mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-20 11:22:56 +02:00
99 lines
4.2 KiB
Diff
99 lines
4.2 KiB
Diff
From 47ddeac79b6d4daffa8e1d104d97691eb8fe7257 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 28 Nov 2014 00:24:18 -0600
|
|
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
|
|
index dfb4299..213a16b 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -40,6 +40,13 @@ public abstract class Entity implements ICommandListener {
|
|
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
}
|
|
// CraftBukikt end
|
|
+ // PaperSpigot start - Teleport passenger vehicle with player
|
|
+ public void retrack() {
|
|
+ final EntityTracker entityTracker = ((WorldServer) world).getTracker();
|
|
+ entityTracker.untrackEntity(this);
|
|
+ entityTracker.track(this);
|
|
+ }
|
|
+ // PaperSpigot end
|
|
|
|
private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
|
|
private static int entityCount;
|
|
@@ -1941,7 +1948,7 @@ public abstract class Entity implements ICommandListener {
|
|
// minecraftserver.getPlayerList().changeWorld(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");
|
|
@@ -1949,6 +1956,10 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
if (entity != null) {
|
|
entity.n(this);
|
|
+ // 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) {
|
|
BlockPosition blockposition = this.world.r(worldserver1.getSpawn());
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index c315654..fd00596 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -453,7 +453,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
|
|
// If this player is riding another entity, we must dismount before teleporting.
|
|
- entity.mount(null);
|
|
+ // PaperSpigot start
|
|
+ entity.mount(null); // Comment out when fully working, until then leave this
|
|
+
|
|
+ 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;
|
|
+ passenger.vehicle = entity;
|
|
+ }
|
|
+ // PaperSpigot end
|
|
|
|
// Update the From Location
|
|
from = event.getFrom();
|
|
@@ -474,6 +494,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
} else {
|
|
server.getHandle().moveToWorld(entity, toWorld.dimension, true, to, true);
|
|
}
|
|
+
|
|
+ // PaperSpigot start
|
|
+ if (vehicle != null) {
|
|
+ vehicle.retrack();
|
|
+ }
|
|
+
|
|
+ if (passenger != null) {
|
|
+ passenger.retrack();
|
|
+ }
|
|
+ // PaperSpigot end
|
|
+
|
|
return true;
|
|
}
|
|
|
|
--
|
|
1.9.1
|
|
|