mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-25 14:00:15 +01:00
Add removal reason to EntityRemoveFromWorldEvent
This commit is contained in:
parent
d0d0efee02
commit
174e25ef2a
84 changed files with 328 additions and 173 deletions
|
@ -4,6 +4,7 @@ import org.bukkit.World;
|
|||
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 class EntityRemoveFromWorldEvent extends EntityEvent {
|
|||
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 class EntityRemoveFromWorldEvent extends EntityEvent {
|
|||
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.
|
||||
* <p>
|
||||
* <b>Note:</b> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder> 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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
List<Entity> 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
AABB aabb = AABB.of(boundingBox1);
|
||||
List<Entity> 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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
+ }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<MobEffect> 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<MobEffect> effect) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ public abstract class CraftAbstractWindCharge extends CraftFireball implements A
|
|||
@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
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.bukkit.entity.Player;
|
|||
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 abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
@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
|
||||
|
|
|
@ -120,7 +120,7 @@ public class CraftItem extends CraftEntity implements Item {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1899,7 +1899,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
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);
|
||||
|
|
|
@ -2173,21 +2173,33 @@ public class CraftEventFactory {
|
|||
}
|
||||
// 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;
|
||||
};
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
|
||||
EntityRemoveEvent.Cause legacyCause;
|
||||
try {
|
||||
legacyCause = EntityRemoveEvent.Cause.valueOf(cause.name());
|
||||
} catch (IllegalArgumentException e) {
|
||||
legacyCause = null;
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
|
@ -29,7 +29,7 @@ public class EntityRemoveEventTest {
|
|||
|
||||
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 @@ public class EntityRemoveEventTest {
|
|||
}
|
||||
}
|
||||
|
||||
if (desc.contains("Lorg/bukkit/event/entity/EntityRemoveEvent$Cause;")) {
|
||||
if (desc.contains("Lcom/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent$Cause;")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue