Skip to content

Commit

Permalink
Forward CraftEntity in teleport command (PaperMC#7025)
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker authored Dec 22, 2021
1 parent 76f3274 commit d4c8190
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion patches/server/0070-Use-a-Shared-Random-for-Entities.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions patches/server/0833-Forward-CraftEntity-in-teleport-command.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <[email protected]>
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();

0 comments on commit d4c8190

Please sign in to comment.