Paper/Spigot-API-Patches/0111-Add-EntityKnockbackByEntityEvent.patch
Spottedleaf 5c7081fecc Update upstream & fix some chunk related issues (#2177)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories

CraftBukkit Changes:
4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories
e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.
d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs

* Bring Chunk load checks in-line with spigot

As of the last upstream merge spigot now checks ticket level status
when returning loaded chunks for a world from api. Now our checks
will respect that decision.

* Fix spawn ticket levels

Vanilla would keep the inner chunks of spawn available for ticking,
however my changes made all chunks non-ticking. Resolve by changing
ticket levels for spawn chunks inside the border to respect this
behavior.


* Make World#getChunkIfLoadedImmediately return only entity ticking chunks

Mojang appears to be using chunks with level > 33 (non-ticking chunks)
as cached chunks and not actually loaded chunks.

* Bring all loaded checks in line with spigot

Loaded chunks must be at least border  chunks, or level <= 33
2019-06-14 03:27:40 +01:00

98 lines
2.7 KiB
Diff

From 618f5b6f9d4b58eccd1561a5f0da774e0ec15964 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 000000000..9efecabab
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
@@ -0,0 +1,82 @@
+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;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * 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();
+
+ @NotNull private final Entity hitBy;
+ private final float knockbackStrength;
+ @NotNull private final Vector acceleration;
+ private boolean cancelled = false;
+
+ public EntityKnockbackByEntityEvent(@NotNull LivingEntity entity, @NotNull Entity hitBy, float knockbackStrength, @NotNull Vector acceleration) {
+ super(entity);
+ this.hitBy = hitBy;
+ this.knockbackStrength = knockbackStrength;
+ this.acceleration = acceleration;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ /**
+ * @return the entity which was knocked back
+ */
+ @NotNull
+ @Override
+ public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity();
+ }
+
+ /**
+ * @return the original knockback strength.
+ */
+ public float getKnockbackStrength() {
+ return knockbackStrength;
+ }
+
+ /**
+ * @return the Entity which hit
+ */
+ @NotNull
+ public Entity getHitBy() {
+ return hitBy;
+ }
+
+ /**
+ * @return the acceleration that will be applied
+ */
+ @NotNull
+ public Vector getAcceleration() {
+ return acceleration;
+ }
+}
--
2.21.0