Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27037,7 +27037,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09
}

diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db74f04cea7 100644
index a9dde8ce02effc0e2f72825667dea37e1e959d03..7a7bd02937f1db6a2d2b9040d398d98ffb9fa1fc 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -202,7 +202,7 @@ import net.minecraft.world.scores.Team;
Expand Down Expand Up @@ -28135,7 +28135,7 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896
+ // Paper end - block counting
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf4b672617 100644
index 30618f5fc053d1e3edde1fab49c02c54d1608d71..40b309955932261ad2ce311e9f1fd6ed1c9af7d3 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -149,7 +149,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
Expand Down Expand Up @@ -28610,7 +28610,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf
}

public InteractionResult interact(Player player, InteractionHand hand) {
@@ -4298,15 +4535,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4304,15 +4541,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
}

public Iterable<Entity> getIndirectPassengers() {
Expand All @@ -28636,7 +28636,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf
}

public int countPlayerPassengers() {
@@ -4449,77 +4688,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4455,77 +4694,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return Mth.lerp(partialTick, this.yRotO, this.yRot);
}

Expand Down Expand Up @@ -28821,7 +28821,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf

public boolean touchingUnloadedChunk() {
AABB aabb = this.getBoundingBox().inflate(1.0);
@@ -4675,6 +4963,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4681,6 +4969,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
}

public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
Expand All @@ -28837,7 +28837,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf
if (!checkPosition(this, x, y, z)) {
return;
}
@@ -4826,6 +5123,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4832,6 +5129,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name

@Override
public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause
Expand All @@ -28850,7 +28850,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
if (this.removalReason == null) {
@@ -4836,7 +5139,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4842,7 +5145,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
this.stopRiding();
}

Expand All @@ -28859,7 +28859,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf
this.levelCallback.onRemove(removalReason);
this.onRemoval(removalReason);
// Paper start - Folia schedulers
@@ -4870,7 +5173,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -4876,7 +5179,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
public boolean shouldBeSaved() {
return (this.removalReason == null || this.removalReason.shouldSave())
&& !this.isPassenger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ index ff6fc300e9e7d1dbf4b0fa1e59bffe94e1f51259..d58ee455467b2c8307ea20f8a9d88f0f
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue(this.tickCount); // Paper
profilerFiller.push("commandFunctions");
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 7ab250350027543adc3926632b0d68a2254c6ad3..2e3e038874757049445a91bf590d5a1a427a3f6d 100644
index 01e472d0e6de4e0d2fdf90878c364e0f5ceb483e..5ebe15e2aaf8a45192750776532057e0313a717a 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -5190,6 +5190,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -5196,6 +5196,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
this.getBukkitEntity().taskScheduler.retire();
}
// Paper end - Folia schedulers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@
}
}

@@ -992,25 +_,95 @@
@@ -992,25 +_,84 @@
}

