diff --git a/connector/src/main/java/org/geysermc/connector/inventory/EnchantingContainer.java b/connector/src/main/java/org/geysermc/connector/inventory/EnchantingContainer.java index 8638e6eab4d..d11ca678819 100644 --- a/connector/src/main/java/org/geysermc/connector/inventory/EnchantingContainer.java +++ b/connector/src/main/java/org/geysermc/connector/inventory/EnchantingContainer.java @@ -47,6 +47,9 @@ public EnchantingContainer(String title, int id, int size, PlayerInventory playe geyserEnchantOptions = new GeyserEnchantOption[3]; for (int i = 0; i < geyserEnchantOptions.length; i++) { geyserEnchantOptions[i] = new GeyserEnchantOption(i); + // Options cannot be null, so we build initial options + // GeyserSession can be safely null here because it's only needed for net IDs + enchantOptions[i] = geyserEnchantOptions[i].build(null); } } } diff --git a/connector/src/main/java/org/geysermc/connector/inventory/GeyserEnchantOption.java b/connector/src/main/java/org/geysermc/connector/inventory/GeyserEnchantOption.java index a643fc194ec..e9ad81a6a85 100644 --- a/connector/src/main/java/org/geysermc/connector/inventory/GeyserEnchantOption.java +++ b/connector/src/main/java/org/geysermc/connector/inventory/GeyserEnchantOption.java @@ -67,12 +67,8 @@ public GeyserEnchantOption(int javaIndex) { } public EnchantOptionData build(GeyserSession session) { - if (enchantLevel == -1) { - // Should not be sent to the client, as it is supposed to be empty - return null; - } return new EnchantOptionData(xpCost, javaIndex + 16, EMPTY, - Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY, - javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), session.getNextItemNetId()); + enchantLevel == -1 ? EMPTY : Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY, + javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), enchantLevel == -1 ? 0 : session.getNextItemNetId()); } }