Make sure the entity is still added to the world

This commit is contained in:
Zach Brown 2017-03-17 00:04:34 -05:00
parent 45ad47717e
commit 08aa6e5f49
No known key found for this signature in database
GPG Key ID: CC9DA35FC5450B76

View File

@ -1,30 +1,65 @@
From f2f4e3a3406b40e13a7dc05cc5dbaeda8038043a Mon Sep 17 00:00:00 2001
From ceabaae622b6af7225c9f35e188275dbe759acd6 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Fri, 17 Mar 2017 01:45:15 +0000
Subject: [PATCH] Fix a duplicate alive entity on second world
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0e1d9817..4cabdd7a 100644
index 0e1d9817..92ba4fcb 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2359,6 +2359,7 @@ public abstract class Entity implements ICommandListener {
@@ -2325,7 +2325,7 @@ public abstract class Entity implements ICommandListener {
// CraftBukkit end */
// CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
// minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
+ this.dead = true; // Paper - Mark entity as dead before we actually move it to the new world
worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal);
// worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity
// CraftBukkit end
@@ -2393,7 +2394,7 @@ public abstract class Entity implements ICommandListener {
// CraftBukkit end
}
- this.dead = true;
+ //this.dead = true; // Paper - Moved this up to ensure that the entity is dead when it's placed on the new world
this.world.methodProfiler.b();
worldserver.m();
worldserver1.m();
this.world.kill(this);
- this.dead = false;
+ //this.dead = false; // Paper - Mark entity as dead before we actually move it to the new world
this.world.methodProfiler.a("reposition");
/* CraftBukkit start - Handled in calculateTarget
BlockPosition blockposition;
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index a9d59bbf..a83a3054 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -803,7 +803,7 @@ public abstract class PlayerList {
entityplayer.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer.dimension, entityplayer.world.getDifficulty(), entityplayer.world.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode()));
this.f(entityplayer);
worldserver.removeEntity(entityplayer);
- entityplayer.dead = false;
+ //entityplayer.dead = false; // Paper - He's dead jim - Handle players the same way we do all entities
this.changeWorld(entityplayer, j, worldserver, worldserver1);
this.a(entityplayer, worldserver);
entityplayer.playerConnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
@@ -923,9 +923,9 @@ public abstract class PlayerList {
worldserver.methodProfiler.a("moving");
entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
- if (entity.isAlive()) {
+ //if (entity.isAlive()) { // Paper - The entity will be dead, that's okay
worldserver.entityJoinedWorld(entity, false);
- }
+ //} // Paper
/*
if (entity.dimension == -1) {
d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D);
@@ -969,7 +969,7 @@ public abstract class PlayerList {
d0 = (double) MathHelper.clamp((int) d0, -29999872, 29999872);
d1 = (double) MathHelper.clamp((int) d1, -29999872, 29999872);
*/
- if (entity.isAlive()) {
+ //if (entity.isAlive()) { // Paper - The entity will be dead, that's okay
// entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch);
// worldserver1.getTravelAgent().a(entity, f);
if (portal) {
@@ -982,7 +982,7 @@ public abstract class PlayerList {
}
// worldserver1.addEntity(entity);
worldserver1.entityJoinedWorld(entity, false);
- }
+ //} // Paper
worldserver.methodProfiler.b();
}
--
2.12.0.windows.1