-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add PlayerLandEvent #10859
base: master
Are you sure you want to change the base?
Add PlayerLandEvent #10859
Conversation
|
||
+ // Paper start - Add PlayerLandEvent | ||
+ if (flag2 && !(this.player.getY() - d4 >= 0.0)) { | ||
+ this.player.setOnGround(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is up with setting the player's ground value here? As this is technically changing behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I set the ground value here is because that method runs checkSupportingBlock()
which updates Entity#mainSupportingBlockPos
. The reason I'm not just taking advantage of this.player.setOnGroundWithKnownMovement()
which happens just a few lines below is because I previously made this event cancellable, But after further testing, it had pretty buggy behaviour... I'm going to quickly just move this below the this.player.setOnGroundWithKnownMovement()
in the next commit.
import net.minecraft.world.phys.shapes.BooleanOp; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
+import org.bukkit.craftbukkit.block.CraftBlock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fully qualified imports when using a class not very often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, will change.
@NonSwag Whilst first looking how to do this in my own plugin, I saw that the best to check when a player lands, is to use a |
isOnGround is exactly as reliable as your new event, because that is everything the server knows about the players on ground state. And adding api to get the mainSupportingBlock for the player should be easy and unproblematic. |
there is already an pr open which exposes that iirc |
mainSupportingBlock iirc was dropped because of how funky movement is as, at the time PlayerMoveEvent e.g. is called, the supporting block is temporarily AIR until the server recomputes it right after. |
yeah. if someone finds a solution for it in #9298 then that won‘t be a problem anymore |
If you think this doesn't need to be added, you can close this post. I think |
isOnGround is sent with the movement packet so in theory it could be added to the movement event |
Again, feel free to close this if you think it's not worth adding |
Description
This is a very simple event. This event is triggered whenever a player lands on a block. The event is mostly useful for when you want to do a specific action whenever a player lands on a specific block/location.
Event Details
Key Components