Soul Shards: The Old Ways

Soul Shards: The Old Ways

13M Downloads

Soul shard stack is improperly handled when interaction with a Soul Cage

Aaron1011 opened this issue ยท 4 comments

commented

In BlockCage#onInteract, the ItemStack's size is decremented by 1. However, the ItemStack is never offered back to the player's hand. This code is only working because an ItemSoulShard's max stack size is 1 - since it will always be decremented to 0, Forge will detect this and set null into the player's hand. However, this would not work for other stack sizes.

For compatibility with Sponge, which doesn't expect this kind of behavior, it would be nice if you could either:

  • Offer the itemstack back to the player's hand.
  • Handle interactions through either Item#onItemUse or Block#onBlockActivated, which already properly handle changes in the ItemStack.
commented

I should not need to "offer the itemstack back" as I am using the same object. This is valid behavior.

Edit: If you are breaking Forge behavior, I don't see why this is my fault.

commented

I should not need to "offer the itemstack back" as I am using the same object. This is valid behavior.

Not really - it only works because you always end up setting the size to 0. If you look at PlayerInteractionManager#processRightClickBlock, the stack is never set back into the player's hand at all. The only reason it's happening in your case is because NetHandlerPlayServer#processRightClickBlock handles ItemStacks of size 0 specially.

Edit: If you are breaking Forge behavior, I don't see why this is my fault.

Sponge is technically changing Forge behavior, but this is really more of a quirk of Forge's RightClickBlock than anything else. Were the initial size anything other than 1, it would not be properly updated on the server.

commented

Changing behavior that mods expect is equivalent to breaking it.

commented

@TehNut: After looking at the issue more, it appears that you were absolutely correct. This was indeed a bug in Sponge, and has since been fixed.

Sorry to have wasted your time.