Improve cross-world teleportation handling

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-06-23 16:45:29 +10:00
parent 477394d314
commit 5d025bbee8
3 changed files with 41 additions and 23 deletions

View File

@@ -83,8 +83,8 @@
+ this.displayName = this.getScoreboardName();
+ this.bukkitPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth();
+ }
+
}
+ // Use method to resend items in hands in case of client desync, because the item use got cancelled.
+ // For example, when cancelling the leash event
+ public void resendItemInHands() {
@@ -130,9 +130,9 @@
+ }
+
+ return blockposition;
}
+ }
+ // CraftBukkit end
+
@Override
public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) {
AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO);
@@ -457,11 +457,11 @@
} else {
- return new DimensionTransition(this.server.overworld(), this, dimensiontransition_a);
+ dimensionTransition = new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit
}
+ }
+ // CraftBukkit start
+ if (reason == null) {
+ return dimensionTransition;
+ }
}
+
+ Player respawnPlayer = this.getBukkitEntity();
+ Location location = CraftLocation.toBukkit(dimensionTransition.pos(), dimensionTransition.newLevel().getWorld(), dimensionTransition.yRot(), dimensionTransition.xRot());
@@ -913,6 +913,24 @@
}
@Override
@@ -1433,7 +1832,7 @@
this.gameMode.setGameModeForPlayer(entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer());
this.onUpdateAbilities();
this.getAttributes().assignBaseValues(entityplayer.getAttributes());
- this.setHealth(this.getMaxHealth());
+ // this.setHealth(this.getMaxHealth()); // CraftBukkit
if (flag) {
this.getInventory().replaceWith(entityplayer.getInventory());
this.setHealth(entityplayer.getHealth());
@@ -1443,7 +1842,7 @@
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
- this.addEffect(new MobEffect(mobeffect));
+ // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit
}
this.experienceLevel = entityplayer.experienceLevel;
@@ -1465,7 +1864,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;