diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java index 1a031bd..0c33dae 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()) { TurnBasedMinecraftMod.getHandler().send(pingPacket, PacketDistributor.PLAYER.with((ServerPlayer)p.entity)); } 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 942c7ee..d640f0b 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java @@ -9,13 +9,16 @@ import java.util.function.Function; public class PacketBattlePing { private int battleID; + private int decisionSeconds; public PacketBattlePing() { battleID = 0; + decisionSeconds = 1; } - public PacketBattlePing(int battleID) { + public PacketBattlePing(int battleID, int decisionSeconds) { this.battleID = battleID; + this.decisionSeconds = decisionSeconds; } public static class Encoder implements BiConsumer { @@ -24,6 +27,7 @@ public class PacketBattlePing { @Override public void accept(PacketBattlePing pkt, RegistryFriendlyByteBuf buf) { buf.writeInt(pkt.battleID); + buf.writeInt(pkt.decisionSeconds); } } @@ -32,7 +36,7 @@ public class PacketBattlePing { @Override public PacketBattlePing apply(RegistryFriendlyByteBuf buf) { - return new PacketBattlePing(buf.readInt()); + return new PacketBattlePing(buf.readInt(), buf.readInt()); } } @@ -46,6 +50,8 @@ public class PacketBattlePing { TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.battleID); } TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); + TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); + TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds); }); ctx.setPacketHandled(true); }