Jump to content

Make another inventory slot.


CoodleGaming

Recommended Posts

2 hours ago, diesieben07 said:
  1. First make a class that extends ItemStackHandler, this will be a capability you attach to players.
  2. Register a capability with this class (CapabilityManager.register) and inject it into a field for using CapabilityInject.
  3. Make a class implementing ICapabilitySerializable, which stores an instance of your custom ItemStackHandler and serializes it to NBT.
  4. Subscribe to AttachCapabilitiesEvent<Entity>, check if the entity is a player and if so, attach a new instance of your capability provider from step 3.
  5. Subscribe to EntityJoinWorldEvent, check if the entity joining is a player and if so, add a new Slot to it's container (PlayerEntity#container) using Container#addSlot (it's protected, you'll need reflection). Point this slot at your custom capability (PlayerEntity#getCapability).
  6. Use GuiContainerEvent.DrawBackground to draw the background for your Slot over top the normal inventory background.

I have no idea how to do any of this. I am really a noob.

 

Link to comment
Share on other sites

  • 2 weeks later...
On 7/4/2020 at 9:49 PM, diesieben07 said:
  1. First make a class that extends ItemStackHandler, this will be a capability you attach to players.
  2. Register a capability with this class (CapabilityManager.register) and inject it into a field for using CapabilityInject.
  3. Make a class implementing ICapabilitySerializable, which stores an instance of your custom ItemStackHandler and serializes it to NBT.
  4. Subscribe to AttachCapabilitiesEvent<Entity>, check if the entity is a player and if so, attach a new instance of your capability provider from step 3.
  5. Subscribe to EntityJoinWorldEvent, check if the entity joining is a player and if so, add a new Slot to it's container (PlayerEntity#container) using Container#addSlot (it's protected, you'll need reflection). Point this slot at your custom capability (PlayerEntity#getCapability).
  6. Use GuiContainerEvent.DrawBackground to draw the background for your Slot over top the normal inventory background.

I want to ask how to make a item which like AlchemicaBag in EE2?I can't understande the source code in the github,please help me ,please 

Link to comment
Share on other sites

13 minutes ago, Same here said:

I want to ask how to make a item which like AlchemicaBag in EE2?

 Make your own thread if you want help.

 

13 minutes ago, Same here said:

I can't understande the source code in the github

If you can't understand the source it's very unlikely you can actually make it yourself, if you want to make a mod, learn Java, get acquainted with Forge and Minecraft, and then do what you want, asking for help when you don't understand Forge/Java will get you nowhere long-term.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

17 minutes ago, Novârch said:

If you can't understand the source it's very unlikely you can actually make it yourself, if you want to make a mod, learn Java, get acquainted with Forge and Minecraft, and then do what you want, asking for help when you don't understand Forge/Java will get you nowhere long-term.

Maybe there's something wrong with my statement,I've learned the basics of Java.My mod has written a lot of basic items and blocks.In fact ,I know that the alchemy bag stores item data through the player entity.But I want to konw how to make the custom capability which can stores itemstack.I've learned how to extend the player's attribute data through the NBT tag.But the NBT Tag can only store data types.How can I store the itemstack to the playerentity?

Edited by Same here
Link to comment
Share on other sites

4 minutes ago, Same here said:

Maybe there's something wrong with my statement,I've learned the basics of Java.My mod has written a lot of basic items and blocks.In fact ,I know that the alchemy bag stores item data through the player entity.But I want to konw how to make the custom capability which can stores itemstack.I've learned how to extend the player's attribute data through the NBT tag.But the NBT Tag ,but NBT data can only store data types.How can I store the itemstack to the playerentity?

This is just from a first glance, so take it with a grain of salt, EE3 seems to write the player's UUID to the ItemStack-s NBT, this is very hard to follow because of the mods' heavy use of util classes, but can be deciphered with some time, I'll give you the link to the item on GitHub, beware it's for 1.12 though, but I think NBT hasn't really changed since day 1.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

2 minutes ago, Novârch said:

This is just from a first glance, so take it with a grain of salt, EE3 seems to write the player's UUID to the ItemStack-s NBT, this is very hard to follow because of the mods' heavy use of util classes, but can be deciphered with some time, I'll give you the link to the item on GitHub, beware it's for 1.12 though, but I think NBT hasn't really changed since day 1.

Thank you very much !

Link to comment
Share on other sites

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.