mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2024-12-05 00:43:15 +01:00
Fixes #6 by re-applying the arena state
Additionally, as a feature of fixing #6, the hit-detection has been made more accurate. Also, all non-solid blocks are now triggered when they are passed through, rather than when hit.
This commit is contained in:
parent
3626d997b8
commit
51237cb11a
@ -131,6 +131,7 @@ public class DropperArenaSession {
|
||||
}
|
||||
//Teleport the player back to the top
|
||||
PlayerTeleporter.teleportPlayer(this.player, this.arena.getSpawnLocation(), true, false);
|
||||
this.entryState.setArenaState(this.arena.getPlayerHorizontalVelocity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,12 +40,19 @@ public class MoveListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This decides how far inside a non-solid block the player must go before detection triggers. The closer to -1
|
||||
it is, the more accurate it will seem to the player, but the likelihood of not detecting the hit decreases */
|
||||
double liquidDepth = -0.8;
|
||||
/* This decides the distance the player must be from the block below before a hit triggers. If too low, the
|
||||
likelihood of detecting the hit decreases, but the immersion increases. */
|
||||
double solidDepth = 0.2;
|
||||
|
||||
// Only do block type checking if the block beneath the player changes
|
||||
if (event.getFrom().getBlock() != event.getTo().getBlock()) {
|
||||
// Check if the player enters water
|
||||
Material winBlockType = arenaSession.getArena().getWinBlockType();
|
||||
// For water, only trigger when the player enters the water, but trigger earlier for everything else
|
||||
int depth = winBlockType == Material.WATER ? 0 : 1;
|
||||
double depth = !winBlockType.isSolid() ? liquidDepth : solidDepth;
|
||||
for (Block block : getBlocksBeneathLocation(event.getTo(), depth)) {
|
||||
if (block.getType() == winBlockType) {
|
||||
arenaSession.triggerWin();
|
||||
@ -54,7 +61,7 @@ public class MoveListener implements Listener {
|
||||
}
|
||||
|
||||
// Check if the player is about to hit a non-air and non-liquid block
|
||||
for (Block block : getBlocksBeneathLocation(event.getTo(), 1)) {
|
||||
for (Block block : getBlocksBeneathLocation(event.getTo(), solidDepth)) {
|
||||
if (!block.getType().isAir() && block.getType() != Material.STRUCTURE_VOID &&
|
||||
block.getType() != Material.WATER && block.getType() != Material.LAVA) {
|
||||
arenaSession.triggerLoss();
|
||||
|
Loading…
Reference in New Issue
Block a user