MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create an item that if right clicked on a block, destroys a diamond in the inventory"
/* This mod creates an item that, when right clicked on a block, will destroy a diamond from the player's inventory. */ public class DiamondDestroyerItem extends Item { public DiamondDestroyerItem(Properties properties) { super(properties); } @Override public ActionResultType useOn(ItemUseContext context) { PlayerEntity player = context.getPlayer(); if (player == null) { return ActionResultType.PASS; } // Check if player has a diamond in their inventory if (player.inventory.contains(new ItemStack(Items.DIAMOND))) { // If they do, remove one player.inventory.removeItem(new ItemStack(Items.DIAMOND)); return ActionResultType.SUCCESS; } return ActionResultType.PASS; } }