From 4106da712cf1e07c3916ec4dc5d8077253a298cc Mon Sep 17 00:00:00 2001 From: Shane Bee Date: Sat, 4 Jan 2025 12:19:07 -0800 Subject: [PATCH] Fix retain passengers teleport flag (#11858) --- build-data/paper.at | 1 + .../java/org/bukkit/craftbukkit/entity/CraftEntity.java | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index 47ca2bb359..bb447c7213 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -196,6 +196,7 @@ public net.minecraft.world.entity.Entity random public net.minecraft.world.entity.Entity setLevel(Lnet/minecraft/world/level/Level;)V public net.minecraft.world.entity.Entity setRot(FF)V public net.minecraft.world.entity.Entity setSharedFlag(IZ)V +public net.minecraft.world.entity.Entity teleportPassengers()V public net.minecraft.world.entity.Entity unsetRemoved()V public net.minecraft.world.entity.Entity wasTouchingWater public net.minecraft.world.entity.ExperienceOrb count diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 86388f04b1..4562bee2e2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -245,7 +245,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Paper start - Teleport passenger API Set flagSet = Set.of(flags); boolean dismount = !flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE); - boolean ignorePassengers = flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS); + boolean retainPassengers = flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS); // Don't allow teleporting between worlds while keeping passengers if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) { return false; @@ -257,7 +257,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } // Paper end - if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API + if ((!retainPassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API return false; } @@ -288,6 +288,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // SPIGOT-619: Force sync head rotation also this.entity.setYHeadRot(location.getYaw()); + // Ensure passengers of entity are teleported + if (retainPassengers && this.entity.isVehicle()) this.entity.teleportPassengers(); + return true; }