APDevTeam / Movecraft

The original movement plugin for Paper. Reloaded. Again.
GNU General Public License v3.0
121 stars 76 forks source link

Don't move players in craft in certain cases #597

Open goodroach opened 1 year ago

goodroach commented 1 year ago

Is your feature request related to a problem? Please describe. There's currently a problem that I'm sure you're aware of where people can subcraft rotate the turret to pull people out of their ships or abuse the hitboxes in order to mess with players.

I'm not sure if there is a 100% foolproof solution but I have two solutions with different consequences and complexities.

Describe the solution you'd like First solution: When a player is moved by a craft, check if that player is standing on a non-air block in the craft's hitbox. This will move the player. However, any vertical movement will result in the player being flung out of the craft. Second solution: Have a list of blocks in the craft's hitbox with some air blocks including one block above the craft that would move a player if STOOD on.

Not sure of any other way, but this is possible, I think. I just need to know at what point does the craft start to move the player.

TylerS1066 commented 1 year ago

I've wanted to improve the movement hitbox check algorithm for a while, but I don't think complicating it with directions is ideal. I think rather than just over-expanding the detection range for movement, we should check if the block the player is standing on (or is in) is in the craft's hitbox. For a quick first pass, we can eliminate down to only crafts within 5 blocks of the player, then check if the block the player is in or standing on is in the hitbox, then handle collisions by only respecting the larger of the two craft?

goodroach commented 1 year ago

Would this be better if this algorithm was done using a listener since the craftTeleportEntity event is called from all forms of movement? That way, it can be checked in one listener, but I'm not sure if I should add that to the PlayerListener or if I should make a new listener class. The listener seems to already provide a craft, so there would be no need to check for a craft. I just need to check if the player is standing on the craft's block and then cancel the event if they are not.

TylerS1066 commented 1 year ago

Would this be better if this algorithm was done using a listener since the craftTeleportEntity event is called from all forms of movement?

Centralizing code and removing duplicates is always a good idea!

should add that to the PlayerListener or if I should make a new listener class

In my view PlayerListener is already too crowded with far too many features packed in, and should be split. Probably best to not tackle that yet, but instead just put your listener somewhere else.

goodroach commented 1 year ago

Where should I put that listener then?