mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
fix: update RespawnPacket to use dataToKeep bitset
(cherry picked from commit e146a9393e
)
This commit is contained in:
parent
941390fb87
commit
b7e3b40147
@ -486,7 +486,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
refreshHealth();
|
refreshHealth();
|
||||||
|
|
||||||
sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
|
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);
|
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
|
||||||
EventDispatcher.call(respawnEvent);
|
EventDispatcher.call(respawnEvent);
|
||||||
@ -1044,7 +1045,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
|
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
|
||||||
|
|
||||||
RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
|
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(removePlayerPacket);
|
||||||
sendPacket(destroyEntitiesPacket);
|
sendPacket(destroyEntitiesPacket);
|
||||||
@ -1444,7 +1446,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
"The dimension needs to be different than the current one!");
|
"The dimension needs to be different than the current one!");
|
||||||
this.dimensionType = dimensionType;
|
this.dimensionType = dimensionType;
|
||||||
sendPacket(new RespawnPacket(dimensionType.toString(), dimensionName,
|
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();
|
refreshClientStateAfterRespawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,19 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
|
|
||||||
public record RespawnPacket(String dimensionType, String worldName,
|
public record RespawnPacket(String dimensionType, String worldName,
|
||||||
long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
||||||
boolean isDebug, boolean isFlat, boolean copyMeta,
|
boolean isDebug, boolean isFlat, byte dataToCopy,
|
||||||
DeathLocation deathLocation, int portalCooldown) implements ServerPacket {
|
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) {
|
public RespawnPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(STRING), reader.read(STRING),
|
this(reader.read(STRING), reader.read(STRING),
|
||||||
reader.read(LONG), GameMode.fromId(reader.read(BYTE)),
|
reader.read(LONG), GameMode.fromId(reader.read(BYTE)),
|
||||||
GameMode.fromId(reader.read(BYTE)),
|
GameMode.fromId(reader.read(BYTE)),
|
||||||
reader.read(BOOLEAN), reader.read(BOOLEAN),
|
reader.read(BOOLEAN), reader.read(BOOLEAN),
|
||||||
reader.read(BOOLEAN), reader.read(DEATH_LOCATION),
|
reader.read(BYTE), reader.read(DEATH_LOCATION),
|
||||||
reader.read(VAR_INT));
|
reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +36,7 @@ public record RespawnPacket(String dimensionType, String worldName,
|
|||||||
writer.write(BYTE, previousGameMode.id());
|
writer.write(BYTE, previousGameMode.id());
|
||||||
writer.write(BOOLEAN, isDebug);
|
writer.write(BOOLEAN, isDebug);
|
||||||
writer.write(BOOLEAN, isFlat);
|
writer.write(BOOLEAN, isFlat);
|
||||||
writer.write(BOOLEAN, copyMeta);
|
writer.write(BYTE, dataToCopy);
|
||||||
writer.write(DEATH_LOCATION, deathLocation);
|
writer.write(DEATH_LOCATION, deathLocation);
|
||||||
writer.write(VAR_INT, portalCooldown);
|
writer.write(VAR_INT, portalCooldown);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user