Jump to content

Recommended Posts

Posted

Hi guys. I'd like to make modification that change player's inventory (examples you can see on the pictures in the archive https://goo.gl/5VNbmC ) and I need your help.

I will describe the essence of modification.

When you start the game you will have only slots in hot bar and slots for armor. When you put the part of armor to the special slot the additional slots will open. The number of additional slots depends of defence point of that part of armor. So, if you wear set of diamond armor you will have twenty additional slots.

This modification will make more realistic (and hardcore, i think) inventory, because people can't carry many items without clothes.

I'm a beginner in modding and I have many questions.

Some of them are:

1. How can I change the default inventory?

2. How can I dynamically check armor slots and draw right number of slots?

Posted

1. Almost any respectable modder here will NOT download anything from links. You either post GitHub/Pastebin or direct image view.

 

2. I can walk you through what you need, but the task itself is like... 7/10 hard. Also you will NEVER get working code here. Keep that in mind.

 

Things you need to understand - there are:

 

* IExtendedEntityProperties (IEEP) - every entity (including player) is saved to disk using NBT. Inside that NBT is all data about given entity. Now - Forge allows you to extend that data by using IEEP. To create such data you need to create class that implements IEEP and assign it to entity data-map that looks +/- like this Map<KeyToData, IEEPClass>. Then in that IEEP you can store players additional info, in this case - inventory slots.

Note - IEEP can hold ANY data in ANY format - it can be objects, generics or whatever - many people don't see that.

To save data stored in IEEp to NBT you simple save it using load/save methods provided there.

Tutorial: (2nd post)

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and

 

* Inventory - should implement IInventory, an interface that says "this is inventory". Inventory will hold array of ItemStacks[] and will be assigned to given entity, in this case - player. Stacks of this inventory will be saved inside IEEP mentioned above.

 

* Container - containers are something that pulls data from some IInventory and creates "window" from it. Don't mistake it with Gui. Container exist both on client and server once player opens one. Moving things on client will cause server to receive updates and also move it's elements.

 

* Gui - gui is client-side only and will display actuall stuff to player. This is specific gui that will extend GuiContainer and open mentioned cliet-side container that will communicate with server's one.

Many people fk up their guis - there are two reasons - they either don't know java (most of time) or are too lazy to look into internals.

Now - I don't know about 1.7.10 (don't remember what changed), but you might find this useful: (my last post)

http://www.minecraftforge.net/forum/index.php/topic,31297.0.html

 

* SimpleNetworkWrapper - you can't create anything advanced in MC without using packets - you need them to synchronize data.

Note the facts:

- Sending packet to one player will make only that player know stuff. In case of inventories - you need to know that other player ALSO need to know your inventory - to display it (e.g render armour). Inside packets you need to ship entity.getEntityId() and on client - get entity by id and set it's properties for given client.

Tutorial:

http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

 

Overall - I STRONGLY recommend updating to 1.8 - I can help more and people - leave the damn 1.7.10 behind alredy! It's been half a year.

 

You can expect hours of coding and reading vanilla code, ask any questions, keep in mind notes above.

1.7.10 is no longer supported by forge, you are on your own.

Posted

In addition to what Ernio said. To intercept the normal inventory you'd probably need to handle the GuiOpenEvent and open your GUI and cancel the default one.

 

Also, you have to consider the behavior whenever you run over stuff on the ground, or any other time stuff is automatically moved to the inventory. You'll have to handle all those cases (also probably with events) to move them into your special inventory.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.