From 96c58566b5c021ca14a91d26117bfb7575fd515f Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:27:05 -0400 Subject: [PATCH] Map unbreakable item component Fixes #4893 --- core/src/main/java/org/geysermc/geyser/item/type/Item.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index 57538565a..2417177ce 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -170,6 +170,11 @@ public class Item { builder.putInt("RepairCost", repairCost); } + // If the tag exists, it's unbreakable; the value is just weather to show the tooltip. As of Java 1.21 + if (components.getDataComponents().containsKey(DataComponentType.UNBREAKABLE)) { + builder.putByte("Unbreakable", (byte) 1); + } + // Prevents the client from trying to stack items with untranslated components // Relies on correct hash code implementation, and some luck builder.putInt("GeyserHash", components.hashCode()); // TODO: don't rely on this