#DoubleJump problem
1 messages · Page 1 of 1 (latest)
that works
anyway
are you 100% you commented out that other velocity line
because currently thats the only thing that could be causing this issue
public class DoubleJump implements Listener {
private final HashSet<UUID> cooldown = new HashSet<>();
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setAllowFlight(true);
cooldown.add(event.getPlayer().getUniqueId());
}
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE) {
event.setCancelled(true);
if (cooldown.contains(player.getUniqueId())) {
//player.getLocation().setY(event.getPlayer().getLocation().getY() - .1);
return;
}
player.setVelocity(player.getLocation().getDirection().setY(1));
player.playSound(player.getLocation(), Sound.WITHER_SHOOT,1.0f, 1.0f);
cooldown.add(player.getUniqueId());
}
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location location = player.getLocation().clone();
if (cooldown.contains(player.getUniqueId())) {
if (location.add(0, -0.5, 0).getBlock().getType().isSolid()) {
cooldown.remove(player.getUniqueId());
System.out.println("Removed players UUID!");
}
}
}
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event) {
if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE) {
event.getPlayer().setAllowFlight(true);
}
}
}
ok lets do some trial and error using stupid stuff quickly
when the cooldown is added
remove the players ability to fly
when the cooldown is removed, give the ability back
public class DoubleJump implements Listener {
private final HashSet<UUID> cooldown = new HashSet<>();
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setAllowFlight(true);
cooldown.add(event.getPlayer().getUniqueId());
}
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE) {
event.setCancelled(true);
if (cooldown.contains(player.getUniqueId())) {
//player.getLocation().setY(event.getPlayer().getLocation().getY() - .1);
return;
}
player.setVelocity(player.getLocation().getDirection().setY(1));
player.playSound(player.getLocation(), Sound.WITHER_SHOOT,1.0f, 1.0f);
cooldown.add(player.getUniqueId());
player.setAllowFlight(false);
}
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location location = player.getLocation().clone();
if (cooldown.contains(player.getUniqueId())) {
if (location.add(0, -0.5, 0).getBlock().getType().isSolid()) {
cooldown.remove(player.getUniqueId());
player.setAllowFlight(true);
System.out.println("Removed players UUID!");
}
}
}
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event) {
if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE) {
event.getPlayer().setAllowFlight(true);
}
}
}```
like this?
yeah
see if that works
doing it like that since I know mineplex and hypixel do that too
now it works perfectly fine
but sometimes I get falldamage, could you help me cancelling that?
but now they cant fly at all when cooldown is added, so no chance of doing it again
oh
including non-double jump fall damage or all fall damage?
non-double jump fall damage
oh no wait, I need no fall damage at all, but I can do this at my own ig
but can I use the double jump code now or is this smth like the wrong way?
make a Set or something of when a player double jumps, and next time they take damage (EntityDamageEvent), check if its for DamageCause.FALL, and if it is, cancel it and remove them from the set
no its fine if it works
remove that commented line tho
otherwise if you want to yeet all fall damage, just listen to the EntityDamageEvent and if its damage cause FALL, then cancel it
Oh, and one more question:
Im not sure if I am wrong or not but I think I get the Y-Boost in Gamemode 1 too when flying up, how can I fix that?
that code wont be doing it
there is a very slight Y boost in normal minecraft when you do fly so it could be that
took longer to solve than it shouldve lol
note to self: dont trust Event#setCancelled
to a simple problem, there'll always be a stupid explanation
yeah, thank you :)
@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
if (e.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
e.setCancelled(true);
}
}```
should work like this, right?