From 021ffe2d946e270c170ebbd34c014fd6e80ffc87 Mon Sep 17 00:00:00 2001 From: David Choo <4722249+davchoo@users.noreply.github.com> Date: Sun, 19 Mar 2023 11:30:56 -0400 Subject: [PATCH] Update ringing bell block event logic (#3625) Check for BellValue instead of a GenericBlockValue Removes now unnecessary JAVA_BELL_ID from BlockStateValues --- .../geyser/level/block/BlockStateValues.java | 1 - .../registry/populator/BlockRegistryPopulator.java | 10 +--------- .../java/level/JavaBlockEventTranslator.java | 13 +++++++------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/level/block/BlockStateValues.java b/core/src/main/java/org/geysermc/geyser/level/block/BlockStateValues.java index 58cbce77f..c6fc60303 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/BlockStateValues.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/BlockStateValues.java @@ -68,7 +68,6 @@ public final class BlockStateValues { public static final int JAVA_AIR_ID = 0; - public static int JAVA_BELL_ID; public static int JAVA_COBWEB_ID; public static int JAVA_FURNACE_ID; public static int JAVA_FURNACE_LIT_ID; diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java index b931750e1..ad1066491 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java @@ -223,7 +223,6 @@ public final class BlockRegistryPopulator { Deque cleanIdentifiers = new ArrayDeque<>(); int javaRuntimeId = -1; - int bellBlockId = -1; int cobwebBlockId = -1; int furnaceRuntimeId = -1; int furnaceLitRuntimeId = -1; @@ -300,10 +299,7 @@ public final class BlockRegistryPopulator { // It's possible to only have this store differences in names, but the key set of all Java names is used in sending command suggestions BlockRegistries.JAVA_TO_BEDROCK_IDENTIFIERS.register(cleanJavaIdentifier.intern(), bedrockIdentifier.intern()); - if (javaId.startsWith("minecraft:bell[")) { - bellBlockId = uniqueJavaId; - - } else if (javaId.contains("cobweb")) { + if (javaId.contains("cobweb")) { cobwebBlockId = uniqueJavaId; } else if (javaId.startsWith("minecraft:furnace[facing=north")) { @@ -324,10 +320,6 @@ public final class BlockRegistryPopulator { slimeBlockRuntimeId = javaRuntimeId; } } - if (bellBlockId == -1) { - throw new AssertionError("Unable to find bell in palette"); - } - BlockStateValues.JAVA_BELL_ID = bellBlockId; if (cobwebBlockId == -1) { throw new AssertionError("Unable to find cobwebs in palette"); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaBlockEventTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaBlockEventTranslator.java index 149e8356e..aa7c9e6e7 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaBlockEventTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaBlockEventTranslator.java @@ -103,7 +103,7 @@ public class JavaBlockEventTranslator extends PacketTranslator 0; // north - case 4 -> 1; // east - case 5 -> 3;// west - default -> bellValue.getValue(); // south (2) is identical + int bedrockRingDirection = switch (bellValue.getDirection()) { + case SOUTH -> 0; + case WEST -> 1; + case NORTH -> 2; + case EAST -> 3; + default -> throw new IllegalStateException("Unexpected BellValue Direction: " + bellValue.getDirection()); }; builder.putInt("Direction", bedrockRingDirection); builder.putByte("Ringing", (byte) 1);