From d4c819056dfe7bde94ac89b8ca71547d7f7c7922 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 21 Dec 2021 16:40:24 -0800 Subject: [PATCH] Forward CraftEntity in teleport command (#7025) --- ...070-Use-a-Shared-Random-for-Entities.patch | 2 +- ...-API-Replenishable-Lootables-Feature.patch | 2 +- ...ward-CraftEntity-in-teleport-command.patch | 39 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 patches/server/0833-Forward-CraftEntity-in-teleport-command.patch diff --git a/patches/server/0070-Use-a-Shared-Random-for-Entities.patch b/patches/server/0070-Use-a-Shared-Random-for-Entities.patch index 618da6448d..60afe5e84c 100644 --- a/patches/server/0070-Use-a-Shared-Random-for-Entities.patch +++ b/patches/server/0070-Use-a-Shared-Random-for-Entities.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Use a Shared Random for Entities Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created. diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ddbbef22813831267c407d9864ce8decb5706df5..664d7199e21f0c617ba41bc7596ead99a0325792 100644 +index fd43c6053b14f60d77e902326df8957d272b944c..6ed53d50f395dc2a629d7393b01074d14f0a60d4 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -152,6 +152,21 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i diff --git a/patches/server/0092-LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/0092-LootTable-API-Replenishable-Lootables-Feature.patch index 7b4afb04c8..456a8ccfeb 100644 --- a/patches/server/0092-LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/0092-LootTable-API-Replenishable-Lootables-Feature.patch @@ -515,7 +515,7 @@ index 0000000000000000000000000000000000000000..3377b86c337d0234bbb9b0349e4034a7 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 664d7199e21f0c617ba41bc7596ead99a0325792..1dba6be93f1078b71712d0b5a24224bdcaeb61a0 100644 +index 6ed53d50f395dc2a629d7393b01074d14f0a60d4..493ddc76367226fa6344a1ee333378410e42b165 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -167,6 +167,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i diff --git a/patches/server/0833-Forward-CraftEntity-in-teleport-command.patch b/patches/server/0833-Forward-CraftEntity-in-teleport-command.patch new file mode 100644 index 0000000000..e8e89b6b09 --- /dev/null +++ b/patches/server/0833-Forward-CraftEntity-in-teleport-command.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sat, 4 Dec 2021 17:04:47 -0800 +Subject: [PATCH] Forward CraftEntity in teleport command + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 9bb44918af119d9afae4a0a050c6a5381f028364..8ea81f6ac7503c68f0aea34802843bc545f46db0 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -3154,6 +3154,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i + } + + public void restoreFrom(Entity original) { ++ // Paper start ++ CraftEntity bukkitEntity = original.bukkitEntity; ++ if (bukkitEntity != null) { ++ bukkitEntity.setHandle(this); ++ this.bukkitEntity = bukkitEntity; ++ } ++ // Paper end + CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag()); + + nbttagcompound.remove("Dimension"); +@@ -3231,10 +3238,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i + if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit + ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit + } +- // CraftBukkit start - Forward the CraftEntity to the new entity +- this.getBukkitEntity().setHandle(entity); +- entity.bukkitEntity = this.getBukkitEntity(); +- // CraftBukkit end ++ // // CraftBukkit start - Forward the CraftEntity to the new entity // Paper - moved to Entity#restoreFrom ++ // this.getBukkitEntity().setHandle(entity); ++ // entity.bukkitEntity = this.getBukkitEntity(); ++ // // CraftBukkit end + } + + this.removeAfterChangingDimensions();