add hardcore property to config event (#117)

(cherry picked from commit f5f8e21427)
This commit is contained in:
mudkip 2024-01-26 00:10:00 -07:00 committed by Matt Worzala
parent 06695f71f0
commit cf8c275cf2
3 changed files with 15 additions and 3 deletions

View File

@ -203,6 +203,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
private int permissionLevel; private int permissionLevel;
private boolean reducedDebugScreenInformation; private boolean reducedDebugScreenInformation;
private boolean hardcore;
// Abilities // Abilities
private boolean flying; private boolean flying;
@ -262,10 +263,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
} }
@ApiStatus.Internal @ApiStatus.Internal
public void setPendingInstance(@NotNull Instance pendingInstance) { public void setPendingOptions(@NotNull Instance pendingInstance, boolean hardcore) {
// I(mattw) am not a big fan of this function, but somehow we need to store // I(mattw) am not a big fan of this function, but somehow we need to store
// the instance and i didn't like a record in ConnectionManager either. // the instance and i didn't like a record in ConnectionManager either.
this.pendingInstance = pendingInstance; this.pendingInstance = pendingInstance;
this.hardcore = hardcore;
} }
/** /**
@ -284,7 +286,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
this.dimensionType = spawnInstance.getDimensionType(); this.dimensionType = spawnInstance.getDimensionType();
final JoinGamePacket joinGamePacket = new JoinGamePacket( final JoinGamePacket joinGamePacket = new JoinGamePacket(
getEntityId(), false, List.of(), 0, getEntityId(), this.hardcore, List.of(), 0,
MinecraftServer.getChunkViewDistance(), MinecraftServer.getChunkViewDistance(), MinecraftServer.getChunkViewDistance(), MinecraftServer.getChunkViewDistance(),
false, true, false, dimensionType.toString(), spawnInstance.getDimensionName(), false, true, false, dimensionType.toString(), spawnInstance.getDimensionName(),
0, gameMode, null, false, levelFlat, deathLocation, portalCooldown); 0, gameMode, null, false, levelFlat, deathLocation, portalCooldown);

View File

@ -19,6 +19,7 @@ public class AsyncPlayerConfigurationEvent implements PlayerEvent {
private final Player player; private final Player player;
private final boolean isFirstConfig; private final boolean isFirstConfig;
private boolean hardcore;
private boolean sendRegistryData; private boolean sendRegistryData;
private Instance spawningInstance; private Instance spawningInstance;
@ -26,6 +27,7 @@ public class AsyncPlayerConfigurationEvent implements PlayerEvent {
this.player = player; this.player = player;
this.isFirstConfig = isFirstConfig; this.isFirstConfig = isFirstConfig;
this.hardcore = false;
this.sendRegistryData = isFirstConfig; this.sendRegistryData = isFirstConfig;
this.spawningInstance = null; this.spawningInstance = null;
} }
@ -42,6 +44,14 @@ public class AsyncPlayerConfigurationEvent implements PlayerEvent {
return isFirstConfig; return isFirstConfig;
} }
public boolean isHardcore() {
return this.hardcore;
}
public void setHardcore(boolean hardcore) {
this.hardcore = hardcore;
}
public boolean willSendRegistryData() { public boolean willSendRegistryData() {
return sendRegistryData; return sendRegistryData;
} }

View File

@ -288,7 +288,7 @@ public final class ConnectionManager {
if (packFuture != null) packFuture.join(); if (packFuture != null) packFuture.join();
keepAlivePlayers.remove(player); keepAlivePlayers.remove(player);
player.setPendingInstance(spawningInstance); player.setPendingOptions(spawningInstance, event.isHardcore());
player.sendPacket(new FinishConfigurationPacket()); player.sendPacket(new FinishConfigurationPacket());
}); });
if (DebugUtils.INSIDE_TEST) configFuture.join(); if (DebugUtils.INSIDE_TEST) configFuture.join();