Skip to content

Commit

Permalink
For /elevator teleport try to find a safe area to teleport to.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew121410 committed Aug 3, 2024
1 parent ed1ee2a commit 038a464
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,27 @@ public void run() {
}

Location location = elevator.getElevatorMovement().getAtDoor();

// Find a spot to teleport the player. 3x3 area.
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
Location newLocation = location.clone().add(x, 0, z);

Location newLocation1 = newLocation.clone().add(0, 1, 0);
Location newLocation2 = newLocation1.clone().add(0, 1, 0);

if (!newLocation.getBlock().getType().isAir()) {
if (newLocation1.getBlock().getType().isAir() && newLocation2.getBlock().getType().isAir()) {
location = newLocation1;
break;
}
} else {
break;
}

}
}

p.teleport(location);
p.sendMessage(Translate.miniMessage("<gold>You have been teleported to the elevator."));
return true;
Expand Down

0 comments on commit 038a464

Please sign in to comment.