PaperMC/Spigot-Server-Patches/0213-Fix-a-duplicate-alive-entity-on-second-world.patch

45 lines
2.2 KiB
Diff
Raw Normal View History

From 791a5b0f6feb0c241429bd044f2255ee251c3bc4 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 0e1d9817b..385329774 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2325,7 +2325,7 @@ public abstract class Entity implements ICommandListener {
// CraftBukkit end */
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;
@@ -2376,7 +2376,20 @@ public abstract class Entity implements ICommandListener {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
// CraftBukkit end */
-
+ // Paper Start - relocate code to modify the entities exit in a portal
+ if (portal) {
+ org.bukkit.util.Vector velocity = entity.getBukkitEntity().getVelocity();
+ worldserver1.getTravelAgent().adjustExit(entity, exit, velocity);
+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
+ if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) {
+ //entity.getBukkitEntity().setVelocity(velocity); // We don't have a CraftEntity yet, set these manually...
+ entity.motX = velocity.getX();
+ entity.motY = velocity.getY();
+ entity.motZ = velocity.getZ();
+ entity.velocityChanged = true;
+ }
+ }
+ // Paper end
boolean flag = entity.attachedToPlayer;
entity.attachedToPlayer = true;
--
2.12.0