private boolean isPvpAllowed() {
Expand Down Expand Up @@ -694,18 +694,7 @@
+ location = respawnEvent.getRespawnLocation();
+
+ return new RespawnResult(
+ new TeleportTransition(
+ ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(),
+ org.bukkit.craftbukkit.util.CraftLocation.toVec3(location),
+ teleportTransition.deltaMovement(),
+ location.getYaw(),
+ location.getPitch(),
+ teleportTransition.missingRespawnBlock(),
+ teleportTransition.asPassenger(),
+ teleportTransition.relatives(),
+ teleportTransition.postTeleportTransition(),
+ teleportTransition.cause()
+ ),
+ teleportTransition.withChangedLocation(location),
+ isBedSpawn,
+ isAnchorSpawn
+ );
Expand Down Expand Up @@ -750,7 +739,7 @@
if (this.isRemoved()) {
return null;
} else {
@@ -1085,13 +_,48 @@
@@ -1085,13 +_,38 @@

ServerLevel level = teleportTransition.newLevel();
ServerLevel serverLevel = this.level();
Expand All @@ -776,17 +765,7 @@
+ }
+ if (!newExit.equals(exit)) {
+ level = ((org.bukkit.craftbukkit.CraftWorld) newExit.getWorld()).getHandle();
+ teleportTransition = new TeleportTransition(
+ level,
+ org.bukkit.craftbukkit.util.CraftLocation.toVec3(newExit),
+ Vec3.ZERO,
+ newExit.getYaw(),
+ newExit.getPitch(),
+ teleportTransition.missingRespawnBlock(),
+ teleportTransition.asPassenger(),
+ Set.of(),
+ teleportTransition.postTeleportTransition(),
+ teleportTransition.cause());
+ teleportTransition = teleportTransition.withChangedLocation(newExit).withVelocity(Vec3.ZERO).withRelatives(Set.of());
+ }
+ // CraftBukkit end
if (!teleportTransition.asPassenger()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@
+ }
+ if (!to.equals(teleEvent.getTo())) {
+ to = teleEvent.getTo();
+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause());
+ teleportTransition = teleportTransition.withChangedLocation(to).withVelocity(Vec3.ZERO).withRelatives(Set.of());
+ // Paper start - Call EntityPortalExitEvent
+ velocity = Vec3.ZERO;
+ }
Expand All @@ -1518,7 +1518,7 @@
+ to = event.getTo().clone();
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getAfter());
+ }
+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), velocity, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause());
+ teleportTransition = teleportTransition.withChangedLocation(to).withRelatives(Set.of()).withVelocity(velocity);
+ }
+ }
+ if (this.isRemoved()) {
Expand Down Expand Up @@ -1546,6 +1546,19 @@

for (Entity entity2 : list) {
entity2.startRiding(entityx, true, false);
@@ -3014,6 +_,12 @@
private TeleportTransition calculatePassengerTransition(TeleportTransition teleportTransition, Entity entity) {
float f = teleportTransition.yRot() + (teleportTransition.relatives().contains(Relative.Y_ROT) ? 0.0F : entity.getYRot() - this.getYRot());
float f1 = teleportTransition.xRot() + (teleportTransition.relatives().contains(Relative.X_ROT) ? 0.0F : entity.getXRot() - this.getXRot());
+ // Paper start - reposition entity as rider when teleporting via API call
+ // This change is mostly required for plugins teleporting entities *every* tick with passengers, specifically player passengers.
+ // The relative teleport of players, which base their location on the server -> client -> server teleport packet cycle, means player
+ // positions can quickly be desynced from their rider position, leading to infinitely growing offsets from their vehicle.
+ if (teleportTransition.passengerTeleportationMode() == TeleportTransition.PassengerTeleportationMode.POSITION_RIDER) this.positionRider(entity);
+ // Paper end - reposition entity as rider when teleporting via API call
Vec3 vec3 = entity.position().subtract(this.position());
Vec3 vec31 = teleportTransition.position()
.add(
@@ -3078,9 +_,17 @@
}

Expand Down Expand Up @@ -1588,7 +1601,7 @@
+
+ public boolean teleportTo(ServerLevel level, double x, double y, double z, Set<Relative> relativeMovements, float yaw, float pitch, boolean setCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
+ // CraftBukkit end
+ Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, pitch, relativeMovements, TeleportTransition.DO_NOTHING, cause)); // CraftBukkit
+ Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, pitch, relativeMovements, TeleportTransition.DO_NOTHING).withCause(cause)); // CraftBukkit
return entity != null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
+ // Store pre teleportation position as the teleport has been moved up.
+ final double preTeleportX = serverPlayer.getX(), preTeleportY = serverPlayer.getY(), preTeleportZ = serverPlayer.getZ();
+ final float preTeleportYRot = serverPlayer.getYRot(), preTeleportXRot = serverPlayer.getXRot();
+ ServerPlayer serverPlayer1 = serverPlayer.teleport(new TeleportTransition(serverLevel, vec3, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+ ServerPlayer serverPlayer1 = serverPlayer.teleport(new TeleportTransition(serverLevel, vec3, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING).withCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+ if (serverPlayer1 == null) {
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT);
+ return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
entity.setAsInsidePortal(this, pos);
TheEndGatewayBlockEntity.triggerCooldown(level, pos, state, theEndGatewayBlockEntity);
}
@@ -108,9 +_,9 @@
@@ -108,10 +_,10 @@
return null;
} else {
return entity instanceof ThrownEnderpearl
- ? new TeleportTransition(level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Set.of(), TeleportTransition.PLACE_PORTAL_TICKET)
+ ? new TeleportTransition(level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Set.of(), TeleportTransition.PLACE_PORTAL_TICKET, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_GATEWAY) // CraftBukkit
+ ? new TeleportTransition(level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Set.of(), TeleportTransition.PLACE_PORTAL_TICKET).withCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_GATEWAY) // CraftBukkit - teleport cause
: new TeleportTransition(
- level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), TeleportTransition.PLACE_PORTAL_TICKET
+ level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), TeleportTransition.PLACE_PORTAL_TICKET, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_GATEWAY // CraftBukkit
);
level, portalPosition, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), TeleportTransition.PLACE_PORTAL_TICKET
- );
+ ).withCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_GATEWAY); // CraftBukkit - teleport cause
}
} else {
return null;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
f = Direction.WEST.toYRot();
f1 = 0.0F;
set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT));
@@ -97,15 +_,24 @@
@@ -97,15 +_,25 @@
f1 = respawnData.pitch();
set = Relative.union(Relative.DELTA, Relative.ROTATION);
if (entity instanceof ServerPlayer serverPlayer) {
Expand All @@ -45,9 +45,6 @@
bottomCenter = entity.adjustSpawnLocation(level1, blockPos).getBottomCenter();
}

- return new TeleportTransition(
- level1, bottomCenter, Vec3.ZERO, f, f1, set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET)
- );
+ // CraftBukkit start
+ set.removeAll(Relative.ROTATION); // remove relative rotation flags to simplify event mutation
+ float absoluteYaw = !flag ? f : entity.getYRot() + f;
Expand All @@ -57,9 +54,11 @@
+ return null;
+ }
+ org.bukkit.Location to = result.to();
+
+ return new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL);
+ // CraftBukkit end
return new TeleportTransition(
level1, bottomCenter, Vec3.ZERO, f, f1, set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET)
- );
+ ).withChangedLocation(to).withCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - portal event & cause
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
Vec3 vec3 = new Vec3(blockPos.getX() + (flag ? d2 : d4), blockPos.getY() + d3, blockPos.getZ() + (flag ? d4 : d2));
Vec3 vec31 = PortalShape.findCollisionFreePosition(vec3, level, entity, dimensions);
- return new TeleportTransition(level, vec31, Vec3.ZERO, i, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), postTeleportTransition);
+ return new TeleportTransition(level, vec31, Vec3.ZERO, i, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // CraftBukkit
+ return new TeleportTransition(level, vec31, Vec3.ZERO, i, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), postTeleportTransition).withCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // CraftBukkit
}

@Override
Loading
Loading