Minor refactoring

Do not create Battle instance client-side from received "Ping" packet.
This commit is contained in:
Stephen Seo 2024-10-25 15:23:44 +09:00
parent 2eea03730b
commit 570c68c675

View file

@ -31,13 +31,12 @@ public record PacketBattlePing(int battleID, int remainingSeconds) implements Cu
@Override
public void handle(final @NotNull PacketBattlePing pkt, IPayloadContext ctx) {
ctx.enqueueWork(() -> {
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.battleID);
if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) {
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
TurnBasedMinecraftMod.proxy.pauseMCMusic();
}
TurnBasedMinecraftMod.proxy.setBattleGuiAsGui();
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds);
TurnBasedMinecraftMod.proxy.pauseMCMusic();
}).exceptionally(e -> {
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
return null;