[1.17.1] Right-Click conflict.
lazynessmind opened this issue ยท 5 comments
Issue:
When trying to open the backpack with a usable item in the offhand, the backpack opens and triggers the use of the offhand item.
Example:
If I have a Cooked Beef in the offhand and my character has hunger, when I open the Backpack the player starts to eat.
In my understanding you just need to return after opening the backpack screen.
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand)
{
if(!world.isClient)
{
ContainerProviderRegistry.INSTANCE.openContainer(Backpack.BACKPACK_IDENTIFIER, user, buf -> {
//buf.writeItemStack(user.getStackInHand(hand));
ItemStack stack = user.getStackInHand(hand);
buf.writeItemStack(stack);
buf.writeInt(hand == Hand.MAIN_HAND ? 0 : 1);
buf.writeString(stack.getName().asString());
//return here to send a success use (something like this im not at home so I can't see the actual code)
return TypedActionResult.success(user.getStackInHand(hand));
});
}
return super.use(world, user, hand);
}
thanks, but that would not be the way to fix it. I just needed to set the user HAND to be the current hand and it locks things in place. I will update and publish a new version.