From 483c485dd9b9a6c8bd6aacb1f146298d10f5a622 Mon Sep 17 00:00:00 2001 From: xoydev Date: Wed, 2 Sep 2026 00:29:01 +0200 Subject: [PATCH] fix(HytaleRtpCommand): add correct fluid ids for isSafeLocation - Fix fluid check for RTP Command --- .../commands/hytale/HytaleRtpCommand.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliteessentials/commands/hytale/HytaleRtpCommand.java b/src/main/java/com/eliteessentials/commands/hytale/HytaleRtpCommand.java index 6fd6688..f6ab486 100644 --- a/src/main/java/com/eliteessentials/commands/hytale/HytaleRtpCommand.java +++ b/src/main/java/com/eliteessentials/commands/hytale/HytaleRtpCommand.java @@ -605,6 +605,33 @@ private Integer findHighestSolidBlock(WorldChunk chunk, int x, int z, int minY) } return null; } + + // FluidId is 0 if the position is not a fluid + private enum FluidType { + UNKNOWN(-1, "Unknown Fluid"), + NONE(0, "No Fluid"), + WATER(2, "Water"), + TAR(3, "Tar"), + SLIME(4, "Slime"), + RED_SLIME(5, "Red Slime"), + POISON(6, "Poison"), + FIRE(8, "Fire"); + + public final int id; + public final String name; + + FluidType(int id, String name) { + this.id = id; + this.name = name; + } + + public static FluidType fromId(int id) { + for(FluidType f : FluidType.values()) { + if(f.id == id) return f; + } + return UNKNOWN; + } + } private boolean isSafeLocation(WorldChunk chunk, int x, int y, int z, boolean debug) { try { @@ -618,10 +645,11 @@ private boolean isSafeLocation(WorldChunk chunk, int x, int y, int z, boolean de Object fluidIdObj = getFluidIdMethod.invoke(chunk, x, checkY, z); if (fluidIdObj instanceof Integer) { int fluidId = (Integer) fluidIdObj; - if (fluidId == 6 || fluidId == 7) { + if (fluidId != FluidType.NONE.id) { if (debug) { - String fluidType = (fluidId == 6) ? "LAVA" : "WATER"; - logger.info("[RTP-SAFETY] " + fluidType + " detected at Y" + (yOffset >= 0 ? "+" : "") + yOffset); + FluidType fluidType = FluidType.fromId(fluidId); + String fluidDebugText = fluidType != FluidType.UNKNOWN ? fluidType.name : fluidType.name + "(" + fluidId + ")"; + logger.info("[RTP-SAFETY] " + fluidDebugText + " detected at Y" + (yOffset >= 0 ? "+" : "") + yOffset); } return false; } @@ -637,7 +665,7 @@ private boolean isSafeLocation(WorldChunk chunk, int x, int y, int z, boolean de Object fluidIdObj = getFluidIdMethod.invoke(chunk, checkX, y, checkZ); if (fluidIdObj instanceof Integer) { int fluidId = (Integer) fluidIdObj; - if (fluidId == 6 || fluidId == 7) { + if (fluidId != FluidType.NONE.id) { return false; } }