Jump to content

[1.18.2] Error when attaching capabilities


Squander

Recommended Posts

1 hour ago, Luis_ST said:

I'm not sure what's the problem everything works how i think it should.

When I turn on the menu, the items that I have in the hotbar appear in 9 slots form my capability, and I want more space

Edited by Squander
Link to comment
Share on other sites

This is not a backpack, I open it with an event (only for the test) in the ClickBlock class

3 minutes ago, Luis_ST said:

Is the code in your Git repo up to date?
How did you open the Backpack?
Did you tried a new World?

 

Edited by Squander
Link to comment
Share on other sites

1 hour ago, Squander said:

and I want more space

I'll guess you mean the size of the ExtraStorageInventory, in your case the size is set in AttachCapabilities where you create ExtraStorageInventory,
and in ClickBlock where you send the size to the client. If you change these values and handle the new Slot size in your ExtraStorageMenu you can expands the ExtraStorage.

Note if you change the value you need to create a new World.

1 hour ago, Squander said:

When I turn on the menu, the items that I have in the hotbar appear in 9 slots form my capability

Finally i found your issue, as D7 already told you can not use ITEM_HANDLER_CAPABILITY but this include IItemHandler.
Due you use IItemHandler for your Capability it always return the already attached IItemHandler (the player inventory).
The steps to solve this problem are easy:

  1. Create a new interface which extends IItemHandler
  2. Implement this interface in your ExtraStorageInventory
  3. Use this interface for your Capability and the LazyOptional
Link to comment
Share on other sites

17 minutes ago, Luis_ST said:

I'll guess you mean the size of the ExtraStorageInventory, in your case the size is set in AttachCapabilities where you create ExtraStorageInventory,
and in ClickBlock where you send the size to the client. If you change these values and handle the new Slot size in your ExtraStorageMenu you can expands the ExtraStorage.

Note if you change the value you need to create a new World.

Finally i found your issue, as D7 already told you can not use ITEM_HANDLER_CAPABILITY but this include IItemHandler.
Due you use IItemHandler for your Capability it always return the already attached IItemHandler (the player inventory).
The steps to solve this problem are easy:

  1. Create a new interface which extends IItemHandler
  2. Implement this interface in your ExtraStorageInventory
  3. Use this interface for your Capability and the LazyOptional

Does my IItemHandler extension interface need to be registered with RegisterCapabilityEvent?

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.