Improvements to teleport with passenger vehicle

This commit is contained in:
Zach Brown 2014-11-30 22:35:33 -06:00
parent 718ed221b4
commit 4e29dfb788

View file

@ -1,4 +1,4 @@
From d5d998345385422fa5f96941068f849fbaa69558 Mon Sep 17 00:00:00 2001
From 26e2ea6f7f563be44fdc37919251dae52d6142c5 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
@ -43,14 +43,17 @@ index b0a90d7..1e5f057 100644
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 5864a51..2d4398e 100644
index d1f69dc..8a2d6e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -453,6 +453,26 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// If this player is riding another entity, we must dismount before teleporting.
entity.mount(null);
@@ -451,7 +451,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) {
@ -66,13 +69,12 @@ index 5864a51..2d4398e 100644
+ passenger.teleportTo(location, false);
+ passenger = passenger.getBukkitEntity().getHandle();
+ entity.passenger = passenger;
+ entity.vehicle = entity;
+ passenger.vehicle = entity;
+ }
+ // PaperSpigot end
+
// Update the From Location
from = event.getFrom();
// Grab the new To Location dependent on whether the event was cancelled.
@@ -472,6 +492,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} else {
server.getHandle().moveToWorld(entity, toWorld.dimension, true, to, true);