From 175d9aff487c30eebb414fdd5354be327456e65e Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Mon, 4 Oct 2021 08:58:33 -0400 Subject: [PATCH] Don't add sculk sensor to creative items without extended height enabled Fixes #2564 --- .../populator/ItemRegistryPopulator.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/registry/populator/ItemRegistryPopulator.java b/connector/src/main/java/org/geysermc/connector/registry/populator/ItemRegistryPopulator.java index 65fa1e5a0..175bf13d7 100644 --- a/connector/src/main/java/org/geysermc/connector/registry/populator/ItemRegistryPopulator.java +++ b/connector/src/main/java/org/geysermc/connector/registry/populator/ItemRegistryPopulator.java @@ -42,8 +42,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.*; -import lombok.AllArgsConstructor; -import lombok.Getter; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.translators.item.StoredItemMappings; import org.geysermc.connector.registry.BlockRegistries; @@ -73,14 +71,7 @@ public class ItemRegistryPopulator { PALETTE_VERSIONS.put("1_17_30", new PaletteVersion(Bedrock_v465.V465_CODEC.getProtocolVersion(), Collections.emptyMap())); } - @Getter - @AllArgsConstructor - private static class PaletteVersion { - private final int protocolVersion; - /** - * Key - item not available in this version. Value - Java replacement item - */ - private final Map additionalTranslatedItems; + private record PaletteVersion(int protocolVersion, Map additionalTranslatedItems) { } public static void populate() { @@ -176,6 +167,10 @@ public class ItemRegistryPopulator { } String identifier = itemNode.get("id").textValue(); + if (identifier.equals("minecraft:sculk_sensor") && !GeyserConnector.getInstance().getConfig().isExtendedWorldHeight()) { + // https://github.com/GeyserMC/Geyser/issues/2564 + continue; + } StartGamePacket.ItemEntry entry = entries.get(identifier); int id = -1; if (entry != null) { @@ -210,7 +205,7 @@ public class ItemRegistryPopulator { } } - BlockMappings blockMappings = BlockRegistries.BLOCKS.forVersion(palette.getValue().getProtocolVersion()); + BlockMappings blockMappings = BlockRegistries.BLOCKS.forVersion(palette.getValue().protocolVersion()); int itemIndex = 0; int javaFurnaceMinecartId = 0; @@ -227,12 +222,12 @@ public class ItemRegistryPopulator { javaOnlyItems.add("minecraft:sculk_sensor"); } // Java-only items for this version - javaOnlyItems.addAll(palette.getValue().getAdditionalTranslatedItems().keySet()); + javaOnlyItems.addAll(palette.getValue().additionalTranslatedItems().keySet()); for (Map.Entry entry : items.entrySet()) { String javaIdentifier = entry.getKey().intern(); GeyserMappingItem mappingItem; - String replacementItem = palette.getValue().getAdditionalTranslatedItems().get(javaIdentifier); + String replacementItem = palette.getValue().additionalTranslatedItems().get(javaIdentifier); if (replacementItem != null) { mappingItem = items.get(replacementItem); } else { @@ -475,7 +470,7 @@ public class ItemRegistryPopulator { NbtMapBuilder componentBuilder = NbtMap.builder(); // Conveniently, as of 1.16.200, the furnace minecart has a texture AND translation string already. // 1.17.30 moves the icon to the item properties section - (palette.getValue().getProtocolVersion() >= Bedrock_v465.V465_CODEC.getProtocolVersion() ? + (palette.getValue().protocolVersion() >= Bedrock_v465.V465_CODEC.getProtocolVersion() ? itemProperties : componentBuilder).putCompound("minecraft:icon", NbtMap.builder() .putString("texture", "minecart_furnace") .putString("frame", "0.000000") @@ -517,7 +512,7 @@ public class ItemRegistryPopulator { .furnaceMinecartData(furnaceMinecartData) .build(); - Registries.ITEMS.register(palette.getValue().getProtocolVersion(), itemMappings); + Registries.ITEMS.register(palette.getValue().protocolVersion(), itemMappings); } } }