Paper
Paper copied to clipboard
Handle rotation for PlayerMoveEvent
This close #8144 by using the new teleport API for handle cases where in PlayerMoveEvent the event only change the rotation of the Player.
Example of this patch using.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event) {
getServer().broadcastMessage(event.getCause().toString());
}
public void onPlayerMove(PlayerMoveEvent event) {
// Why does this call a teleport event?
getServer().broadcastMessage("test move: [" + event.getFrom() + "] [" + event.getTo() + "]");
if (event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.STICK)) {
Location to = event.getFrom();
to.setPitch(90);
//to.setYaw(90);
event.setTo(to);
} else if (event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.SLIME_BALL)) {
Location to = event.getFrom();
to.setWorld(getServer().getWorld("world_nether"));
to.setPitch(90);
//to.setYaw(90);
event.setTo(to);
}
}
https://youtu.be/mHXRMvHTpEM
Rebased and now are two files (thanks indexs) :3
Friday of PR rebased.
and conflicts gone again.
Generally I’m a bit iffy as this is a major behavior change. Unfortunately I’m not sure it’s worth making a breaking change like this?
Well this breaking is very situational (? Because only handle the old form in spigot to make a teleport for any variation in the destination, this change is more to reduce this teleportation for rotations.
Yes, it's situational but you cannot really tell if people may have relied on this behavior or not. What I would instead do is perhaps make a new event, maybe PlayerMoveHeadEvent or something idk.
The PlayerMoveHeadEvent could act as a way to allow plugins to prevent players from moving their head while still allowing to keep velocity the same. But again, I think that changing the behavior of this event like that isn't the best here.
Closing, in general, see the listed comment above. I do not want to so strictly break previous behavior because it's expected that this event reset the velocity of the player when canceled, and using this new rotation logic for the move event breaks this.