You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create this block with with a gui. I want the player to put an enchanted book in a slot. Then when they press a button the enchanted book should be replaced by a normal book. Now that works as it should and I can see the book and hover over it to see Its name. But when I try to take the item out of the slot the book just turns back into the enchanted book. As soon as i click on the item to take it from the slot it just turns back into whatever it was before.
The method that gets called when the button is pushed looks like this:
public void addEnchantment()
{
ItemStack enchantingStack = this.inventory.getStack(0);
if(enchantingStack.isOf(Items.ENCHANTED_BOOK))
{
blockEntity.enchantments.add(EnchantmentHelper.get(enchantingStack));
this.inventory.setStack(0, new ItemStack(Items.BOOK));
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description
I'm trying to create this block with with a gui. I want the player to put an enchanted book in a slot. Then when they press a button the enchanted book should be replaced by a normal book. Now that works as it should and I can see the book and hover over it to see Its name. But when I try to take the item out of the slot the book just turns back into the enchanted book. As soon as i click on the item to take it from the slot it just turns back into whatever it was before.
The method that gets called when the button is pushed looks like this:
I have no idea why this is happening please help.
Here is a link to the GitHub repo
The code is happening in the NewEnchantmentScreenHandler class
Beta Was this translation helpful? Give feedback.
All reactions