Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Handle rotation for PlayerMoveEvent

Open Doc94 opened this issue 1 year ago • 6 comments

This close #8144 by using the new teleport API for handle cases where in PlayerMoveEvent the event only change the rotation of the Player.

Doc94 avatar Jul 23 '22 16:07 Doc94

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

Doc94 avatar Jul 27 '22 02:07 Doc94

Rebased and now are two files (thanks indexs) :3

Doc94 avatar Jul 31 '22 15:07 Doc94

Friday of PR rebased.

Doc94 avatar Aug 12 '22 16:08 Doc94

and conflicts gone again.

Doc94 avatar Oct 22 '22 01:10 Doc94

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?

Owen1212055 avatar Nov 18 '22 03:11 Owen1212055

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.

Doc94 avatar Nov 19 '22 13:11 Doc94

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.

Owen1212055 avatar Nov 26 '22 00:11 Owen1212055

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.

Owen1212055 avatar Nov 30 '23 19:11 Owen1212055