mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
Entity Jump API
This commit is contained in:
parent
599bf3512d
commit
fbcf4759fb
2 changed files with 72 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
||||||
|
package com.destroystokyo.paper.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.entity.EntityEvent;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an entity jumps
|
||||||
|
* <p>
|
||||||
|
* Cancelling the event will stop the entity from jumping
|
||||||
|
*/
|
||||||
|
@NullMarked
|
||||||
|
public class EntityJumpEvent extends EntityEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public EntityJumpEvent(final LivingEntity entity) {
|
||||||
|
super(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LivingEntity getEntity() {
|
||||||
|
return (LivingEntity) super.getEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return this.cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(final boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1159,4 +1159,26 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
||||||
return this.getActiveItemHand();
|
return this.getActiveItemHand();
|
||||||
}
|
}
|
||||||
// Paper end - active item API
|
// Paper end - active item API
|
||||||
|
|
||||||
|
// Paper start - entity jump API
|
||||||
|
/**
|
||||||
|
* Get entity jump state.
|
||||||
|
* <p>
|
||||||
|
* Jump state will be true when the entity has been marked to jump.
|
||||||
|
*
|
||||||
|
* @return entity jump state.
|
||||||
|
*/
|
||||||
|
boolean isJumping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set entity jump state
|
||||||
|
* <p>
|
||||||
|
* Setting to true will mark the entity to jump.
|
||||||
|
* <p>
|
||||||
|
* Setting to false will unmark the entity to jump but will not stop a jump already in-progress.
|
||||||
|
*
|
||||||
|
* @param jumping entity jump state
|
||||||
|
*/
|
||||||
|
void setJumping(boolean jumping);
|
||||||
|
// Paper end - entity jump API
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue