diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java index 244b580c..ab126eeb 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java @@ -25,19 +25,27 @@ package org.geysermc.connector.network.translators.block; -import lombok.AllArgsConstructor; import lombok.Getter; @Getter -@AllArgsConstructor public class BlockEntry { public static BlockEntry AIR = new BlockEntry("minecraft:air", 0, 0); - private String javaIdentifier; - private int javaId; + private final String javaIdentifier; + private final int javaId; + private final int bedrockRuntimeId; + private final boolean waterlogged; - private int bedrockRuntimeId; + public BlockEntry(String javaIdentifier, int javaId, int bedrockRuntimeId) { + this.javaIdentifier = javaIdentifier; + this.javaId = javaId; + this.bedrockRuntimeId = bedrockRuntimeId; + this.waterlogged = (javaIdentifier.contains("waterlogged=true") + || javaIdentifier.startsWith("minecraft:kelp") + || javaIdentifier.contains("seagrass") + || javaIdentifier.startsWith("minecraft:bubble_column")); + } @Override public boolean equals(Object obj) { diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java index 31be9fa4..7ff630c3 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java @@ -17,11 +17,4 @@ public class BlockTranslator { return javaIdentifierMap.computeIfAbsent(javaIdentifier, key -> Toolbox.BLOCK_ENTRIES.values() .stream().filter(blockEntry -> blockEntry.getJavaIdentifier().equals(key)).findFirst().orElse(null)); } - - public boolean isWaterLogged(BlockEntry entry) { - return (entry.getJavaIdentifier().contains("waterlogged=true") - || entry.getJavaIdentifier().startsWith("minecraft:kelp") - || entry.getJavaIdentifier().contains("seagrass") - || entry.getJavaIdentifier().startsWith("minecraft:bubble_column")); - } } diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index bc6c739b..a80621a8 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -38,7 +38,7 @@ public class ChunkUtils { section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), block.getBedrockRuntimeId()); - if (TranslatorsInit.getBlockTranslator().isWaterLogged(block)) { + if (block.isWaterlogged()) { BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]"); section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z), water.getBedrockRuntimeId()); } @@ -63,7 +63,7 @@ public class ChunkUtils { UpdateBlockPacket waterPacket = new UpdateBlockPacket(); waterPacket.setDataLayer(1); waterPacket.setBlockPosition(pos); - if (TranslatorsInit.getBlockTranslator().isWaterLogged(blockEntry)) { + if (blockEntry.isWaterlogged()) { BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]"); waterPacket.setRuntimeId(water.getBedrockRuntimeId()); } else {