From 0fe4bbcb38d055e791eec10388509c2eb067d42a Mon Sep 17 00:00:00 2001 From: Ethan <68365423+letsgoawaydev@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:02:10 +0800 Subject: [PATCH] implement hardcore mode --- .../java/org/geysermc/geyser/session/GeyserSession.java | 5 ++++- .../translator/protocol/java/JavaLoginTranslator.java | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index 3bdf23e39..53b66b99f 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -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)); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java index 7a33c53d6..46d314da2 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java @@ -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