diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java index 67104bb..b7dff97 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java @@ -461,7 +461,7 @@ public class Battle { if (!isServer) { return; } - PacketBattlePing pingPacket = new PacketBattlePing(getId()); + PacketBattlePing pingPacket = new PacketBattlePing(getId(), (int)(timer / 1000000000L)); for (Combatant p : players.values()) { PacketDistributor.sendToPlayer((ServerPlayer)p.entity, pingPacket); } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java index 08ed1ff..0e3c1ba 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java @@ -11,12 +11,14 @@ import net.neoforged.neoforge.network.handling.IPayloadContext; import net.neoforged.neoforge.network.handling.IPayloadHandler; import org.jetbrains.annotations.NotNull; -public record PacketBattlePing(int battleID) implements CustomPacketPayload { +public record PacketBattlePing(int battleID, int remainingSeconds) implements CustomPacketPayload { public static final CustomPacketPayload.Type TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattleping")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, PacketBattlePing::battleID, + ByteBufCodecs.VAR_INT, + PacketBattlePing::remainingSeconds, PacketBattlePing::new ); @@ -34,6 +36,7 @@ public record PacketBattlePing(int battleID) implements CustomPacketPayload { } TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); + TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds); }).exceptionally(e -> { ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage())); return null;