mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
fbe69b61a9
This event is called when an entity receives knockback by another entity. The knockback can be modified in the event. If the event is cancelled the entity is not knocked back.
80 lines
No EOL
2.3 KiB
Diff
80 lines
No EOL
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Brokkonaut <hannos17@gmx.de>
|
|
Date: Mon, 18 Jun 2018 15:40:39 +0200
|
|
Subject: [PATCH] Add EntityKnockbackByEntityEvent
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
|
|
new file mode 100644
|
|
index 00000000..99f7ef70
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
|
|
@@ -0,0 +0,0 @@
|
|
+package com.destroystokyo.paper.event.entity;
|
|
+
|
|
+import org.bukkit.entity.Entity;
|
|
+import org.bukkit.entity.LivingEntity;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.bukkit.util.Vector;
|
|
+
|
|
+/**
|
|
+ * Fired when an Entity is knocked back by the hit of another Entity. The acceleration
|
|
+ * vector can be modified. If this event is cancelled, the entity is not knocked back.
|
|
+ *
|
|
+ */
|
|
+public class EntityKnockbackByEntityEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ private final Entity hitBy;
|
|
+ private final float knockbackStrength;
|
|
+ private final Vector acceleration;
|
|
+ private boolean cancelled = false;
|
|
+
|
|
+ public EntityKnockbackByEntityEvent(LivingEntity entity, Entity hitBy, float knockbackStrength, Vector acceleration) {
|
|
+ super(entity);
|
|
+ this.hitBy = hitBy;
|
|
+ this.knockbackStrength = knockbackStrength;
|
|
+ this.acceleration = acceleration;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public LivingEntity getEntity() {
|
|
+ return (LivingEntity) super.getEntity();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the original knockback strength.
|
|
+ */
|
|
+ public float getKnockbackStrength() {
|
|
+ return knockbackStrength;
|
|
+ }
|
|
+
|
|
+ public Entity getHitBy() {
|
|
+ return hitBy;
|
|
+ }
|
|
+
|
|
+ public Vector getAcceleration() {
|
|
+ return acceleration;
|
|
+ }
|
|
+}
|
|
--
|