Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve event values move events #4895

Merged

Conversation

TPGamesNL
Copy link
Member

Description

Change PlayerTeleportEvent location event value to include PlayerMoveEvent (first extends the latter)
Add PlayerMoveEvent default and future location event value
Add EntityMoveEvent location event values
Also added more specific event classes to EvtMove


Target Minecraft Versions: partially Paper 1.16+
Requirements: none
Related Issues: #4890

Add future and default location event value for PlayerMoveEvent
Add past, default and future event value for EntityMoveEvent
@TPGamesNL TPGamesNL added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. labels Jul 11, 2022
@TPGamesNL TPGamesNL requested a review from TheLimeGlass July 11, 2022 08:41
Copy link
Member

@AyhamAl-Ali AyhamAl-Ali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a question, why is PlayerMoveEvent getFrom() at time -1 and getTo() at time 0 while EntityMoveEvent getFrom() at time 0 and getTo() at time 1?

@TPGamesNL
Copy link
Member Author

The difference between these things determines which will be the default. If they're -1 and 0, the default is the future state, and if they're 0 and 1, the default is the past state.

For PlayerMoveEvent, I chose the default to be the future state, because if you cancel a move event, the client sees it as being teleported back after moving instead of actually not moving. This means, to the client, the player has moved already so their location is updated already. If you think it's more practically useful the other way around, lmk (for example, I don't know how the server handles it internally, what the actual player's location is, or how other clients see the player).

For EntityMoveEvent, I chose the default to be the past state, again due to the cancellation stuff. When I tried pushing the entity, they just didn't move at all, therefore I think it makes more sense to have the previous location as default.

@AyhamAl-Ali
Copy link
Member

Cool! your choice fits the situation IMO.

@TPGamesNL TPGamesNL requested a review from APickledWalrus July 20, 2022 09:10
@TheLimeGlass TheLimeGlass merged commit 0db7944 into SkriptLang:master Jul 23, 2022
@TPGamesNL TPGamesNL deleted the fix/move-event-location-time-states branch July 23, 2022 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants