diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
index 5ad5632d4d47..14ba73d2b112 100644
--- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
+++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
@@ -4,6 +4,7 @@
import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -17,11 +18,14 @@ public class EntityRemoveFromWorldEvent extends EntityEvent {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final World world;
+ private final Cause cause;
@ApiStatus.Internal
- public EntityRemoveFromWorldEvent(final Entity entity, final World world) {
+ public EntityRemoveFromWorldEvent(final Entity entity, final World world, final Cause cause) {
super(entity);
+
this.world = world;
+ this.cause = cause;
}
/**
@@ -31,6 +35,14 @@ public World getWorld() {
return this.world;
}
+ /**
+ * Gets the reason the entity is being removed from the world.
+ * @return the removal reason
+ */
+ public Cause getCause() {
+ return cause;
+ }
+
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
@@ -39,4 +51,119 @@ public HandlerList getHandlers() {
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
+
+ public enum Cause {
+
+ /**
+ * When an entity dies.
+ */
+ DEATH(true, false),
+ /**
+ * When an entity does despawn. This includes mobs which are too far away,
+ * items or arrows which lay to long on the ground or area effect cloud.
+ */
+ DESPAWN(true, false),
+ /**
+ * When an entity gets removed because it drops as an item.
+ * For example, trident or falling sand.
+ *
+ * Note: Depending on other factors, such as gamerules, no item will actually drop,
+ * the cause, however, will still be drop.
+ */
+ DROP(true, false),
+ /**
+ * When an entity gets removed because it enters a block.
+ * For example, bees or silverfish.
+ */
+ ENTER_BLOCK(true, false),
+ /**
+ * When an entity gets removed because it exploded.
+ * For example, creepers, tnt or firework.
+ */
+ EXPLODE(true, false),
+ /**
+ * When an entity gets removed because it hit something. This mainly applies to projectiles.
+ */
+ HIT(true, false),
+ /**
+ * When an entity gets removed because it merges with another one.
+ * For example, items or xp.
+ */
+ MERGE(true, false),
+ /**
+ * When an entity gets removed because it is too far below the world.
+ * This only applies to entities which get removed immediately,
+ * some entities get damage instead.
+ */
+ OUT_OF_WORLD(true, false),
+ /**
+ * When an entity gets removed because it got pickup.
+ * For example, items, arrows, xp or parrots which get on a player shoulder.
+ */
+ PICKUP(true, false),
+ /**
+ * When an entity gets removed with a player because the player quits the game.
+ * For example, a boat which gets removed with the player when he quits.
+ */
+ PLAYER_QUIT(false, false),
+ /**
+ * When a plugin manually removes an entity.
+ */
+ PLUGIN(true, false),
+ /**
+ * When an entity gets removed because it transforms into another one.
+ */
+ TRANSFORMATION(true, false),
+ /**
+ * When the chunk an entity is in gets unloaded.
+ */
+ UNLOAD(false, true),
+ /**
+ * When an entity is discarded, and a more specific cause does not exist.
+ */
+ DISCARD(true, false),
+ /**
+ * When an entity changes dimensions.
+ */
+ CHANGED_DIMENSION(false, false),
+ /**
+ * When the chunk an entity is in is no longer accessible, but not yet fully unloaded.
+ */
+ INACCESSIBLE(false, false),
+ /**
+ * Used when the cause of the removal is unknown.
+ */
+ UNKNOWN(false, false);
+
+ private final boolean destroy;
+ private final boolean save;
+
+ Cause(boolean destroy, boolean save) {
+ this.destroy = destroy;
+ this.save = save;
+ }
+
+ /**
+ * Whether the entity instance being removed will be destroyed.
+ *
+ * @return whether the entity will be destroyed
+ */
+ public boolean willDestroy() {
+ return this.destroy;
+ }
+
+ /**
+ * Whether the entity instance being removed will be saved. This does not account for the value of
+ * {@link Entity#isPersistent}. Entities removed with {@link Cause#PLAYER_QUIT} are saved
+ * prior to the event firing, and thus should be modified prior to this using another event, such as
+ * with {@link PlayerQuitEvent}.
+ *
+ * @return whether the entity will be saved
+ */
+ public boolean willSave() {
+ return this.save;
+ }
+
+ }
+
}
diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch
index cbfc717b36a1..c09f64d72580 100644
--- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch
+++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch
@@ -366,7 +366,7 @@ index d95413af04121fe91ca0f3b0c70025b9808acef9..ad665c7535c615d2b03a3e7864be435f
import org.slf4j.Logger;
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
-index 3164f3784131babf9a6663335517a12df7e88a7b..da8848e2a3e3745949eb2356a049451d30f763a7 100644
+index 1555d1984787d360800ae3de9110bc8df80ba7f0..219e097e4275eabbe141ec987fdd991c71c244ba 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -551,6 +551,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -455,7 +455,7 @@ index a9f01e616ef6b0d74caf57cd68eb371a4fd30fd5..179f4e4b9b1eb57f78bbb2f9fa34b11e
public void aiStep() {
super.aiStep();
diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java
-index 24735284fda151414d99faad401d25ba60995f9a..23b342cc31c7e72ade0e1ccad86a9ccf34380f13 100644
+index 336ab1657ff4d41cdf037eb71b5db1f993ab225f..784215b4a406e1c317ef2250ad6389c15d9d0669 100644
--- a/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/net/minecraft/world/entity/AreaEffectCloud.java
@@ -128,6 +128,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
@@ -467,7 +467,7 @@ index 24735284fda151414d99faad401d25ba60995f9a..23b342cc31c7e72ade0e1ccad86a9ccf
+ public void inactiveTick() {
+ super.inactiveTick();
+ if (this.tickCount >= this.waitTime + this.duration) {
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
+ }
+ }
+ // Paper end - EAR 2
@@ -476,7 +476,7 @@ index 24735284fda151414d99faad401d25ba60995f9a..23b342cc31c7e72ade0e1ccad86a9ccf
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
-index e7889c9c7b155db46730f5e168bb7fd3d1732a8c..334859c5ff7023c730513301cc11c9837b2c7823 100644
+index d7d42aa174d3e5e175db026a3e7937cae38b1d51..4a948b21f4b544fee7b3ac00e986e2e6a15b6f5c 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -380,6 +380,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -533,7 +533,7 @@ index e7889c9c7b155db46730f5e168bb7fd3d1732a8c..334859c5ff7023c730513301cc11c983
movement = this.maybeBackOffFromEdge(movement, type);
Vec3 vec3 = this.collide(movement);
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
-index ff513e8c87bf42be756e46f4dbfec8dda2b8cb60..239c443ddc9bacc08a39a8ef2ab17016a2480549 100644
+index 04aef3a25e3bb6e5328ab924d2659027cdb4b640..9acf0ddeaa51a55ffdd26be8ef903c38c808f0f9 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3096,6 +3096,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -552,7 +552,7 @@ index ff513e8c87bf42be756e46f4dbfec8dda2b8cb60..239c443ddc9bacc08a39a8ef2ab17016
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
-index f7d69db61d1293510428ae275e8a50571dde5ddf..1ed07fd23985a6bf8cf8300f74c92b7531a79fc6 100644
+index f4058e70456e5189638095dd95868c609c509331..8993005e107ee9b7426e01a2d290a71ae7f7dd91 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -215,6 +215,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -651,7 +651,7 @@ index 789fea258d70e60d38271ebb31270562dc7eb3ab..d0ab3db7bbd2942db19f473474371b20
}
}
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
-index 8b034b6bda937b25dbb3d09b8293fed6d7dc512c..52a7ed0d991758bad0dcedcb7f97fb15ac6c6d04 100644
+index a175a2071609c15e1090202a4d26a65b60668bff..8c009c4506ad338b700585f2d3c6be1016f456c0 100644
--- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -124,6 +124,29 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -676,7 +676,7 @@ index 8b034b6bda937b25dbb3d09b8293fed6d7dc512c..52a7ed0d991758bad0dcedcb7f97fb15
+ return;
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
+ }
+ }
+ // Paper end - EAR 2
@@ -764,7 +764,7 @@ index c1e09e701757a300183b62d343ded03033e63aa7..56574f8ef879159edc0114da09300143
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
-index 7c0862c50b44555fb27ce7dc46f4ec95a3eb0022..774ca9e0b56fd175ae246051de762d0c4256ca58 100644
+index 0e44373884bebf1e8755267cd0389449d3f8ac7a..e46cb17afbd52a78c7c8ada4fd45460af34b1251 100644
--- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
+++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
@@ -102,6 +102,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
@@ -828,7 +828,7 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb
+
}
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
-index 32f184288f6065259c921293922c1b0163df4dc4..0f346faa82b988e86834c38837f6f11bea7f31c6 100644
+index 79854cefdc2a7459f409e9d94b0775dd8365a6a9..4dd1899960db8b02f40c69fd7fd902236a8295f6 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -153,6 +153,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
diff --git a/paper-server/patches/features/0017-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0017-Moonrise-optimisation-patches.patch
index 337302aaa272..25bdba0c0a28 100644
--- a/paper-server/patches/features/0017-Moonrise-optimisation-patches.patch
+++ b/paper-server/patches/features/0017-Moonrise-optimisation-patches.patch
@@ -297,7 +297,7 @@ index 0000000000000000000000000000000000000000..1b8193587814225c2ef2c5d9e667436e
+ }
+}
diff --git a/ca/spottedleaf/moonrise/paper/PaperHooks.java b/ca/spottedleaf/moonrise/paper/PaperHooks.java
-index 5577287398db2bb9d21f14409ef580b8ab9ea018..4d344559a20a0c35c181e297e81788c747363ec9 100644
+index 22d44fda8057e9f01ae6e51162626957e81618eb..60d0f1d0dd17704e85d1cee610adbf3b950400ee 100644
--- a/ca/spottedleaf/moonrise/paper/PaperHooks.java
+++ b/ca/spottedleaf/moonrise/paper/PaperHooks.java
@@ -268,7 +268,7 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo
@@ -26735,7 +26735,7 @@ index 70f6d068b3f3665b282d9750310c883839120ab2..870b9efd445ddadb3725e88351555ad9
if (!passengers.equals(this.lastPassengers)) {
this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
-index 192977dd661ee795ada13db895db770293e9b402..95a4e37a3c93f9b3c56c7a7376ed521cd46fbb6f 100644
+index ada8a27ac26773670c9cda8d84bdf096cf2b3d57..55469573bf4420a378fff33fa5410571f57bcccc 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -170,7 +170,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
@@ -26960,7 +26960,8 @@ index 192977dd661ee795ada13db895db770293e9b402..95a4e37a3c93f9b3c56c7a7376ed521c
- return player != null && player.level() == this ? player : null;
+ public final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder moonrise$getViewDistanceHolder() {
+ return this.viewDistanceHolder;
-+ }
+ }
+- // Paper end - optimise getPlayerByUUID
+
+ @Override
+ public final long moonrise$getLastMidTickFailure() {
@@ -26975,8 +26976,7 @@ index 192977dd661ee795ada13db895db770293e9b402..95a4e37a3c93f9b3c56c7a7376ed521c
+ @Override
+ public final ca.spottedleaf.moonrise.common.misc.NearbyPlayers moonrise$getNearbyPlayers() {
+ return this.nearbyPlayers;
- }
-- // Paper end - optimise getPlayerByUUID
++ }
+
+ @Override
+ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getLoadedChunks() {
@@ -27495,6 +27495,19 @@ index 192977dd661ee795ada13db895db770293e9b402..95a4e37a3c93f9b3c56c7a7376ed521c
return crashReportCategory;
}
+@@ -2373,7 +2689,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
+ // CraftBukkit end
+ // Paper start - fire if tracking ends without calling Entity#setRemoved
+ if (entity.getRemovalReason() == null) {
+- new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), ServerLevel.this.getWorld(), com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNKNOWN).callEvent();
++ com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause;
++ if (entity.moonrise$getChunkStatus() == FullChunkStatus.INACCESSIBLE) cause = com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.INACCESSIBLE;
++ else cause = com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNKNOWN;
++
++ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), ServerLevel.this.getWorld(), cause).callEvent();
+ }
+ // Paper end - fire if tracking ends without calling Entity#setRemoved
+ }
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index ff5889f8fed0707a6654d9d21862e32e2ebc866d..e61fe83479f095e8addbd3e8f1d5179c998ae1eb 100644
--- a/net/minecraft/server/level/ServerPlayer.java
@@ -27976,7 +27989,7 @@ index 4eb040006f5d41b47e5ac9df5d9f19c4315d6343..7fa41dea184b01891f45d8e404bc1cba
this.generatingStep = generatingStep;
this.cache = cache;
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
-index ff0315cffdb282fdc0a1ffd15e2954caa76835c9..5e94dd9e26aa4fd6545dbaae2ae0cb51cb6f13e0 100644
+index 5cd7e0a7ff60a1d801bdcac3818ba53100e76f64..2835e93f4ea77ec9020ab201e9e704f522599f2a 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -1312,7 +1312,7 @@ public abstract class PlayerList {
@@ -28372,7 +28385,7 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896
+ // Paper end - block counting
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
-index 45f69a914d5a0565196c4105d61541047301470f..f42bdae2f80805e5069212bd16e3ab6814aef9ee 100644
+index 21761e320600ed1655ad8c46ea9240a900446edd..e7efbc3a5bc8fb07a99fa0dedb627c730e0fc431 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -135,7 +135,7 @@ import net.minecraft.world.scores.ScoreHolder;
@@ -29085,14 +29098,14 @@ index 45f69a914d5a0565196c4105d61541047301470f..f42bdae2f80805e5069212bd16e3ab68
@@ -4603,6 +4908,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
- public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ public final void setRemoved(Entity.RemovalReason removalReason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ // Paper start - rewrite chunk system
+ if (!((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this.level).moonrise$getEntityLookup().canRemoveEntity((Entity)(Object)this)) {
+ LOGGER.warn("Entity " + this + " is currently prevented from being removed from the world since it is processing section status updates", new Throwable());
+ return;
+ }
+ // Paper end - rewrite chunk system
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, removalReason, cause);
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@@ -4614,7 +4925,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -29353,7 +29366,7 @@ index 324cc0686f0f5b1371b2bbea5b8c8fdb1f363006..39cd1e3d8192d7077d6b7864d3393309
this(setDirty, true, ImmutableList.of());
}
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
-index 33f6d6862731d22d6d3eeb7cf39a4a42049afae3..a3cc0001a949597e345d7919c3f6109fa4a949ad 100644
+index 3c1e817bf6bd9a383e4b20dcc3a94efde094c4bd..656228e30bde2f3a839b2a0171522330f38c252f 100644
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -316,7 +316,7 @@ public class ArmorStand extends LivingEntity {
@@ -29503,7 +29516,7 @@ index 300f3ed58109219d97846082941b860585f66fed..e81195df621159da67136f020fa7a6d3
// Paper start - Affects Spawning API
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
-index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..8331b49185500ab3b4307e9ae05126b4f83a318a 100644
+index 6b81142c52cbef6f31606b0f33bafd2443d3f7f3..00900f0b87e0c183d681fed540bf75772a46a774 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -79,6 +79,7 @@ import net.minecraft.world.level.storage.LevelData;
@@ -30216,7 +30229,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..8331b49185500ab3b4307e9ae05126b4
}
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
@@ -865,6 +1505,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
- entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD); // Paper - EntityRemoveFromWorldEvent
// Paper end - Prevent block entity and entity crashes
}
+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system
@@ -32481,7 +32494,7 @@ index 7a64b00ff31d1273d0b0b9a3cfd43808c88ef46a..c9d8a1c0a75c34ccd9f5cead02cccd77
this.chunkType = chunkType;
this.heightmapsAfter = heightmapsAfter;
diff --git a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
-index c953bc93de8a42bcc12b7e8f46b3ae804e54964e..2ccbdfdcf81556306e098277ecf119d5fd02138c 100644
+index 617750597ee21020aae0439b1c48aa6fbd62c760..c44a3628f63e1c3ad3c8fbba67999163eb3b2e55 100644
--- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
+++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
@@ -182,7 +182,7 @@ public class ChunkStatusTasks {
diff --git a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch
index d736409b628e..747cc0897044 100644
--- a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch
+++ b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch
@@ -229,7 +229,7 @@
+
+ @Override
+ public void unloadEntity(final Entity entity) {
-+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, org.bukkit.event.entity.EntityRemoveEvent.Cause.UNLOAD);
++ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNLOAD);
+ }
+
+ @Override
diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch
index 91fda07c6b9a..d93ca1969e73 100644
--- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch
+++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch
@@ -5,7 +5,7 @@
List entitiesOfClass = this.getLevel()
.getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player));
- entitiesOfClass.forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED));
-+ entitiesOfClass.forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper
++ entitiesOfClass.forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD)); // Paper
}
}
diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch
index 23eeabf7b914..29de86db4920 100644
--- a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch
+++ b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch
@@ -5,7 +5,7 @@
AABB aabb = AABB.of(boundingBox1);
List entitiesOfClass = level.getEntitiesOfClass(Entity.class, aabb, entity -> !(entity instanceof Player));
- entitiesOfClass.forEach(Entity::discard);
-+ entitiesOfClass.forEach(entity -> entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper
++ entitiesOfClass.forEach(entity -> entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD)); // Paper
}
public static BlockPos getTransformedFarCorner(BlockPos pos, Vec3i offset, Rotation rotation) {
diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch
index 6ca1c0d342f3..75abd08a19e0 100644
--- a/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch
+++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch
@@ -5,7 +5,7 @@
private static int resetGameTestInfo(GameTestInfo gameTestInfo) {
- gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED));
-+ gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper
++ gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD)); // Paper
gameTestInfo.getStructureBlockEntity().placeStructure(gameTestInfo.getLevel());
StructureUtils.removeBarriers(gameTestInfo.getStructureBounds(), gameTestInfo.getLevel());
say(gameTestInfo.getLevel(), "Reset succeded for: " + gameTestInfo.getTestName(), ChatFormatting.GREEN);
diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch
index acc43a771692..6203c93a692f 100644
--- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch
+++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch
@@ -1159,7 +1159,7 @@
String string = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde(
"onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")
-@@ -1785,6 +_,15 @@
+@@ -1785,6 +_,19 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
@@ -1171,7 +1171,11 @@
+ }
+ }
+ // CraftBukkit end
-+ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), ServerLevel.this.getWorld()).callEvent(); // Paper - fire while valid
++ // Paper start - fire if tracking ends without calling Entity#setRemoved
++ if (entity.getRemovalReason() == null) {
++ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), ServerLevel.this.getWorld(), com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNKNOWN).callEvent();
++ }
++ // Paper end - fire if tracking ends without calling Entity#setRemoved
}
@Override
diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch
index e9cb8b46e9fe..47f7b15fb2d5 100644
--- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch
+++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch
@@ -407,7 +407,7 @@
+ }
+ }
+ // Paper end - Fix villager boat exploit
-+ entity.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, org.bukkit.event.entity.EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause
++ entity.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLAYER_QUIT); // Paper - EntityRemoveFromWorldEvent
+ });
}
}
@@ -418,7 +418,7 @@
- thrownEnderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER);
+ // Paper start - Allow using old ender pearl behavior
+ if (!thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) {
-+ thrownEnderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, org.bukkit.event.entity.EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause
++ thrownEnderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLAYER_QUIT); // Paper - EntityRemoveFromWorldEvent
+ } else {
+ thrownEnderpearl.cachedOwner = null;
+ }
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch
index ae128ef1a745..361f287b5410 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch
@@ -14,7 +14,7 @@
private void serverTick(ServerLevel level) {
if (this.tickCount >= this.waitTime + this.duration) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
boolean isWaiting = this.isWaiting();
boolean flag = this.tickCount < this.waitTime;
@@ -23,7 +23,7 @@
radius += this.radiusPerTick;
if (radius < 0.5F) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return;
}
@@ -66,7 +66,7 @@
radius += this.radiusOnUse;
if (radius < 0.5F) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return;
}
@@ -75,7 +75,7 @@
this.duration = this.duration + this.durationOnUse;
if (this.duration <= 0) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return;
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch
index 1bd938bdbef0..64f352e623f6 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch
@@ -5,7 +5,7 @@
for (Entity entity : newMob.getPassengers()) {
entity.stopRiding();
- entity.remove(Entity.RemovalReason.DISCARDED);
-+ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
++ entity.remove(Entity.RemovalReason.DISCARDED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.TRANSFORMATION); // Paper - EntityRemoveFromWorldEvent
}
firstPassenger.startRiding(newMob);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch
index f1de578de1fa..aeaf81260563 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch
@@ -226,7 +226,7 @@
public void kill(ServerLevel level) {
- this.remove(Entity.RemovalReason.KILLED);
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
this.gameEvent(GameEvent.ENTITY_DIE);
}
@@ -236,7 +236,7 @@
+ this.discard(null);
+ }
+
-+ public final void discard(org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ public final void discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ this.remove(Entity.RemovalReason.DISCARDED, cause);
+ // CraftBukkit end
}
@@ -300,7 +300,7 @@
+ this.setRemoved(reason, null);
+ }
+
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause eventCause) { // Paper - EntityRemoveFromWorldEvent
+ this.setRemoved(reason, eventCause);
+ // CraftBukkit end
}
@@ -374,7 +374,7 @@
public void tick() {
+ // Paper start - entity despawn time limit
+ if (this.despawnTime >= 0 && this.tickCount >= this.despawnTime) {
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // Paper end - entity despawn time limit
@@ -497,7 +497,7 @@
protected void onBelowWorld() {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.OUT_OF_WORLD); // Paper - EntityRemoveFromWorldEvent
}
public boolean isFree(double x, double y, double z) {
@@ -1727,8 +1727,8 @@
+ }
+
+ @Override
-+ public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
-+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause);
++ public final void setRemoved(Entity.RemovalReason removalReason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
++ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, removalReason, cause);
+ // CraftBukkit end
+ final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
if (this.removalReason == null) {
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch
index 69d13b30791d..1d9d0341b646 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch
@@ -117,7 +117,7 @@
this.age++;
if (this.age >= 6000) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -160,7 +160,7 @@
this.count = this.count + orb.count;
this.age = Math.min(this.age, orb.age);
- orb.discard();
-+ orb.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause
++ orb.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.MERGE); // Paper - EntityRemoveFromWorldEvent
}
private void setUnderwaterMovement() {
@@ -169,7 +169,7 @@
this.health = (int)(this.health - amount);
if (this.health <= 0) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
}
return true;
@@ -210,7 +210,7 @@
this.count--;
if (this.count == 0) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch
index ffaffc46db47..9f3a77cd0feb 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch
@@ -31,7 +31,7 @@
}
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else if (this.life < -this.random.nextInt(10)) {
this.flashes--;
this.life = 1;
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch
index bca5d0ef6be0..a78288f32d88 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch
@@ -90,7 +90,7 @@
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
this.level().broadcastEntityEvent(this, (byte)60);
- this.remove(Entity.RemovalReason.KILLED);
-+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -130,7 +130,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, EntityRemoveEvent.Cause eventCause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause eventCause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
if ((reason == Entity.RemovalReason.KILLED || reason == Entity.RemovalReason.DISCARDED) && this.level() instanceof ServerLevel serverLevel) {
this.triggerOnDeathMobEffects(serverLevel, reason);
@@ -388,6 +388,7 @@
@Nullable
public MobEffectInstance removeEffectNoUpdate(Holder effect) {
+- return this.activeEffects.remove(effect);
+ // CraftBukkit start
+ return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
+ }
@@ -409,7 +410,7 @@
+ return null;
+ }
+
- return this.activeEffects.remove(effect);
++ return this.activeEffects.remove(effectInstance);
}
public boolean removeEffect(Holder effect) {
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch
index 6e9bf95ddfca..0456b1226e3d 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch
@@ -174,7 +174,7 @@
item.shrink(itemStack.getCount());
if (item.isEmpty()) {
- entity.discard();
-+ entity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
}
}
}
@@ -214,7 +214,7 @@
public void checkDespawn() {
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
- Entity nearestPlayer = this.level().getNearestPlayer(this, -1.0);
+ Entity nearestPlayer = this.level().findNearbyPlayer(this, -1.0, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper - Affects Spawning API
@@ -224,7 +224,6 @@
- int i = despawnDistance * despawnDistance;
- if (d > i && this.removeWhenFarAway(d)) {
- this.discard();
-- }
+ // Paper start - Configurable despawn distances
+ final io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DespawnRangePair despawnRangePair = this.level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory());
+ final io.papermc.paper.configuration.type.DespawnRange.Shape shape = this.level().paperConfig().entities.spawning.despawnRangeShape;
@@ -235,8 +234,8 @@
+ final double distanceSquared = dxSqr + dzSqr + dySqr;
+ // Despawn if hard/soft limit is exceeded
+ if (despawnRangePair.hard().shouldDespawn(shape, dxSqr, dySqr, dzSqr, dy) && this.removeWhenFarAway(distanceSquared)) {
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
-+ }
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
+ }
- int noDespawnDistance = this.getType().getCategory().getNoDespawnDistance();
- int i1 = noDespawnDistance * noDespawnDistance;
@@ -245,7 +244,7 @@
- } else if (d < i1) {
+ if (despawnRangePair.soft().shouldDespawn(shape, dxSqr, dySqr, dzSqr, dy)) {
+ if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && this.removeWhenFarAway(distanceSquared)) {
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
+ }
+ } else {
+ // Paper end - Configurable despawn distances
@@ -372,7 +371,7 @@
if (conversionParams.type().shouldDiscardAfterConversion()) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.TRANSFORMATION); // Paper - EntityRemoveFromWorldEvent
}
return mob;
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/Digging.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/Digging.java.patch
index c571e45b5ed3..26314981f546 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/Digging.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/Digging.java.patch
@@ -5,7 +5,7 @@
protected void stop(ServerLevel level, E entity, long gameTime) {
if (entity.getRemovalReason() == null) {
- entity.remove(Entity.RemovalReason.DISCARDED);
-+ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - Add bukkit remove cause
++ entity.remove(Entity.RemovalReason.DISCARDED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch
index 7d0041cf64a0..a0524e4de692 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch
@@ -26,7 +26,7 @@
}
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
return Optional.of(InteractionResult.SUCCESS);
} else {
return Optional.empty();
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch
index f0e77a24bef6..c7913c6deb95 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch
@@ -36,7 +36,7 @@
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
this.take(entity, item.getCount());
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch
index aa6fdd965444..cbe08d5166ca 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch
@@ -51,7 +51,7 @@
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
this.take(entity, item.getCount());
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
this.ticksSinceEaten = 0;
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch
index 3e9a850886ba..9b79e4b161fe 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch
@@ -35,7 +35,7 @@
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
this.take(entity, item.getCount());
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch
index 31833a858436..084102ea40cb 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch
@@ -11,7 +11,7 @@
+ return;
+ }
+ level.addFreshEntity(zombifiedPiglin, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.TRANSFORMATION); // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
if (zombifiedPiglin == null) {
super.thunderHit(level, lightning);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch
index 367ba239ffc6..3924bf64417b 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch
@@ -5,7 +5,7 @@
this.saveWithoutId(compoundTag);
if (player.setEntityOnShoulder(compoundTag)) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
return true;
} else {
return false;
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch
index f503b6b31023..304dd1378eca 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch
@@ -5,7 +5,7 @@
frog.doHurtTarget(level, entity);
if (!entity.isAlive()) {
- entity.remove(Entity.RemovalReason.KILLED);
-+ entity.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ entity.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch
index cdbce96d9995..034461455c2c 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch
@@ -5,7 +5,7 @@
super.aiStep();
if (this.isTrap() && this.trapTime++ >= 18000) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch
index 83a979d52e0b..c9940e9c1815 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch
@@ -5,7 +5,7 @@
if (this.despawnDelay <= 0) {
this.removeLeash();
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch
index f318988a0562..23bab8f5bd21 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch
@@ -69,10 +69,10 @@
+ return false;
+ }
+
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // Paper - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
+ level.explode(this, damageSource1, null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.BLOCK);
+ } else {
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // Paper - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch
index bb629ff9a652..dcc44cace24c 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch
@@ -163,7 +163,7 @@
+ this.silentDeath = false; // Reset to default if event was cancelled
+ return;
+ }
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
+ // Paper end - Fire entity death event
this.gameEvent(GameEvent.ENTITY_DIE);
if (this.dragonFight != null) {
@@ -228,7 +228,7 @@
}
- this.remove(Entity.RemovalReason.KILLED);
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
this.gameEvent(GameEvent.ENTITY_DIE);
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch
index 61de7efb5987..e8e6f3e8601a 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch
@@ -19,7 +19,7 @@
public void end() {
if (this.flame != null) {
- this.flame.discard();
-+ this.flame.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.flame.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
this.flame = null;
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch
index 936e924c091a..01ca947198cf 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch
@@ -97,7 +97,7 @@
public void checkDespawn() {
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
this.noActionTime = 0;
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch
index 36711a9189d3..3068988235e5 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch
@@ -318,7 +318,7 @@
+ if (event.isCancelled()) return;
+ }
+ // Paper end
-+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.remove(Entity.RemovalReason.KILLED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
this.gameEvent(GameEvent.ENTITY_DIE);
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch
index 55a016fcd97a..d8970bb8c71f 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch
@@ -34,7 +34,7 @@
+ return;
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
this.dropItem(serverLevel, null);
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch
index 56d3dea16c83..9c5adc12e44b 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch
@@ -53,7 +53,7 @@
}
+ // CraftBukkit start
+ if (die) {
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
+ }
+ // CraftBukkit end
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch
index 96b38cb9debb..94dee206f679 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch
@@ -33,7 +33,7 @@
public void tick() {
if (this.blockState.isAir()) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
Block block = this.blockState.getBlock();
this.time++;
@@ -45,7 +45,7 @@
+ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
+ this.spawnAtLocation(serverLevel, block);
+ }
-+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.OUT_OF_WORLD); // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // Paper end - Configurable falling blocks height nerf
@@ -63,7 +63,7 @@
}
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
}
} else {
BlockState blockState = this.level().getBlockState(blockPos);
@@ -73,7 +73,7 @@
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockPos, this.blockState)) {
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // CraftBukkit end
@@ -83,7 +83,7 @@
.chunkMap
.broadcast(this, new ClientboundBlockUpdatePacket(blockPos, this.level().getBlockState(blockPos)));
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
if (block instanceof Fallable) {
((Fallable)block).onLand(this.level(), blockPos, this.blockState, blockState, this);
}
@@ -92,13 +92,13 @@
}
} else if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
this.callOnBrokenAfterFall(block, blockPos);
this.spawnAtLocation(serverLevel, block);
}
} else {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.callOnBrokenAfterFall(block, blockPos);
this.spawnAtLocation(serverLevel, block);
@@ -106,7 +106,7 @@
}
} else {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
this.callOnBrokenAfterFall(block, blockPos);
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch
index 22c2ed163b3a..846faca63456 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch
@@ -29,7 +29,7 @@
public void tick() {
if (this.getItem().isEmpty()) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
super.tick();
if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
@@ -64,7 +64,7 @@
+ return;
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
}
@@ -119,7 +119,7 @@
destinationEntity.age = Math.min(destinationEntity.age, originEntity.age);
if (originStack.isEmpty()) {
- originEntity.discard();
-+ originEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause
++ originEntity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.MERGE); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -138,7 +138,7 @@
if (this.health <= 0) {
this.getItem().onDestroyed(this);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
}
return true;
@@ -246,7 +246,7 @@
entity.take(this, count);
if (item.isEmpty()) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
item.setCount(count);
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch
index 45ed0bc03d71..150af8ecba4b 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch
@@ -41,7 +41,7 @@
this.applyEffectsFromBlocks();
+ // Paper start - Configurable TNT height nerf
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
-+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.OUT_OF_WORLD); // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // Paper end - Configurable TNT height nerf
@@ -58,7 +58,7 @@
if (!this.level().isClientSide) {
this.explode();
}
-+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
} else {
this.updateInWaterStateAndDoFluidPushing();
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch
index 6a3c83769696..1b0046340a83 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch
@@ -62,7 +62,7 @@
this.spawnLingeringCloud();
this.triggerOnDeathMobEffects(serverLevel, Entity.RemovalReason.KILLED);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit start
+ } else {
+ this.swell = 0;
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch
index 4677099a10f4..338c2b53615b 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch
@@ -5,7 +5,7 @@
if (this.life >= 2400) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch
index baac9f090b12..1ee7f739bb8c 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch
@@ -5,7 +5,7 @@
ItemStack itemStack = this.inventory.addItem(item);
if (itemStack.isEmpty()) {
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
} else {
item.setCount(itemStack.getCount());
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch
index a8c9b55110f4..b1ec2fbdf908 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch
@@ -21,7 +21,7 @@
levelAccessor.setBlock(blockPos, InfestedBlock.infestedStateByHost(blockState), 3);
this.mob.spawnAnim();
- this.mob.discard();
-+ this.mob.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause
++ this.mob.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.ENTER_BLOCK); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch
index 07a1abbeea16..38b43c410b55 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch
@@ -37,7 +37,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause eventCause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
int size = this.getSize();
if (!this.level().isClientSide && size > 1 && this.isDeadOrDying()) {
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch
index 467622eb818c..a18790e5cc3e 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch
@@ -29,7 +29,7 @@
item = itemEntity.getItem();
- itemEntity.discard();
- } else {
-+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ itemEntity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
+ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, itemEntity, itemEntity.getItem().getCount() - 1, false).isCancelled()) {
+ piglin.onItemPickup(itemEntity); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification
piglin.take(itemEntity, 1);
@@ -67,7 +67,7 @@
ItemStack itemStack = item.split(1);
if (item.isEmpty()) {
- itemEntity.discard();
-+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ itemEntity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
} else {
itemEntity.setItem(item);
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch
index 7728954a042f..9b42f16982e6 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch
@@ -28,7 +28,7 @@
mob.take(itemEntity, count - itemStack.getCount());
if (itemStack.isEmpty()) {
- itemEntity.discard();
-+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ itemEntity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
} else {
item.setCount(itemStack.getCount());
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch
index 6c74e0007bc9..bb0e5ebe09e6 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch
@@ -75,7 +75,7 @@
private void maybeDespawn() {
if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) {
- this.discard();
-+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch
index 4d20a5178a80..77600b6ba88c 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch
@@ -462,7 +462,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause eventCause) { // Paper - EntityRemoveFromWorldEvent
+ super.remove(reason, eventCause);
+ // CraftBukkit end
this.inventoryMenu.removed(this);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch
index cf61cc49d2f8..7439731b49d2 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch
@@ -113,7 +113,7 @@
- if (this.life >= 1200) {
- this.discard();
+ if (this.life >= (this.pickup == Pickup.CREATIVE_ONLY ? this.level().paperConfig().entities.spawning.creativeArrowDespawnRate.value() : (this.pickup == Pickup.DISALLOWED ? this.level().paperConfig().entities.spawning.nonPlayerArrowDespawnRate.value() : ((this instanceof ThrownTrident) ? this.level().spigotConfig.tridentDespawnRate : this.level().spigotConfig.arrowDespawnRate)))) { // Spigot // Paper - Configurable non-player arrow despawn rate; TODO: Extract this to init?
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -134,7 +134,7 @@
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
return;
}
@@ -162,7 +162,7 @@
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
if (this.getPierceLevel() <= 0) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
} else {
entity.setRemainingFireTicks(remainingFireTicks);
@@ -171,7 +171,7 @@
}
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
@@ -231,7 +231,7 @@
+ // CraftBukkit end
entity.take(this, 1);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch
index 0f392f4b0acc..9c0611d8ce22 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch
@@ -20,7 +20,7 @@
this.createParticleTrail();
} else {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch
index b04695ec1ebc..fad4828cde80 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch
@@ -10,7 +10,7 @@
- this.discard();
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason
+ } else areaEffectCloud.discard(null); // Paper - EnderDragon Events
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch
index e980aa3858fa..2cb0d05292c0 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch
@@ -5,7 +5,7 @@
if (--this.lifeTicks < 0) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch
index 450c900de362..b8f4f8519fca 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch
@@ -28,7 +28,7 @@
if (this.life > 80 && !this.level().isClientSide) {
this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F);
- this.discard();
-+ this.discard(this.surviveAfterDeath ? org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP : org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(this.surviveAfterDeath ? com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP : com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
if (this.surviveAfterDeath) {
this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem()));
} else {
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch
index f0049b5ab417..12614f93ebe8 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch
@@ -35,7 +35,7 @@
this.gameEvent(GameEvent.EXPLODE, this.getOwner());
this.dealExplosionDamage(level);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
}
@Override
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch
index b433002c9011..19fb61e22646 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch
@@ -32,13 +32,13 @@
Player playerOwner = this.getPlayerOwner();
if (playerOwner == null) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else if (this.level().isClientSide || !this.shouldStopFishing(playerOwner)) {
if (this.onGround()) {
this.life++;
if (this.life >= 1200) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return;
}
} else {
@@ -47,7 +47,7 @@
return false;
} else {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return true;
}
}
@@ -235,7 +235,7 @@
+ // CraftBukkit end
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return i;
} else {
return 0;
@@ -248,7 +248,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
this.updateOwnerInfo(null);
- super.remove(reason);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch
index d484e6d4eb1a..3faffc409686 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch
@@ -29,7 +29,7 @@
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB);
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch
index 1e27f667a53f..55aa4d53b461 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch
@@ -13,10 +13,10 @@
float f = 0.99F;
if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else if (this.isInWaterOrBubble()) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
this.setDeltaMovement(deltaMovement.scale(0.99F));
this.applyGravity();
@@ -25,7 +25,7 @@
super.onHitBlock(result);
if (!this.level().isClientSide) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch
index 8f79e335e3ee..3b56ddc0f6ef 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch
@@ -28,7 +28,7 @@
public void checkDespawn() {
if (this.level().getDifficulty() == Difficulty.PEACEFUL) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -59,7 +59,7 @@
+ this.destroy(null);
+ }
+
-+ private void destroy(org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ private void destroy(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ this.discard(cause);
+ // CraftBukkit end
this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of(this));
@@ -69,7 +69,7 @@
protected void onHit(HitResult result) {
super.onHit(result);
- this.destroy();
-+ this.destroy(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.destroy(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
@Override
@@ -85,7 +85,7 @@
this.playSound(SoundEvents.SHULKER_BULLET_HURT, 1.0F, 1.0F);
level.sendParticles(ParticleTypes.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2, 0.2, 0.2, 0.0);
- this.destroy();
-+ this.destroy(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.destroy(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
return true;
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch
index ceefdcdb8130..62ef220fd456 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch
@@ -45,7 +45,7 @@
super.onHit(result);
if (!this.level().isClientSide) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch
index 5c87f7788ca4..b4fc805a1f4d 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch
@@ -5,7 +5,7 @@
if (!this.level().isClientSide) {
this.level().broadcastEntityEvent(this, (byte)3);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch
index a19b02d29751..5731ebced475 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch
@@ -64,7 +64,7 @@
this.level().broadcastEntityEvent(this, (byte)3);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
index 8fdaf1cd3caf..4f99977f6aba 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
@@ -7,7 +7,7 @@
+ // CraftBukkit start
+ ServerPlayer serverPlayer1 = serverPlayer.teleport(new TeleportTransition(serverLevel, vec3, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+ if (serverPlayer1 == null) {
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT);
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // CraftBukkit end
@@ -49,10 +49,10 @@
}
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
} else {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
@@ -61,7 +61,7 @@
&& !owner.isAlive()
&& serverPlayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
} else {
super.tick();
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch
index e560b1ef1e17..69235522efbb 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch
@@ -17,7 +17,7 @@
+ }
+ // CraftBukkit end
+ ExperienceOrb.award((ServerLevel)this.level(), this.position(), i, org.bukkit.entity.ExperienceOrb.SpawnReason.EXP_BOTTLE, this.getOwner(), this); // Paper
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
index 0fbeafb10009..373917313d2a 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
@@ -43,7 +43,7 @@
serverLevel.levelEvent(i, this.blockPosition(), potionContents.getColor());
- this.discard();
+ } // Paper - Fix potions splash events
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch
index dad0da0b921d..3d4c84d049f8 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch
@@ -25,11 +25,11 @@
}
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DROP); // Paper - EntityRemoveFromWorldEvent
} else {
if (!(owner instanceof Player) && this.position().distanceTo(owner.getEyePosition()) < owner.getBbWidth() + 1.0) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
return;
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch
index d323b77c2ba3..00e28b1000e6 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch
@@ -37,7 +37,7 @@
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB);
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch
index a764fae4a2fe..d20869998ebf 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch
@@ -14,7 +14,7 @@
Vec3 vec31 = result.getLocation().add(vec3);
this.explode(vec31);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -23,7 +23,7 @@
super.onHit(result);
if (!this.level().isClientSide) {
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // Paper - EntityRemoveFromWorldEvent
}
}
@@ -32,7 +32,7 @@
if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxY() + 30) {
this.explode(this.position());
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.OUT_OF_WORLD); // Paper - EntityRemoveFromWorldEvent
} else {
super.tick();
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch
index 59f462b6cc71..7c3f5a5106c3 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch
@@ -22,7 +22,7 @@
this.setItemSlot(equipmentSlot, item);
this.take(entity, item.getCount());
- entity.discard();
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
this.getCurrentRaid().setLeader(this.getWave(), this);
this.setPatrolLeader(true);
} else {
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch
index 3d61d83b48bb..765c94c472db 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch
@@ -93,7 +93,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause eventCause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) {
this.dropLeash();
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch
index 9fd4787f99ad..820388f03d31 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch
@@ -9,7 +9,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end
if (!this.level().isClientSide && reason.shouldDestroy()) {
Containers.dropContents(this.level(), this, this);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch
index 5289f0b57cea..7478a3d6202e 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch
@@ -22,7 +22,7 @@
+ }
+
+ @Override
-+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ public void remove(Entity.RemovalReason reason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ // CraftBukkit end - add Bukkit remove cause
if (!this.level().isClientSide && reason.shouldDestroy()) {
Containers.dropContents(this.level(), this, this);
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
index 0f23c30d40be..2f92604997a4 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
@@ -14,7 +14,7 @@
if (this.fuse > 0) {
+ // Paper start - Configurable TNT height nerf
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD);
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.OUT_OF_WORLD); // Paper - EntityRemoveFromWorldEvent
+ return;
+ }
+ // Paper end - Configurable TNT height nerf
@@ -50,7 +50,7 @@
Level.ExplosionInteraction.TNT
);
- this.discard();
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
index 0020b09f5192..8e84486ae273 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
@@ -27,7 +27,7 @@
+ return true;
+ }
+ // CraftBukkit end
-+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
++ this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // Paper - EntityRemoveFromWorldEvent
}
} else {
+ // CraftBukkit start
diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch
index 9958bd72b63a..18e36ef8a74f 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch
@@ -575,7 +575,7 @@
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
+ MinecraftServer.LOGGER.error(msg, var6);
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD); // Paper - EntityRemoveFromWorldEvent
+ // Paper end - Prevent block entity and entity crashes
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch
index 7950dedc629f..509d9dc92126 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch
@@ -77,7 +77,7 @@
}
- bee.discard();
-+ bee.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause
++ bee.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.ENTER_BLOCK); // Paper - EntityRemoveFromWorldEvent
super.setChanged();
}
}
diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch
index f654073e2d20..19207df3bece 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch
@@ -200,7 +200,7 @@
flag = true;
item.setItem(ItemStack.EMPTY);
- item.discard();
-+ item.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
++ item.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // Paper - EntityRemoveFromWorldEvent
} else {
item.setItem(itemStack1);
}
diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch
index 351f01f843b7..9b6ebe258722 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch
@@ -17,7 +17,7 @@
}
- entity.remove(Entity.RemovalReason.DISCARDED);
-+ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - Add bukkit remove cause;
++ entity.remove(Entity.RemovalReason.DISCARDED, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // Paper - EntityRemoveFromWorldEvent
}
});
if (!spawner.getOminousConfig().spawnPotentialsDefinition().isEmpty()) {
diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch
index 30e279c283ad..46c20c24b667 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch
@@ -63,7 +63,7 @@
+ break;
+ }
+ case DELETE: {
-+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
++ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD); // Paper - EntityRemoveFromWorldEvent
+ return true;
+ }
+ default:
diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch
index 495ef0300d1c..621ff3c2448e 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch
@@ -5,7 +5,7 @@
endCrystal.setBeamTarget(null);
level.explode(endCrystal, endCrystal.getX(), endCrystal.getY(), endCrystal.getZ(), 6.0F, Level.ExplosionInteraction.NONE);
- endCrystal.discard();
-+ endCrystal.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
++ endCrystal.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // Paper - EntityRemoveFromWorldEvent
}
} else if (ticks >= 80) {
level.levelEvent(3001, new BlockPos(0, 128, 0), 0);
diff --git a/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch
index 6c5e3be1ccb2..3b526b724953 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch
@@ -5,7 +5,7 @@
void setRemoved(Entity.RemovalReason removalReason);
+ // CraftBukkit start - add Bukkit remove cause
-+ default void setRemoved(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
++ default void setRemoved(Entity.RemovalReason entity_removalreason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ this.setRemoved(entity_removalreason);
+ }
+ // CraftBukkit end
diff --git a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch
index 384e9f3c58dc..c718a6aaa2ea 100644
--- a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch
@@ -134,7 +134,7 @@
private void unloadEntity(EntityAccess entity) {
- entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK);
-+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, org.bukkit.event.entity.EntityRemoveEvent.Cause.UNLOAD); // CraftBukkit - add Bukkit remove cause
++ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNLOAD); // Paper - EntityRemoveFromWorldEvent
entity.setLevelCallback(EntityInLevelCallback.NULL);
}
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java
index 59df9031e8b4..17518016633a 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java
@@ -12,7 +12,7 @@ public CraftAbstractWindCharge(CraftServer server, net.minecraft.world.entity.pr
@Override
public void explode() {
this.getHandle().explode(this.getHandle().position());
- this.getHandle().discard(EntityRemoveEvent.Cause.EXPLODE); // SPIGOT-7577 - explode doesn't discard the entity, this happens only in tick and onHitBlock
+ this.getHandle().discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // SPIGOT-7577 - explode doesn't discard the entity, this happens only in tick and onHitBlock
}
@Override
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 91b78711ec06..68013e7fd88e 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -46,7 +46,6 @@
import org.bukkit.entity.Pose;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityRemoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.PermissibleBase;
@@ -379,7 +378,7 @@ public void lockFreezeTicks(boolean locked) {
@Override
public void remove() {
this.entity.pluginRemoved = true;
- this.entity.discard(this.getHandle().generation ? null : EntityRemoveEvent.Cause.PLUGIN);
+ this.entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLUGIN);
}
@Override
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index 7a3d982b133f..5319e2fd3a28 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -120,7 +120,7 @@ public int getHealth() {
public void setHealth(int health) {
if (health <= 0) {
this.getHandle().getItem().onDestroyed(this.getHandle());
- this.getHandle().discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PLUGIN);
+ this.getHandle().discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLUGIN);
} else {
this.getHandle().health = health;
}
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 18100c2c7ca8..5bc2da6c07b6 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1899,7 +1899,7 @@ public int applyMending(int amount) {
final int consumedExperience = i * amount / possibleDurabilityFromXp; // Paper - taken from ExperienceOrb#repairPlayerItems
org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.get().inSlot(), i, consumedExperience);
i = event.getRepairAmount();
- orb.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
+ orb.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN);
if (!event.isCancelled()) {
amount -= consumedExperience; // Use previously computed variable to reduce diff on change.
itemstack.setDamageValue(itemstack.getDamageValue() - i);
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index e37aaf77f94b..f6dce0665951 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -2173,21 +2173,33 @@ public static io.papermc.paper.event.entity.EntityKnockbackEvent callEntityKnock
}
// Paper end - replace knockback events
- public static void callEntityRemoveEvent(Entity entity, EntityRemoveEvent.Cause cause) {
- if (entity instanceof ServerPlayer) {
- return; // Don't call for player
- }
+ public static void callEntityRemoveEvent(Entity entity, Entity.RemovalReason removalReason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) {
+ if (entity.generation) return;
if (cause == null) {
- // Don't call if cause is null
- // This can happen when an entity changes dimension,
- // the entity gets removed during world gen or
- // the entity is removed before it is even spawned (when the spawn event is cancelled for example)
- return;
+ cause = switch (removalReason) {
+ case KILLED -> com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH;
+ case DISCARDED -> com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD;
+ case UNLOADED_TO_CHUNK -> com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.UNLOAD;
+ case UNLOADED_WITH_PLAYER -> com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLAYER_QUIT;
+ case CHANGED_DIMENSION -> com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.CHANGED_DIMENSION;
+ };
+ }
+
+ EntityRemoveEvent.Cause legacyCause;
+ try {
+ legacyCause = EntityRemoveEvent.Cause.valueOf(cause.name());
+ } catch (IllegalArgumentException e) {
+ legacyCause = null;
}
- Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
+ if (!(entity instanceof ServerPlayer) && legacyCause != null) {
+ Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), legacyCause));
+ }
+
+ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), entity.level().getWorld(), cause).callEvent();
}
+
// Paper start - PlayerUseUnknownEntityEvent
public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) {
new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
diff --git a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java
index 0d198f25920f..08b1bd0af3e5 100644
--- a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java
+++ b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java
@@ -29,7 +29,7 @@ public void testForMissing(ClassNode classNode) throws ClassNotFoundException {
for (MethodNode methodNode : classNode.methods) {
if (methodNode.name.equals("remove") && methodNode.desc.contains("Lnet/minecraft/world/entity/Entity$RemovalReason;")) {
- if (methodNode.desc.contains("Lorg/bukkit/event/entity/EntityRemoveEvent$Cause;")) {
+ if (methodNode.desc.contains("Lcom/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent$Cause;")) {
bukkitCause = true;
} else {
minecraftCause = true;
@@ -98,7 +98,7 @@ private boolean check(String owner, String name, String desc) throws ClassNotFou
}
}
- if (desc.contains("Lorg/bukkit/event/entity/EntityRemoveEvent$Cause;")) {
+ if (desc.contains("Lcom/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent$Cause;")) {
return false;
}