2014-09-22 05:05:59 +02:00
|
|
|
From 2e1e4619fd49a668fca9eabecbbc7f21d29b9af1 Mon Sep 17 00:00:00 2001
|
2014-06-22 22:28:51 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 17 May 2014 02:12:39 -0500
|
|
|
|
Subject: [PATCH] Teleport passenger/vehicle with player
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2014-07-21 22:46:54 +02:00
|
|
|
index dea5e19..5dc7e95 100644
|
2014-06-22 22:28:51 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2014-06-24 14:21:58 +02:00
|
|
|
@@ -38,6 +38,13 @@ public abstract class Entity {
|
2014-06-22 22:28:51 +02:00
|
|
|
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
|
|
|
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
|
|
}
|
|
|
|
+ // PaperSpigot start
|
|
|
|
+ public void retrack() {
|
|
|
|
+ final EntityTracker entityTracker = ((WorldServer) world).getTracker();
|
|
|
|
+ entityTracker.untrackEntity(this);
|
|
|
|
+ entityTracker.track(this);
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
private static int entityCount;
|
2014-06-24 14:21:58 +02:00
|
|
|
@@ -1849,7 +1856,7 @@ public abstract class Entity {
|
2014-06-22 22:28:51 +02:00
|
|
|
// minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1);
|
|
|
|
boolean before = worldserver1.chunkProviderServer.forceChunkLoad;
|
|
|
|
worldserver1.chunkProviderServer.forceChunkLoad = true;
|
|
|
|
- worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal);
|
|
|
|
+ //worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal); // PaperSpigot - no... this entity is dead
|
|
|
|
worldserver1.chunkProviderServer.forceChunkLoad = before;
|
|
|
|
// CraftBukkit end
|
|
|
|
this.world.methodProfiler.c("reloading");
|
2014-06-24 14:21:58 +02:00
|
|
|
@@ -1857,6 +1864,10 @@ public abstract class Entity {
|
2014-06-22 22:28:51 +02:00
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
entity.a(this, true);
|
|
|
|
+ // PaperSpigot start - move entity to new location
|
|
|
|
+ exit.getBlock(); // force load
|
|
|
|
+ entity.setLocation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
|
|
|
|
+ // PaperSpigot end
|
|
|
|
/* CraftBukkit start - We need to do this...
|
|
|
|
if (j == 1 && i == 1) {
|
|
|
|
ChunkCoordinates chunkcoordinates = worldserver1.getSpawn();
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2014-09-22 05:05:59 +02:00
|
|
|
index 173166f..2c8d0a0 100644
|
2014-06-22 22:28:51 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2014-09-22 05:05:59 +02:00
|
|
|
@@ -492,6 +492,26 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2014-08-18 17:43:17 +02:00
|
|
|
// If this player is riding another entity, we must dismount before teleporting.
|
|
|
|
entity.mount(null);
|
2014-06-22 22:28:51 +02:00
|
|
|
|
|
|
|
+ // PaperSpigot start
|
|
|
|
+ Entity vehicle = entity.vehicle;
|
|
|
|
+ Entity passenger = entity.passenger;
|
|
|
|
+ if (vehicle != null) {
|
|
|
|
+ vehicle.passenger = null;
|
|
|
|
+ vehicle.teleportTo(location, false);
|
|
|
|
+ vehicle = vehicle.getBukkitEntity().getHandle();
|
|
|
|
+ entity.vehicle = vehicle;
|
|
|
|
+ vehicle.passenger = entity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (passenger != null) {
|
|
|
|
+ passenger.vehicle = null;
|
|
|
|
+ passenger.teleportTo(location, false);
|
|
|
|
+ passenger = passenger.getBukkitEntity().getHandle();
|
|
|
|
+ entity.passenger = passenger;
|
|
|
|
+ entity.vehicle = entity;
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
// Update the From Location
|
|
|
|
from = event.getFrom();
|
|
|
|
// Grab the new To Location dependent on whether the event was cancelled.
|
2014-09-22 05:05:59 +02:00
|
|
|
@@ -511,6 +531,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2014-06-22 22:28:51 +02:00
|
|
|
} else {
|
|
|
|
server.getHandle().moveToWorld(entity, toWorld.dimension, true, to, true);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start
|
|
|
|
+ if (vehicle != null) {
|
|
|
|
+ vehicle.retrack();
|
|
|
|
+ //entity.retrack();
|
|
|
|
+ }
|
|
|
|
+ if (passenger != null) {
|
|
|
|
+ passenger.retrack();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
|
|
|
1.9.1
|
|
|
|
|