Add removal reason to EntityRemoveFromWorldEvent

This commit is contained in:
TonytheMacaroni 2024-01-06 12:13:30 -05:00
parent 57c75a4b67
commit 6cf0de6ad7
50 changed files with 1724 additions and 121 deletions

View file

@ -59,13 +59,14 @@ new file mode 100644
index 0000000000000000000000000000000000000000..5ad5632d4d47d8b42e4f2af19c0fe6cf94ac5643
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
@@ -0,0 +1,42 @@
@@ -0,0 +1,169 @@
+package com.destroystokyo.paper.event.entity;
+
+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;
+
@ -79,11 +80,14 @@ index 0000000000000000000000000000000000000000..5ad5632d4d47d8b42e4f2af19c0fe6cf
+ 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;
+ }
+
+ /**
@ -93,6 +97,14 @@ index 0000000000000000000000000000000000000000..5ad5632d4d47d8b42e4f2af19c0fe6cf
+ 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;
@ -101,6 +113,121 @@ index 0000000000000000000000000000000000000000..5ad5632d4d47d8b42e4f2af19c0fe6cf
+ 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;
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java b/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java
index e32df91d911bae42c8137c6f952a6ac6a94d27e0..8ed5d1ccc44951089999db360219b556db89b4ba 100644

View file

@ -15006,12 +15006,13 @@ index 73e83d56a340f0c7dcb8ff737d621003e72c6de4..bdaf062f9b66ceab303a0807eca30134
}
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
new file mode 100644
index 0000000000000000000000000000000000000000..c78cbec447032de9fe69748591bef6be300160ed
index 0000000000000000000000000000000000000000..0d00940d9eb724afc9f2d44d697fbd40832bfabd
--- /dev/null
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
@@ -0,0 +1,607 @@
+package io.papermc.paper.world;
+
+import com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent;
+import com.destroystokyo.paper.util.maplist.EntityList;
+import io.papermc.paper.chunk.system.entity.EntityLookup;
+import io.papermc.paper.util.TickThread;
@ -15036,7 +15037,6 @@ index 0000000000000000000000000000000000000000..c78cbec447032de9fe69748591bef6be
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Predicate;
+import org.bukkit.event.entity.EntityRemoveEvent;
+
+public final class ChunkEntitySlices {
+
@ -15132,12 +15132,12 @@ index 0000000000000000000000000000000000000000..c78cbec447032de9fe69748591bef6be
+ continue;
+ }
+ if (entity.shouldBeSaved()) {
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveFromWorldEvent.Cause.UNLOAD);
+ if (entity.isVehicle()) {
+ // we cannot assume that these entities are contained within this chunk, because entities can
+ // desync - so we need to remove them all
+ for (final Entity passenger : entity.getIndirectPassengers()) {
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveFromWorldEvent.Cause.UNLOAD);
+ }
+ }
+ }
@ -16486,7 +16486,7 @@ index 88729d92878f98729eb5669cce5ae5b1418865a1..13d15a135dd0373bef4a5ac9ffb56dbb
// Paper end
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d3f63185edd1db9fab3887ea3f08982435b3a23c..d6ecee1db17cb9eaeffa94b3d8dd150238fdefe5 100644
index a5734fd84e863d72489f3eef4c352f5ba324f448..bb623c041c64bfac6a66a493ae5f05a1c7fa98d6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -122,10 +122,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -18344,7 +18344,7 @@ index 0e89cf0742b9443f5256081987242554de24d893..802e9d266c01eaf8a83e78fe8dbe881e
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b33bf957b1541756e3b983b87b1c83629757739a..0ccdc8d135dd3edb410fbc1d248c20a4a45b37fa 100644
index b8f313d60e76203986669dffecc3323e6f38019a..dcdc82461df0f5cb7ef8894bebd2be83e07bc0cd 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -199,7 +199,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -19293,7 +19293,7 @@ index c502d9b85eb68b277ae17dfea34e0475f0156647..27d0f1ed58948039004f8f1eba2f7f96
this.desiredChunksPerTick = Double.isNaN((double)desiredBatchSize) ? 0.01F : Mth.clamp(desiredBatchSize, 0.01F, 64.0F);
if (this.unacknowledgedBatches == 0) {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0aa28caa1254137c0bae8e213bd08c9a654f5335..c4b4e5f5c9366b241686e881cda34568a57b4877 100644
index 2860c8e7df49655bd0f8832ec8362f43e22a1488..62013378c1925134682e7a7c406a398baf2d0358 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -296,7 +296,7 @@ public abstract class PlayerList {
@ -19552,7 +19552,7 @@ index 62363c09111aaa31220fb260940744c097af7b3c..ff497f0e80889508dd8c183b48cd33bc
@@ -4519,6 +4584,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
public final void setRemoved(Entity.RemovalReason entity_removalreason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
+ // Paper start - rewrite chunk system
+ io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot remove entity off-main");
+ if (!((ServerLevel)this.level).getEntityLookup().canRemoveEntity(this)) {
@ -19560,7 +19560,7 @@ index 62363c09111aaa31220fb260940744c097af7b3c..ff497f0e80889508dd8c183b48cd33bc
+ return;
+ }
+ // Paper end - rewrite chunk system
CraftEventFactory.callEntityRemoveEvent(this, cause);
CraftEventFactory.callEntityRemoveEvent(this, entity_removalreason, cause); // Paper - EntityRemoveFromWorldEvent
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@@ -4530,7 +4602,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -19867,7 +19867,7 @@ index bd20bea7f76a7307f1698fb2dfef37125032d166..9a28912f52824acdc80a62243b136e6f
<T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 975fcd4b8f93cb8c602ddeb165c485214eac10a4..d3137c9e5cc42ef191ea233b0d37eafeffc6f82c 100644
index f2f8f7b1356b0e7fe7010eca2fc55b46b0bcb1dc..75deea9c9b02feea2fb57556e48d97a6f460deb6 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -547,6 +547,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -21685,7 +21685,7 @@ index 7aee9f6b143c89cf8d65ca55eeda808152b4dd26..9c06c3729b09726e1da6ff8fb975cef2
// Paper start - implement pointers
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 68a0b6b8650e9e80e8e8c4037d92389cae899d72..9aec6efef4094bbdb920101df1a7a5a2a6070dde 100644
index c6c9199e88cd25f2ba8155cea77365f05979c07d..ba6c42530e5995dee4f693fd5d560f21bb8fde7e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3463,31 +3463,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

File diff suppressed because it is too large Load diff

View file

@ -59,14 +59,14 @@ index 02b9e1ed57f5d65698c461387ff7d48450e6a70f..0d18b12d0755c14bd041e0f981774696
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 8f468a3bfa8ef381eabb45ebb3dd9a4942e98dd5..96e0fc5c8a018fd579f24529175decdac634cfa1 100644
index 1b9ea4990ca03a48b26457d0e42d97eca39d703c..147c4cb3460fa7d46b8c1e20aeaec3e4f1b215f7 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1931,4 +1931,13 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
@@ -1944,4 +1944,13 @@ public class CraftEventFactory {
new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity(), entity.level().getWorld(), cause).callEvent();
}
+ // Paper start - PlayerUseUnknownEntityEvent
// Paper end - EntityRemoveFromWorldEvent
+ // 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(
+ (Player) player.getBukkitEntity(), packet.getEntityId(), packet.isAttack(),

View file

@ -21,7 +21,7 @@ index 99771070840a545537fe352bda1c4aaeedd638ca..2fab84c5e2dc4de39281956390588a9a
return true;
diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index 25a45e680f9fdea90f43d59de87a3a500f4ee8c0..0330a62a6a0060d2a96de191db68774588fc7ae5 100644
index eb1fcd73600db3c040f8700c822157333d4e7f00..2d70e18de483d72b637e08286627a7f9a8199dff 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -44,9 +44,63 @@ public class ExperienceOrb extends Entity {
@ -172,7 +172,7 @@ index 48d0cbe7859c62bbf281a7b43ef9af658667cb7b..b46352b328178df2a48d1c9e895bed3f
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
index de2a25db9465bc4ae3cbf7ff6d3af756df679f4a..a6788da1505f9e119c03b94488f5e006da13e918 100644
index c7e5d4279df924ed4067f4b74c36e1a4dd0ccbad..dd04f885d1a9ecb9ad9fc743792fa32df7e7e1c4 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
@@ -897,7 +897,7 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
@ -220,7 +220,7 @@ index 25a429a2d1725d562a28b9d07dba630cfe49d32a..f8283405b3c5bd43746a5738be55f600
if (this.dragonFight != null) {
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 243eb1e54293c763a06febff551c051398d43535..79fdc8284f57a4f11e1954936ad574f7b8df5435 100644
index ec2f1f1a2e12048a6c8b38cf787374218509306f..ae149663ecd46489066223bf325bc2fb8a37e4af 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -634,7 +634,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@ -233,7 +233,7 @@ index 243eb1e54293c763a06febff551c051398d43535..79fdc8284f57a4f11e1954936ad574f7
}
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index 0f2e2e42e732e942664d70a72dd9c4e47c7e95b6..e51cb9c96e1bd13c00bf938436f4fc26d80055a1 100644
index 922e8bdc52ce9e5720396406f97478730dc23c9c..5841aec10a9b0c102c64ecc45cef2967ceda6824 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -207,7 +207,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
@ -246,7 +246,7 @@ index 0f2e2e42e732e942664d70a72dd9c4e47c7e95b6..e51cb9c96e1bd13c00bf938436f4fc26
}
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
index ed43ad94ca007a54e3c32d5e17c141048eeb5835..0b4c67b9de6893601f032a8fae103e8a98f2c767 100644
index 37f4120add02737e6efdc8979ab3a841abe2148a..ad3b9af306313060b8f2ccbd4874e8d0aee6135b 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
@@ -525,7 +525,7 @@ public class FishingHook extends Projectile {
@ -259,7 +259,7 @@ index ed43ad94ca007a54e3c32d5e17c141048eeb5835..0b4c67b9de6893601f032a8fae103e8a
// CraftBukkit end
if (itemstack1.is(ItemTags.FISHES)) {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java
index 9963db38420b91ae817a18ff084311cb45c0edee..70ceef96c6305324aef3b006f6603817ef187e9f 100644
index ac8d4a1cc047b76cdaa93931282fbf1c3b07c15b..02377b4bbd4f3f11212bf8c372d3c86a6be443b6 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java
@@ -54,7 +54,7 @@ public class ThrownExperienceBottle extends ThrowableItemProjectile {
@ -268,7 +268,7 @@ index 9963db38420b91ae817a18ff084311cb45c0edee..70ceef96c6305324aef3b006f6603817
- ExperienceOrb.award((ServerLevel) this.level(), this.position(), i);
+ ExperienceOrb.award((ServerLevel) this.level(), this.position(), i, org.bukkit.entity.ExperienceOrb.SpawnReason.EXP_BOTTLE, this.getOwner(), this); // Paper
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
}
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java

View file

@ -5,7 +5,7 @@ Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 759c246540bbd5cb99c78a722c39b72fbc1951d4..f51f04758e135294bab5c7d1f891a8d67fea78f5 100644
index 3aed8b373d8e923d2c3fbb3528c68cdf3d62dfda..78865d3a8fe07f40d53155506a6a75b2c4349720 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -436,6 +436,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
@ -38,4 +38,4 @@ index 759c246540bbd5cb99c78a722c39b72fbc1951d4..f51f04758e135294bab5c7d1f891a8d6
+ if (flyAtPlayer) // Paper - PlayerPickupItemEvent
player.take(this, i);
if (itemstack.isEmpty()) {
this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent

View file

@ -64,7 +64,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index df6da730134da754d0ff23bd1b57c82486b9ab73..69b5946625a53a1351ffc4bdf61c6874949bbeae 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1010,4 +1010,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1009,4 +1009,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return originVector.toLocation(world);
}
// Paper end - entity origin API

View file

@ -42,7 +42,7 @@ index f53504221e660bfe86220a8cc1ae28750794f0cf..93550342c6f181b7622f5d649cd3e507
+ int i = Math.min(possibleDurabilityFromXp, itemstack.getDamageValue());
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.get().inSlot(), i);
+ 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 -= i * amount / possibleDurabilityFromXp;
+ itemstack.setDamageValue(itemstack.getDamageValue() - i);

View file

@ -25,7 +25,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index 91180d7ad705ca97c0df43debc14b204127165d0..e3af0db8082e4e90902197f96f1c833405bf5f63 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1976,4 +1976,14 @@ public class CraftEventFactory {
@@ -1989,4 +1989,14 @@ public class CraftEventFactory {
).callEvent();
}
// Paper end - PlayerUseUnknownEntityEvent

View file

@ -21,10 +21,10 @@ check is essentially the same as this.getHandle() == other.getHandle()
However, replaced it too to make it clearer of intent.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 69b5946625a53a1351ffc4bdf61c6874949bbeae..bddf98bdf60473eb1d2e533cf533ed7eee797aaa 100644
index 2ab879c05604312199126c0f51902f37742b2712..e46b0c85798a194a7e928999faf7a5776ebf27ef 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -502,14 +502,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -501,14 +501,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false;
}
final CraftEntity other = (CraftEntity) obj;

View file

@ -225,7 +225,7 @@ index d6bbeaf3833a4c44ed05243445edd813e3f15dcb..1b13096da1f0bc49efe25677ec24e6ab
Level world = this.level();
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
index 230040bef7d2cf9a463cfd9cb3b1b1aa208a7119..6c79997ba46e641de5aa12ff8a3d790d04a5a475 100644
index 8b79944f80279339a27f64001572a87dca93d01a..49c339d84f7f8d4ffa11504bed24553af2cc0435 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -519,7 +519,7 @@ public abstract class AbstractArrow extends Projectile {
@ -238,7 +238,7 @@ index 230040bef7d2cf9a463cfd9cb3b1b1aa208a7119..6c79997ba46e641de5aa12ff8a3d790d
}
diff --git a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
index de2bc78415ab4efb651030be6560d9c9778a1d17..1e00df3fa3c3b61daa3d59ee1173269a6eae3a43 100644
index bea9ef6fdd9a45ef1f4893643035d9fd9d3e967b..03de16a6024dbdffcf2efc4a5add79fa16b5eb9b 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
@@ -103,7 +103,7 @@ public abstract class AbstractWindCharge extends AbstractHurtingProjectile imple
@ -315,5 +315,5 @@ index e3af0db8082e4e90902197f96f1c833405bf5f63..3059a21b554db99af96c76f72dd08591
}
+ // Paper end - replace knockback events
public static void callEntityRemoveEvent(Entity entity, EntityRemoveEvent.Cause cause) {
if (entity instanceof ServerPlayer) {
// Paper start - EntityRemoveFromWorldEvent
public static void callEntityRemoveEvent(Entity entity, Entity.RemovalReason removalReason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] EnderDragon Events
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
index 3eaf64a6f66c6a844e30967e6b87432e559a59e7..5c5c71db73a2bfebbb33cebd6325a0f4fef1f239 100644
index 32ab046a98ed888e98fc0174b7315c8c79b76ebd..870bb6d252981fccebc02605b859dce513aa21ea 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
@@ -88,7 +88,13 @@ public class DragonSittingFlamingPhase extends AbstractDragonSittingPhase {
@ -37,7 +37,7 @@ index e5c896409536b7fb908590d02e40923d5979841f..a28e6b6a50cfd9191732ad2e4aca5f63
if (this.currentPath != null) {
while (!this.currentPath.isDone()) {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
index 3c77515f6b7f1ff89325afba214e9a8e5f536158..1dade7a4fbdf190661e4431496349444467509cc 100644
index 68b51a30587d00bb2bcbb645710e93ccd79fba46..89c8aae3dbd77fd07299159155fca3d4f8cf265c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
@@ -63,8 +63,10 @@ public class DragonFireball extends AbstractHurtingProjectile {
@ -48,6 +48,6 @@ index 3c77515f6b7f1ff89325afba214e9a8e5f536158..1dade7a4fbdf190661e4431496349444
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
this.level().addFreshEntity(entityareaeffectcloud);
+ } else entityareaeffectcloud.discard(null); // Paper - EnderDragon Events
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
}

View file

@ -268,7 +268,7 @@ index 25a71cc5ca8cf8a5070cd24eb56fe0d79e765669..b46572f6e3b52f498b395d3b8c5def2a
}
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
index a6788da1505f9e119c03b94488f5e006da13e918..e46c8231ee318eda0512afbb6343b426b4838643 100644
index dd04f885d1a9ecb9ad9fc743792fa32df7e7e1c4..2fa31978a4f181608b2b6c540de7db1635a5cef5 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
@@ -704,16 +704,38 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
@ -336,7 +336,7 @@ index 767817fb1418958c89d0db9da4ae7eb8a5a16076..5654c614f07f07ff642ba4851b0cb6fa
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc655020714e9b1ffd 100644
index 7f5c374f13ba86acb3e12bedb92665753842bcf5..16ec47a4b47e25a34304fe8ca58d6cd659d01222 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -505,8 +505,10 @@ public class ArmorStand extends LivingEntity {
@ -359,7 +359,7 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071
- this.brokenByPlayer(worldserver, source);
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(worldserver, source); // Paper
this.showBreakingParticles();
- this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
- this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event // Paper - EntityRemoveFromWorldEvent
+ if (!event.isCancelled()) this.kill(source, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
}
@ -419,7 +419,7 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071
+ if (event.isCancelled()) return;
+ }
+ // Paper end
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); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
// CraftBukkit end
this.gameEvent(GameEvent.ENTITY_DIE);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java

View file

@ -138,7 +138,7 @@ index 146cbec9e64b6c77759aadd0d0c4e989018e9aef..4c4545b3732d4c08afdb7bc1913169a9
level.gameEvent(entity, GameEvent.ENTITY_PLACE, this.position());
this.setItem(ItemStack.EMPTY);
diff --git a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
index 1dade7a4fbdf190661e4431496349444467509cc..3e869620db35d38db39fbeed715b898ef9d2743c 100644
index 8d2a9cb0a4dc6d8f134213abf3a094e55e67474b..65ab90ec9a24e12225be57c6b10b93a8d65438f9 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
@@ -65,7 +65,7 @@ public class DragonFireball extends AbstractHurtingProjectile {
@ -148,7 +148,7 @@ index 1dade7a4fbdf190661e4431496349444467509cc..3e869620db35d38db39fbeed715b898e
- this.level().addFreshEntity(entityareaeffectcloud);
+ this.level().addFreshEntity(entityareaeffectcloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason
} else entityareaeffectcloud.discard(null); // Paper - EnderDragon Events
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
}
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index ee897b8c9462dbb3d7be9a2994753155065ce205..1d0964a7f544735a0213d5c7832c71f53db139a9 100644
@ -214,10 +214,10 @@ index c3f6522a7dc0777c5b3fa2bac63a8901f96d9f38..9b336f651ead8111a0b2c0fedad9331f
if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, pos).isCancelled()) {
return Optional.empty();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index bddf98bdf60473eb1d2e533cf533ed7eee797aaa..ce70c8fddbe63d0af2b1f988ce9a2b40c5d48066 100644
index e46b0c85798a194a7e928999faf7a5776ebf27ef..8f8ff10ec0e3543dbd3baa9529241819caf2441f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1018,4 +1018,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1017,4 +1017,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.getHandle().spawnedViaMobSpawner;
}
// Paper end - Entity#fromMobSpawner

View file

@ -77,7 +77,7 @@ index 82fc5133325a127890984d51c1381883759eb444..ae16cf5c803caae636860dd9b1a83abe
+ break;
+ }
+ case DELETE: {
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ entity.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DISCARD);
+ return true;
+ }
+ default:

View file

@ -21,7 +21,7 @@ Co-authored-by: Aikar <aikar@aikar.co>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index 0916e24271d07ad5db51c5bc68791722b0f69c2b..a758b2456acac23095fe4619ae10300a034cb460 100644
index 3957988d213716258e72b4708acc08ec1cdf0f27..2b3ecec18a1e0a1ac4057b4f72e6b45488f9aa06 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -244,6 +244,7 @@ public class ExperienceOrb extends Entity {
@ -43,7 +43,7 @@ index 0916e24271d07ad5db51c5bc68791722b0f69c2b..a758b2456acac23095fe4619ae10300a
+ // Paper end - call orb merge event
this.count += other.count;
this.age = Math.min(this.age, other.age);
other.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause
other.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
@@ -360,7 +366,7 @@ public class ExperienceOrb extends Entity {
int l = amount - k * amount / j;

View file

@ -8,10 +8,10 @@ public net.minecraft.world.entity.Entity isInRain()Z
public net.minecraft.world.entity.Entity isInBubbleColumn()Z
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index ce70c8fddbe63d0af2b1f988ce9a2b40c5d48066..34321f095e12ea0cca34ff1ec00819c6350205a8 100644
index c5f15ff7f6af20a1c068a7068e54c21f34ab685a..ac0b1cbb6c8356061757673f868912dcc80d234d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1025,4 +1025,41 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1024,4 +1024,41 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return getHandle().spawnReason;
}
// Paper end - entity spawn reason API

View file

@ -81,10 +81,10 @@ index b90127f9f805fdb5bb43a4b8ad2b10499b0b6b78..8efc06d29c62fa2be8515ed3359d52a6
if (entity instanceof Mob) {
Mob entityinsentient = (Mob) entity;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 34321f095e12ea0cca34ff1ec00819c6350205a8..5f5788a502642463091fb76e98703aaec7a86836 100644
index ac0b1cbb6c8356061757673f868912dcc80d234d..6b27f7c2d2120cbefe9a05a2e5d56e0c6fa571db 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -240,7 +240,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -239,7 +239,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// entity.setLocation() throws no event, and so cannot be cancelled

View file

@ -19,10 +19,10 @@ index c01a9305eb1c3e2ee5effab1e11980c2540d3c2a..6ab665efcac4c2543bab9d95472026e0
// Paper end - Expose entity id counter
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 5f5788a502642463091fb76e98703aaec7a86836..98e8ad81b8c9c0636abe59f70ce891fe926a37fe 100644
index 6b27f7c2d2120cbefe9a05a2e5d56e0c6fa571db..0dbcca0080b8e9dceafc57acd7fbcac78c208c0c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1062,4 +1062,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1061,4 +1061,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return getHandle().isInLava();
}
// Paper end - entity liquid API

View file

@ -35,7 +35,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index 24fcb0eb139174671ffb7a8e5222ec9833835f87..9e67dc35ea12149265517b951a96828460b2ca67 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -2127,4 +2127,12 @@ public class CraftEventFactory {
@@ -2140,4 +2140,12 @@ public class CraftEventFactory {
return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion());
}
// Paper end - WitchReadyPotionEvent

View file

@ -20,6 +20,6 @@ index 98eb00a8ee23543714d424d3ff5ca19887d6db19..9436a9614dea81d14c4f77cc21ca91f8
+ }
+ }
+ // Paper end - Fix villager boat exploit
entity1.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause
entity1.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
});
}

View file

@ -32,7 +32,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index 9e67dc35ea12149265517b951a96828460b2ca67..251b605396b77b0c449972c1da75978f57587e1a 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -2134,5 +2134,11 @@ public class CraftEventFactory {
@@ -2147,5 +2147,11 @@ public class CraftEventFactory {
io.papermc.paper.event.block.BlockFailedDispenseEvent event = new io.papermc.paper.event.block.BlockFailedDispenseEvent(block);
return event.callEvent();
}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Expand EntityUnleashEvent
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 7d131f3b3f5739468aa3115e97ed28b6bfeca33d..da184893d617311a43f9ce176a965f8417a2876d 100644
index ce56ccbb116623f2803aed5f43f4be5d04f20fc5..76d83911dd1410520ba63d6a85da9dd17fe94c2b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2574,12 +2574,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -80,7 +80,7 @@ index 5c51dd5229689cba459655d488aee59bd159a414..e7535f15be3cc1537aafee53779ccfb4
default void closeRangeLeashBehaviour(Entity entity) {}
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index b46572f6e3b52f498b395d3b8c5def2aa799ff03..e87360e21e6eb7b0161c34a3ac6cb83d18bcd1e8 100644
index 14678e655da654cef8cb8f9faff6372b7c03b17f..dd1ede91e65f3b2301cac3bdec39b76e0078b453 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1621,8 +1621,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@ -115,7 +115,7 @@ index bf2c9134c7d9d5926add36b55e3cfea79e8c8243..7b7bc1a205dfacbe5709011b6b6799e7
return false;
diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
index 3c0af74ed65610b1d5e3b72fdcf28c5a3423f0da..01173fc7177d78588978e087e63efda0b0527c2f 100644
index cdc454055306b7a2e2a4be24207137b99b555d7d..30deb6f319983b0a4899fce3976927c92debb341 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
@@ -118,13 +118,18 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity {
@ -140,7 +140,7 @@ index 3c0af74ed65610b1d5e3b72fdcf28c5a3423f0da..01173fc7177d78588978e087e63efda0
flag1 = true;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 251b605396b77b0c449972c1da75978f57587e1a..c48a9026c4db2005b67c5f70e9e1fa95b7820bc0 100644
index a3613495df7c712fdcc2a97b06132e1483556fcc..97a9db439699a35bc1858c14cc4d6b7a3e953a83 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1598,8 +1598,10 @@ public class CraftEventFactory {

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 98e8ad81b8c9c0636abe59f70ce891fe926a37fe..96201ea45f8b53dcadb1a8732b1d49b1e8d1d7df 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1069,4 +1069,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1068,4 +1068,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return getHandle().isTicking();
}
// Paper end - isTicking API

View file

@ -8,7 +8,7 @@ Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6
Fix splash events cancellation that still show particles/sound
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
index be787a5b52e90796d4f06e17e564f4324807c3e6..cb34cc9443da56c0497c7a0192c8b8363c3426fe 100644
index f3c008de4ac3def173b63059e71b03ff1a001f6b..b3a4756ded5e48261b5cfa91af9d80e3b46506f0 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
@@ -106,55 +106,76 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
@ -34,7 +34,7 @@ index be787a5b52e90796d4f06e17e564f4324807c3e6..cb34cc9443da56c0497c7a0192c8b836
this.level().levelEvent(i, this.blockPosition(), potioncontents.getColor());
+ } // Paper - Fix potions splash events
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
}
}

View file

@ -146,7 +146,7 @@ index 615b57fac9def18d9dcaefcfe397c74c11cac627..f933654b66f7474dc071da5f10cf1684
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
index b06d39d3bd39a4dc4f273a359a89592d3b8cf184..43046f4a0cff620834ac4647efdcde227185b2ff 100644
index 81abf1ce26432afa1598f3b8f5e34c80289f639d..bd1f01deec9b0842fff67d7e25d4569c42316be4 100644
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -50,6 +50,7 @@ public class Tadpole extends AbstractFish {
@ -264,7 +264,7 @@ index 8afd453deda455bd486c9a4a69790151f5012f62..33b7e578f39608d522a9c270cac69be4
@Override
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 3ee24382ef3614ff0c5d5cdc614a41286ba4af5e..3cd4a744c3e3aeba90f342de9dea67ef2f3de626 100644
index 6f079d4d344d3421bccfe60ad8b014687b79c061..76b4340e9c7988c23967f53a495043a2abfb9622 100644
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -88,6 +88,11 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
@ -353,7 +353,7 @@ index 9cf453248b6ee9e1af9f5945b1e515a9ad7ff236..f8c733961015ace508bfe14fd61d5188
@Override
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
index 46b67c38dccf911973e6a7643f06972019073eb2..e45c3a9805d9fac1fabe6d891c817743acd9969e 100644
index 41b9c8bbb3f31cd29ad4c0ba524311a253123cbe..08447cf5e0f978c52f1413bf5a9cc991e38f8e5c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
@@ -106,6 +106,20 @@ public class ThrownTrident extends AbstractArrow {
@ -708,7 +708,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 96201ea45f8b53dcadb1a8732b1d49b1e8d1d7df..7c04eb9e7eb5ff728465b46e3739eb2598ef1204 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1086,4 +1086,27 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1085,4 +1085,27 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return set;
}
// Paper end - tracked players API

View file

@ -30,7 +30,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 7c04eb9e7eb5ff728465b46e3739eb2598ef1204..6fab713531665298d3b03e7960a17ecb1471a6d7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1087,6 +1087,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1086,6 +1086,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// Paper end - tracked players API

View file

@ -10,7 +10,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 6fab713531665298d3b03e7960a17ecb1471a6d7..4ed5647101bbace0005b1ebfb824e4aed48e43cb 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1099,6 +1099,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1098,6 +1098,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// Paper end - raw entity serialization API

View file

@ -7,7 +7,7 @@ Subject: [PATCH] Add API for item entity health
public net.minecraft.world.entity.item.ItemEntity health
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index 4a15c3786edbfeae3367c0b20fb6aee11d62aea6..1a291dd8a287db30e71dcb315599fc4b038764c4 100644
index 4a15c3786edbfeae3367c0b20fb6aee11d62aea6..dc0656ceec4e77f38ab7a9f2de8a7b24deec4837 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -98,6 +98,21 @@ public class CraftItem extends CraftEntity implements Item {
@ -24,7 +24,7 @@ index 4a15c3786edbfeae3367c0b20fb6aee11d62aea6..1a291dd8a287db30e71dcb315599fc4b
+ 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;
+ }

View file

@ -62,7 +62,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 4ed5647101bbace0005b1ebfb824e4aed48e43cb..4c09f2529dd8eb7ac7d260d177f5292ff2339442 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -323,6 +323,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -322,6 +322,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.getHandle().isFullyFrozen();
}

View file

@ -32,7 +32,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 4c09f2529dd8eb7ac7d260d177f5292ff2339442..94051ae8ea93ab144f3767345b1cda0438d2afc6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -221,15 +221,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -220,15 +220,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public boolean teleport(Location location, TeleportCause cause) {
@ -71,7 +71,7 @@ index 4c09f2529dd8eb7ac7d260d177f5292ff2339442..94051ae8ea93ab144f3767345b1cda04
// Let the server handle cross world teleports
if (location.getWorld() != null && !location.getWorld().equals(this.getWorld())) {
@@ -975,6 +996,39 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -974,6 +995,39 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return CraftEntity.perm;
}

View file

@ -25,7 +25,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 94051ae8ea93ab144f3767345b1cda0438d2afc6..f950102a324d07aeba260bfa82fe88728f2362e5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1193,4 +1193,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1192,4 +1192,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.getHandle().noPhysics;
}
// Paper end - missing entity api

View file

@ -40,7 +40,7 @@ index d3d50ec0f4466464c048449d8a844569c447d59b..b9810a1f6ac91ae9631dd1ebc225f009
+ // Paper end - EntityPickupItemEvent fixes
piglin.take(drop, drop.getItem().getCount());
itemstack = drop.getItem();
drop.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
drop.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
} else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, drop.getItem().getCount() - 1, false).isCancelled()) {
+ piglin.onItemPickup(drop); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification
piglin.take(drop, 1);
@ -56,7 +56,7 @@ index d3d50ec0f4466464c048449d8a844569c447d59b..b9810a1f6ac91ae9631dd1ebc225f009
if (!flag) {
PiglinAi.putInInventory(piglin, itemstack);
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
index 174d246b0a4d0fc9d769aad08da627ca8487bdf2..bbf21ea433f9e3963aac0ede597ed8d3c8e50ed8 100644
index b319ce7d8e09ed8325e3ba0d1ab0c84574938d92..c5d584922b0924e7cd5550637a2d30741c18e64d 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
@@ -225,6 +225,11 @@ public abstract class Raider extends PatrollingMonster {

View file

@ -10,7 +10,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai
index 4bf6281a75597072b19658208e4447c4d1ee8ba2..688f9f13ae06337250e2e9ac2ddf9ad90d049f9b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2302,4 +2302,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2310,4 +2310,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
}
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index f950102a324d07aeba260bfa82fe88728f2362e5..ac513d3162a0794f226abc80bff21c799fe5802c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -874,6 +874,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -873,6 +873,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return Pose.values()[this.getHandle().getPose().ordinal()];
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index ac513d3162a0794f226abc80bff21c799fe5802c..7c7501b4b21530d0641774f64e87d7d1ca71a33c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1183,6 +1183,33 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1182,6 +1182,33 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// Paper end - entity powdered snow API

View file

@ -72,7 +72,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index b6cca72b4785d5cf009077c81c1cca718d8cfe28..a0b387ddf3cc1e3473c6b35175ac8b68c717cfbe 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -2197,4 +2197,28 @@ public class CraftEventFactory {
@@ -2210,4 +2210,28 @@ public class CraftEventFactory {
return event.callEvent();
}
// Paper end

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Expand PlayerItemMendEvent
diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index a758b2456acac23095fe4619ae10300a034cb460..a58ff67052fb5f33782f8b5c83465ec03ef1d073 100644
index 2b3ecec18a1e0a1ac4057b4f72e6b45488f9aa06..ed17a307b050d7ccaef02a027d28ce1a9983e484 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -354,7 +354,10 @@ public class ExperienceOrb extends Entity {
@ -41,7 +41,7 @@ index 06a3ccb90f23fc357e5cbc6e9173baab4b218955..3945a6ab723deee3ec3ebb5fbc726ce1
+ 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 -= i * amount / possibleDurabilityFromXp;
+ amount -= consumedExperience; // Use previously computed variable to reduce diff on change.

View file

@ -53,7 +53,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index 9586837f25464396c0695e87fa278c91ca90183a..9b3023fdda9d08c0f5489542f644e2ea311af191 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -2198,6 +2198,32 @@ public class CraftEventFactory {
@@ -2211,6 +2211,32 @@ public class CraftEventFactory {
}
// Paper end

View file

@ -1214,8 +1214,8 @@ index 37f37df8b4185c92c13e43eb89d19514e360059e..33ac5c816c98c2dfa99898279ed74d42
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
return this.getBukkitEntity();
@@ -4486,6 +4498,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
CraftEventFactory.callEntityRemoveEvent(this, cause);
public final void setRemoved(Entity.RemovalReason entity_removalreason, com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause cause) { // Paper - EntityRemoveFromWorldEvent
CraftEventFactory.callEntityRemoveEvent(this, entity_removalreason, cause); // Paper - EntityRemoveFromWorldEvent
// CraftBukkit end
+ final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
if (this.removalReason == null) {
@ -1335,7 +1335,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 7c7501b4b21530d0641774f64e87d7d1ca71a33c..d3ff8015b2f713451b0aeb50e1b4cf81f2bcb7bc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -70,6 +70,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -69,6 +69,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
private EntityDamageEvent lastDamageEvent;
private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftEntity.DATA_TYPE_REGISTRY);
protected net.kyori.adventure.pointer.Pointers adventure$pointers; // Paper - implement pointers
@ -1351,7 +1351,7 @@ index 7c7501b4b21530d0641774f64e87d7d1ca71a33c..d3ff8015b2f713451b0aeb50e1b4cf81
public CraftEntity(final CraftServer server, final Entity entity) {
this.server = server;
@@ -486,6 +495,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -485,6 +494,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.entity;
}

View file

@ -10,7 +10,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index d3ff8015b2f713451b0aeb50e1b4cf81f2bcb7bc..3626fea17527da69e6fbee26f018f52ef036cf90 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1263,4 +1263,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1262,4 +1262,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return !this.getHandle().level().noCollision(this.getHandle(), aabb);
}
// Paper end - Collision API

View file

@ -21,6 +21,6 @@ index 6306f7925ac4852d8eed7508a11764c636dd7d36..5868d2e9e05a698c77117cf87c79b636
+ }
+ // Paper end - Fire entity death event
+
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); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
this.gameEvent(GameEvent.ENTITY_DIE);
if (this.dragonFight != null) {

View file

@ -28,7 +28,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 3626fea17527da69e6fbee26f018f52ef036cf90..580427bf1521ac9fef37f7464e12a7bfe4fbfb10 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -899,6 +899,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -898,6 +898,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public boolean isSneaking() {
return this.getHandle().isShiftKeyDown();
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 580427bf1521ac9fef37f7464e12a7bfe4fbfb10..9ca1fee03bfa557f1df7388c6043c9ec6d02a79a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -258,6 +258,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -257,6 +257,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false;
}

View file

@ -44,7 +44,7 @@ index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..2ee48ac3b665db2b02bcb1a30ec972d4
+ // Paper end - custom shear drops
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
index aa125e3043b120935aaa015803f065f99eb8d050..0c21959f57ae88fcd0a4d6dc911c1ce347c96528 100644
index 514b961f94e9239b7879a98df789c8fa396d25bf..dac0a9d5118cf5f1f7c74c087c35b527c6e2dec0 100644
--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
@@ -123,11 +123,18 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
@ -93,7 +93,7 @@ index aa125e3043b120935aaa015803f065f99eb8d050..0c21959f57ae88fcd0a4d6dc911c1ce3
if (!this.level().isClientSide()) {
Cow entitycow = (Cow) EntityType.COW.create(this.level());
@@ -193,17 +216,12 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
// CraftBukkit end
- for (int i = 0; i < 5; ++i) {

View file

@ -123,7 +123,7 @@ index 7bc612890f941177da11da0ce047d5a74d8ebb33..270acce7411e5ada71eaa04c05efc888
if (damager != null) {
event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), source.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
index 9bf11a8b44e696b6587bc775904a836d390e437b..d1041f2a4f1b3ea29ad532006e18cdc30c5019fa 100644
index 6ec47383b62b869f063368ff2088636c3f59ac08..64355b3ff97209961739a2671f60320271478ec8 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -271,7 +271,7 @@ public class Creeper extends Monster implements PowerableMob {
@ -134,9 +134,9 @@ index 9bf11a8b44e696b6587bc775904a836d390e437b..d1041f2a4f1b3ea29ad532006e18cdc3
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this)
this.spawnLingeringCloud();
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java
index c75433bb0fcd4264148950467bf6b700296aca7b..820965950c8b6c868ee261cf9613665e583f092e 100644
index 932c2f8681e7a6a88bd1c66d8d498b24a3eb12a7..9c44d35c7b8d67b00c19c427cf2a3e5f5129aa35 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java
@@ -135,7 +135,7 @@ public class EvokerFangs extends Entity implements TraceableEntity {
@ -149,7 +149,7 @@ index c75433bb0fcd4264148950467bf6b700296aca7b..820965950c8b6c868ee261cf9613665e
if (entityliving1.isAlliedTo((Entity) target)) {
return;
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
index f43dd56182ced23cf1cf65c149c532a611cc933a..1aa5e57a4e6a4be60514d8808a2e6c973d93e798 100644
index e53d9109d9033031d7f0f14281da3a190ab0146f..cdc0331b923a4099dc66d02f2333a1bcc4b699ae 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -89,7 +89,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
@ -162,7 +162,7 @@ index f43dd56182ced23cf1cf65c149c532a611cc933a..1aa5e57a4e6a4be60514d8808a2e6c97
}
} else {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/WitherSkull.java b/src/main/java/net/minecraft/world/entity/projectile/WitherSkull.java
index 60eac9df10a9a395a1568925515d010eb51a64e5..55fd997a4e894eeab24de269d59e486196ffbe8d 100644
index 1ee5176e6e485898c57c2bab8f3cf718807b1f46..f2c4c2edd1f308acaa7a75f98eaba880c4b31c09 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/WitherSkull.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/WitherSkull.java
@@ -77,7 +77,7 @@ public class WitherSkull extends AbstractHurtingProjectile {

View file

@ -2177,7 +2177,7 @@ index 0000000000000000000000000000000000000000..5b092bca7027e37aeee8f4b852ad896d
+}
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
new file mode 100644
index 0000000000000000000000000000000000000000..997b05167c19472acb98edac32d4548cc65efa8e
index 0000000000000000000000000000000000000000..a94ad978faee586d1bc73fc5a438b7bb1b5a3c8d
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -0,0 +1,819 @@
@ -2185,6 +2185,7 @@ index 0000000000000000000000000000000000000000..997b05167c19472acb98edac32d4548c
+
+import ca.spottedleaf.moonrise.common.list.EntityList;
+import ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity;
+import com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent;
+import com.google.common.collect.ImmutableList;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
@ -2209,7 +2210,6 @@ index 0000000000000000000000000000000000000000..997b05167c19472acb98edac32d4548c
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Predicate;
+import org.bukkit.event.entity.EntityRemoveEvent;
+
+public final class ChunkEntitySlices {
+
@ -2330,12 +2330,12 @@ index 0000000000000000000000000000000000000000..997b05167c19472acb98edac32d4548c
+ continue;
+ }
+ if (entity.shouldBeSaved()) {
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveFromWorldEvent.Cause.UNLOAD);
+ if (entity.isVehicle()) {
+ // we cannot assume that these entities are contained within this chunk, because entities can
+ // desync - so we need to remove them all
+ for (final Entity passenger : entity.getIndirectPassengers()) {
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveFromWorldEvent.Cause.UNLOAD);
+ }
+ }
+ }
@ -27282,14 +27282,14 @@ index 76e9d34e5219fbae0095cf735b58833c29343573..6fe90b281c95062c0be14650c00b21b6
@@ -4529,6 +4730,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
public final void setRemoved(Entity.RemovalReason entity_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
CraftEventFactory.callEntityRemoveEvent(this, cause);
CraftEventFactory.callEntityRemoveEvent(this, entity_removalreason, cause); // Paper - EntityRemoveFromWorldEvent
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@@ -4540,7 +4747,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -27565,7 +27565,7 @@ index 971fb29a2c3dc713cb8ab1d2eed054cc16f9c93c..a6c0e89cb645693034f8e90ac2de8f2d
this(updateListener, true, ImmutableList.of());
}
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
index 2f398750bfee5758ad8b1367b6fc14364e4de776..c292f58ba4b29395484dbbf8591e455f449581d8 100644
index e2462d46d3994ec4cf65c8fe4794c577e8eb54a6..a7296b5a9f0e5a2b41c2cddc6b4b794763d0b085 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -359,7 +359,7 @@ public class ArmorStand extends LivingEntity {
@ -28754,7 +28754,7 @@ index 16e721ac80ba21511bdeccfccd055f7700bda61f..7a592a3c5491fc19ab33287e1e60b869
}
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
@@ -850,12 +1340,20 @@ 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
@ -29877,7 +29877,7 @@ index 0baa4adf2a4401f9c955352f27e6f99957d1dff4..3723c07183e7b894cccf4d01bedf1d0d
this.chunkType = chunkType;
this.heightmapsAfter = heightMapTypes;
diff --git a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
index ae16cf5c803caae636860dd9b1a83abe479ca5a4..b993c4b2595e2879b25753c2e34530f3622c18fa 100644
index 99077982cd61e2c4436d94a7283487c3e154cf65..fc288ff79a567ab8d2cd55e4ac6b277670e7d94f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
+++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
@@ -154,7 +154,7 @@ public class ChunkStatusTasks {

View file

@ -202,7 +202,7 @@ index 05dae689ada8d96009e81aabf95a626bae90ecd3..3b15995efc65a351da8dac009b969849
if (this.isUsingItem()) {
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
index b586116d8cca1585f9c9e618ed4d0cb2ef2747be..acf38ef6d8de8b15cf2b09eb7bda390c4e446e9a 100644
index 80c1c1096b88040e17b2fa373cf1fa8bfacddc46..60b7edcf6139abc8c292b7f62fb8576148cb0d09 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
@@ -108,8 +108,7 @@ public interface Bucketable {
@ -240,7 +240,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/
index 9ca1fee03bfa557f1df7388c6043c9ec6d02a79a..cd789c235acf740ec29c30b180e7fbe1a140caa9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1012,7 +1012,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1011,7 +1011,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return;
}

View file

@ -30,7 +30,7 @@ completely unnecessary, which also rids paper of the previous described
incompatibility with non-ticking chunks.
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 03cfa29bdb426a9fb6b1b6be6e897da48d4f2f3e..4423973d4d9a2c3879d98d1d4c8b8c117c677ac5 100644
index c0ab6a1f95dd49b77914534faeeca3f686084a77..4a872c1987dde64809fafc5948139966fe643685 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -60,7 +60,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
@ -43,7 +43,7 @@ index 03cfa29bdb426a9fb6b1b6be6e897da48d4f2f3e..4423973d4d9a2c3879d98d1d4c8b8c11
private int despawnRate = -1; // Paper - Alternative item-despawn-rate
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
@@ -153,12 +153,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
this.discard(com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause // Paper - EntityRemoveFromWorldEvent
} else {
super.tick();
- // CraftBukkit start - Use wall time for pickup and despawn timers

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Improve entity effect API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index cd789c235acf740ec29c30b180e7fbe1a140caa9..89c8713d2c2206d1b0d8c0a392c9d13b3e736f0c 100644
index f0ffb262c9ae0d60c8dd5e3b11312e79506db038..1362f28ae79f1c859a46520f6457eab7df98ecbf 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1299,4 +1299,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1298,4 +1298,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.getHandle().getScoreboardName();
}
// Paper end - entity scoreboard name
@ -25,7 +25,7 @@ index cd789c235acf740ec29c30b180e7fbe1a140caa9..89c8713d2c2206d1b0d8c0a392c9d13b
+ // Paper end - broadcast hurt animation
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index ad740739437be632fc7fedec488a7d0c49534688..42d7660efe5baa6f796f2a7606686c765b6f2478 100644
index cb7232ef3a8f142c43cc6a6780bf2815f799df95..82bdf534129ac26907a5fbd9dcb4aca04872b0b5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1277,6 +1277,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {