mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
implement hardcore mode
This commit is contained in:
parent
ba5b4224d8
commit
0fe4bbcb38
2 changed files with 13 additions and 1 deletions
|
@ -368,6 +368,8 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
private volatile boolean closed;
|
||||
|
||||
private GameMode gameMode = GameMode.SURVIVAL;
|
||||
@Setter
|
||||
private boolean hardcore = false;
|
||||
|
||||
/**
|
||||
* Keeps track of the world name for respawning.
|
||||
|
@ -667,7 +669,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
@Setter
|
||||
private int stepTicks = 0;
|
||||
|
||||
|
||||
|
||||
public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop tickEventLoop) {
|
||||
this.geyser = geyser;
|
||||
this.upstream = new UpstreamSession(bedrockServerSession);
|
||||
|
@ -1640,6 +1642,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
startGamePacket.setUniqueEntityId(playerEntity.getGeyserId());
|
||||
startGamePacket.setRuntimeEntityId(playerEntity.getGeyserId());
|
||||
startGamePacket.setPlayerGameType(EntityUtils.toBedrockGamemode(gameMode));
|
||||
startGamePacket.setHardcore(hardcore);
|
||||
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
|
||||
startGamePacket.setRotation(Vector2f.from(1, 1));
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.translator.protocol.java;
|
|||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.cloudburstmc.protocol.bedrock.data.GameRuleData;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.DeathInfoPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.GameRulesChangedPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
import org.geysermc.erosion.Constants;
|
||||
|
@ -83,6 +84,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
session.setWorldName(spawnInfo.getWorldName());
|
||||
session.setLevels(Arrays.stream(packet.getWorldNames()).map(Key::asString).toArray(String[]::new));
|
||||
session.setGameMode(spawnInfo.getGameMode());
|
||||
session.setHardcore(packet.isHardcore());
|
||||
|
||||
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
||||
if (needsSpawnPacket) {
|
||||
|
@ -90,6 +92,13 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
DimensionUtils.setBedrockDimension(session, newDimension.bedrockId());
|
||||
session.connect();
|
||||
|
||||
// This is to ensure that you don't get stuck without a respawn screen in hardcore
|
||||
if (!entity.isAlive()) {
|
||||
DeathInfoPacket deathInfoPacket = new DeathInfoPacket();
|
||||
deathInfoPacket.setCauseAttackName("");
|
||||
session.sendUpstreamPacket(deathInfoPacket);
|
||||
}
|
||||
|
||||
// It is now safe to send these packets
|
||||
session.getUpstream().sendPostStartGamePackets();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue