mirror of
https://github.com/SunNetservers/Launchpad.git
synced 2025-03-31 08:46:29 +02:00
Improves launchpad hit detection #5
This commit is contained in:
parent
c6ecd8219b
commit
e6bc5908f5
@ -53,6 +53,10 @@ public class LaunchpadUseListener implements Listener {
|
|||||||
Block block = event.getTo().getBlock();
|
Block block = event.getTo().getBlock();
|
||||||
if (block.getType().isAir()) {
|
if (block.getType().isAir()) {
|
||||||
block = block.getRelative(BlockFace.DOWN);
|
block = block.getRelative(BlockFace.DOWN);
|
||||||
|
// Only trigger hit detection for passable blocks if the player is in the block
|
||||||
|
if (block.isPassable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pressure plates are detected in onPressurePlateUse instead
|
// Pressure plates are detected in onPressurePlateUse instead
|
||||||
@ -68,19 +72,10 @@ public class LaunchpadUseListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
double velocity = player.getVelocity().getY();
|
|
||||||
// These are constants for the velocity of a player when landing from a jump and just walking respectively.
|
|
||||||
// When flying, the Y velocity is always 0.
|
|
||||||
double LANDING_Y_VELOCITY = -0.22768848754498797;
|
|
||||||
double DEFAULT_Y_VELOCITY = -0.0784000015258789;
|
|
||||||
// Make sure not to trigger until the player touches the block. This doesn't work if the player is flying.
|
|
||||||
if (!player.isFlying() && (velocity != LANDING_Y_VELOCITY && velocity != DEFAULT_Y_VELOCITY)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch the player
|
// Launch the player
|
||||||
if (launchpad != null) {
|
if (launchpad != null) {
|
||||||
launch(event.getPlayer(), launchpad);
|
launch(player, launchpad);
|
||||||
} else {
|
} else {
|
||||||
launch(player, type);
|
launch(player, type);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user