diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index c206ae2d9..81a7255ba 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -487,7 +487,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable, refreshHealth(); sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(), - 0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown)); + 0, gameMode, gameMode, false, levelFlat, RespawnPacket.COPY_ALL, + deathLocation, portalCooldown)); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this); EventDispatcher.call(respawnEvent); @@ -1039,7 +1040,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable, final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList(); RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(), - 0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown); + 0, gameMode, gameMode, false, levelFlat, RespawnPacket.COPY_ALL, + deathLocation, portalCooldown); sendPacket(removePlayerPacket); sendPacket(destroyEntitiesPacket); @@ -1439,7 +1441,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable, "The dimension needs to be different than the current one!"); this.dimensionType = dimensionType; sendPacket(new RespawnPacket(dimensionType.toString(), dimensionName, - 0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown)); + 0, gameMode, gameMode, false, levelFlat, + RespawnPacket.COPY_ALL, deathLocation, portalCooldown)); refreshClientStateAfterRespawn(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java index 5730e5ba9..ce0dc7896 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java @@ -11,14 +11,19 @@ import static net.minestom.server.network.NetworkBuffer.*; public record RespawnPacket(String dimensionType, String worldName, long hashedSeed, GameMode gameMode, GameMode previousGameMode, - boolean isDebug, boolean isFlat, boolean copyMeta, + boolean isDebug, boolean isFlat, byte dataToCopy, DeathLocation deathLocation, int portalCooldown) implements ServerPacket { + + public static final byte COPY_ATTRIBUTES = 0x1; + public static final byte COPY_METADATA = 0x2; + public static final byte COPY_ALL = COPY_ATTRIBUTES | COPY_METADATA; + public RespawnPacket(@NotNull NetworkBuffer reader) { this(reader.read(STRING), reader.read(STRING), reader.read(LONG), GameMode.fromId(reader.read(BYTE)), GameMode.fromId(reader.read(BYTE)), reader.read(BOOLEAN), reader.read(BOOLEAN), - reader.read(BOOLEAN), reader.read(DEATH_LOCATION), + reader.read(BYTE), reader.read(DEATH_LOCATION), reader.read(VAR_INT)); } @@ -31,7 +36,7 @@ public record RespawnPacket(String dimensionType, String worldName, writer.write(BYTE, previousGameMode.id()); writer.write(BOOLEAN, isDebug); writer.write(BOOLEAN, isFlat); - writer.write(BOOLEAN, copyMeta); + writer.write(BYTE, dataToCopy); writer.write(DEATH_LOCATION, deathLocation); writer.write(VAR_INT, portalCooldown); }