Skip to content

Instantly share code, notes, and snippets.

@Koboo
Created September 18, 2022 13:45
Show Gist options
  • Save Koboo/15763f24dc5226a03547fefbf205e801 to your computer and use it in GitHub Desktop.
Save Koboo/15763f24dc5226a03547fefbf205e801 to your computer and use it in GitHub Desktop.
"Infinite" room in bukkit through player move event
@EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if(!from.getWorld().getName().equalsIgnoreCase(to.getWorld().getName())) {
return;
}
boolean flipYaw = false;
double x = to.getX();
double z = to.getZ();
if(x < -roomSize || x > roomSize) {
flipYaw = true;
}
if(z < -roomSize || z > roomSize) {
flipYaw = true;
}
float yaw = event.getPlayer().getLocation().getYaw() + 180;
if(flipYaw) {
event.setTo(new Location(to.getWorld(), from.getX(), from.getY(), from.getZ(), yaw, to.getPitch()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment