2020-04-02 23:07:06 +02:00
|
|
|
From 4591321a0b6f1215bbcd8ee48963b40a0ac2a9ca Mon Sep 17 00:00:00 2001
|
2018-06-21 03:59:11 +02:00
|
|
|
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
|
2020-04-02 23:07:06 +02:00
|
|
|
index 000000000..9efecabab
|
2018-06-21 03:59:11 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,82 @@
|
2018-06-21 03:59:11 +02:00
|
|
|
+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;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-06-21 03:59:11 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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();
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final Entity hitBy;
|
2018-06-21 03:59:11 +02:00
|
|
|
+ private final float knockbackStrength;
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final Vector acceleration;
|
2018-06-21 03:59:11 +02:00
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public EntityKnockbackByEntityEvent(@NotNull LivingEntity entity, @NotNull Entity hitBy, float knockbackStrength, @NotNull Vector acceleration) {
|
2018-06-21 03:59:11 +02:00
|
|
|
+ super(entity);
|
|
|
|
+ this.hitBy = hitBy;
|
|
|
|
+ this.knockbackStrength = knockbackStrength;
|
|
|
|
+ this.acceleration = acceleration;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-21 03:59:11 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-21 03:59:11 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-16 13:20:58 +02:00
|
|
|
+ /**
|
|
|
|
+ * @return the entity which was knocked back
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-21 03:59:11 +02:00
|
|
|
+ @Override
|
|
|
|
+ public LivingEntity getEntity() {
|
|
|
|
+ return (LivingEntity) super.getEntity();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2018-08-16 13:20:58 +02:00
|
|
|
+ * @return the original knockback strength.
|
2018-06-21 03:59:11 +02:00
|
|
|
+ */
|
|
|
|
+ public float getKnockbackStrength() {
|
|
|
|
+ return knockbackStrength;
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-16 13:20:58 +02:00
|
|
|
+ /**
|
|
|
|
+ * @return the Entity which hit
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-21 03:59:11 +02:00
|
|
|
+ public Entity getHitBy() {
|
|
|
|
+ return hitBy;
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-16 13:20:58 +02:00
|
|
|
+ /**
|
|
|
|
+ * @return the acceleration that will be applied
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-21 03:59:11 +02:00
|
|
|
+ public Vector getAcceleration() {
|
|
|
|
+ return acceleration;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2020-04-02 23:07:06 +02:00
|
|
|
2.25.1
|
2018-06-21 03:59:11 +02:00
|
|
|
|