Fix retain passengers teleport flag (#11858)

This commit is contained in:
Shane Bee 2025-01-04 12:19:07 -08:00 committed by GitHub
parent edde7264c6
commit 4106da712c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -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 setLevel(Lnet/minecraft/world/level/Level;)V
public net.minecraft.world.entity.Entity setRot(FF)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 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 unsetRemoved()V
public net.minecraft.world.entity.Entity wasTouchingWater public net.minecraft.world.entity.Entity wasTouchingWater
public net.minecraft.world.entity.ExperienceOrb count public net.minecraft.world.entity.ExperienceOrb count

View File

@ -245,7 +245,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// Paper start - Teleport passenger API // Paper start - Teleport passenger API
Set<io.papermc.paper.entity.TeleportFlag> flagSet = Set.of(flags); Set<io.papermc.paper.entity.TeleportFlag> flagSet = Set.of(flags);
boolean dismount = !flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE); 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 // 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()) { if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) {
return false; return false;
@ -257,7 +257,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
// Paper end // 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; return false;
} }
@ -288,6 +288,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// SPIGOT-619: Force sync head rotation also // SPIGOT-619: Force sync head rotation also
this.entity.setYHeadRot(location.getYaw()); this.entity.setYHeadRot(location.getYaw());
// Ensure passengers of entity are teleported
if (retainPassengers && this.entity.isVehicle()) this.entity.teleportPassengers();
return true; return true;
} }