-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add EntityLandEvent #14204
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
Open
Clexus
wants to merge
6
commits into
PaperMC:main
Choose a base branch
from
Clexus:land
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−9
Open
Add EntityLandEvent #14204
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df0c561
Add EntityLandEvent
Clexus db6a5fc
Add fall distance support
Clexus 78ac26b
Merge branch 'PaperMC:main' into land
Clexus b11adee
Use new fallOn
Clexus b060a50
Move event call to right place
Clexus a93f16e
Forgot to remove comment
Clexus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
paper-api/src/main/java/io/papermc/paper/event/entity/EntityLandEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package io.papermc.paper.event.entity; | ||
|
|
||
| import org.bukkit.block.Block; | ||
| import org.bukkit.entity.Entity; | ||
| import org.bukkit.event.Cancellable; | ||
| import org.bukkit.event.HandlerList; | ||
| import org.bukkit.event.entity.EntityEvent; | ||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| /** | ||
| * Called when an {@link Entity} lands on the block after falling. | ||
| * This event is called before {@link org.bukkit.event.entity.EntityDamageEvent}, {@link org.bukkit.event.entity.EntityChangeBlockEvent}, {@link org.bukkit.event.player.PlayerInteractEvent} | ||
| * and {@link org.bukkit.event.entity.EntityInteractEvent}. | ||
| */ | ||
| @NullMarked | ||
| public class EntityLandEvent extends EntityEvent implements Cancellable { | ||
|
|
||
| private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
|
|
||
| private final Block block; | ||
| private boolean cancelled; | ||
| private double fallDistance; | ||
|
|
||
| public EntityLandEvent(final Entity entity, final Block block, double fallDistance) { | ||
| super(entity); | ||
| this.block = block; | ||
| this.fallDistance = fallDistance; | ||
| } | ||
|
|
||
| @Override | ||
| public HandlerList getHandlers() { | ||
| return HANDLER_LIST; | ||
| } | ||
|
|
||
| public static HandlerList getHandlerList() { | ||
| return HANDLER_LIST; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the block that the entity landed on. | ||
| * | ||
| * @return the block that the entity landed on | ||
| */ | ||
| public Block getBlock() { | ||
| return this.block; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isCancelled() { | ||
| return this.cancelled; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether to cancel the landing, cancelling this event will prevent | ||
| * the entity from taking fall damage and interact with the block. (ex: break turtle egg) | ||
| * | ||
| * @param cancel true if the event should be cancelled, false otherwise | ||
| */ | ||
| @Override | ||
| public void setCancelled(final boolean cancel) { | ||
| this.cancelled = cancel; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the fall distance of the entity before landing. | ||
| * | ||
| * @return the fall distance | ||
| */ | ||
| public double getFallDistance() { | ||
| return fallDistance; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the fall distance of the entity before landing. | ||
| * Fall distance in the event is used to calculate fall damage and | ||
| * the chance of transforming {@link org.bukkit.Material#FARMLAND} to {@link org.bukkit.Material#DIRT} and | ||
| * the type of falling sound when the entity lands on {@link org.bukkit.Material#POWDER_SNOW}. | ||
| * | ||
| * @param fallDistance the fall distance | ||
| */ | ||
| public void setFallDistance(final double fallDistance) { | ||
| this.fallDistance = fallDistance; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.