Fixes some liquid hitbox problems

This commit is contained in:
Kristian Knarvik 2023-09-25 20:50:02 +02:00
parent d8bf77d317
commit a498e9bad0

View File

@ -191,14 +191,18 @@ public class MoveListener implements Listener {
*/ */
private boolean checkForSpecialBlock(ArenaSession arenaSession, Location toLocation) { private boolean checkForSpecialBlock(ArenaSession arenaSession, Location toLocation) {
SharedConfiguration sharedConfiguration = MiniGames.getInstance().getSharedConfiguration(); SharedConfiguration sharedConfiguration = MiniGames.getInstance().getSharedConfiguration();
double liquidDepth = sharedConfiguration.getLiquidHitBoxDepth();
double solidDepth = sharedConfiguration.getSolidHitBoxDistance(); double solidDepth = sharedConfiguration.getSolidHitBoxDistance();
double liquidDepth = sharedConfiguration.getLiquidHitBoxDepth();
Arena arena = arenaSession.getArena(); Arena arena = arenaSession.getArena();
// For water, only trigger when the player enters the water, but trigger earlier for everything else // For water, only trigger when the player enters the water, but trigger earlier for everything else
double depth = arena.winLocationIsSolid() ? solidDepth : liquidDepth; Set<Block> potentialWinTriggerBlocks;
for (Block block : getBlocksBeneathLocation(toLocation, depth)) { if (arena.winLocationIsSolid()) {
potentialWinTriggerBlocks = getBlocksBeneathLocation(toLocation, solidDepth);
} else {
potentialWinTriggerBlocks = getBlocksBeneathLocation(toLocation, liquidDepth);
}
for (Block block : potentialWinTriggerBlocks) {
if (arena.willCauseWin(block)) { if (arena.willCauseWin(block)) {
arenaSession.triggerWin(); arenaSession.triggerWin();
return true; 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 // Check if the player is about to hit a non-air and non-liquid block
for (Block block : getBlocksBeneathLocation(toLocation, solidDepth)) { 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(); arenaSession.triggerLoss();
return true; return true;
} }