From a498e9bad0b83195b8bc2900889344f2c3f0565c Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 25 Sep 2023 20:50:02 +0200 Subject: [PATCH] Fixes some liquid hitbox problems --- .../minigames/listener/MoveListener.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/knarcraft/minigames/listener/MoveListener.java b/src/main/java/net/knarcraft/minigames/listener/MoveListener.java index 5e50440..7882a7d 100644 --- a/src/main/java/net/knarcraft/minigames/listener/MoveListener.java +++ b/src/main/java/net/knarcraft/minigames/listener/MoveListener.java @@ -191,14 +191,18 @@ public class MoveListener implements Listener { */ private boolean checkForSpecialBlock(ArenaSession arenaSession, Location toLocation) { SharedConfiguration sharedConfiguration = MiniGames.getInstance().getSharedConfiguration(); - double liquidDepth = sharedConfiguration.getLiquidHitBoxDepth(); double solidDepth = sharedConfiguration.getSolidHitBoxDistance(); - + double liquidDepth = sharedConfiguration.getLiquidHitBoxDepth(); Arena arena = arenaSession.getArena(); // For water, only trigger when the player enters the water, but trigger earlier for everything else - double depth = arena.winLocationIsSolid() ? solidDepth : liquidDepth; - for (Block block : getBlocksBeneathLocation(toLocation, depth)) { + Set potentialWinTriggerBlocks; + if (arena.winLocationIsSolid()) { + potentialWinTriggerBlocks = getBlocksBeneathLocation(toLocation, solidDepth); + } else { + potentialWinTriggerBlocks = getBlocksBeneathLocation(toLocation, liquidDepth); + } + for (Block block : potentialWinTriggerBlocks) { if (arena.willCauseWin(block)) { arenaSession.triggerWin(); return true; @@ -207,7 +211,15 @@ public class MoveListener implements Listener { // Check if the player is about to hit a non-air and non-liquid block for (Block block : getBlocksBeneathLocation(toLocation, solidDepth)) { - if (!block.getType().isAir() && arena.willCauseLoss(block)) { + if (!block.getType().isAir() && !block.isLiquid() && arena.willCauseLoss(block)) { + arenaSession.triggerLoss(); + return true; + } + } + + // Check if the player has entered a liquid that causes a loss + for (Block block : getBlocksBeneathLocation(toLocation, liquidDepth)) { + if (block.isLiquid() && arena.willCauseLoss(block)) { arenaSession.triggerLoss(); return true; }