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);
}
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<PacketBattlePing> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TurnBasedMinecraftMod.MODID, "network_packetbattleping"));
public static final StreamCodec<ByteBuf, PacketBattlePing> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.VAR_INT,
PacketBattlePing::battleID,
+ ByteBufCodecs.VAR_INT,
+ PacketBattlePing::remainingSeconds,
PacketBattlePing::new
);
}
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
+ TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
}).exceptionally(e -> {
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
return null;