Minor refactoring
Do not create Battle instance client-side from received "Ping" packet.
This commit is contained in:
parent
2eea03730b
commit
570c68c675
1 changed files with 5 additions and 6 deletions
|
@ -31,13 +31,12 @@ public record PacketBattlePing(int battleID, int remainingSeconds) implements Cu
|
||||||
@Override
|
@Override
|
||||||
public void handle(final @NotNull PacketBattlePing pkt, IPayloadContext ctx) {
|
public void handle(final @NotNull PacketBattlePing pkt, IPayloadContext ctx) {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
|
if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) {
|
||||||
TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.battleID);
|
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 -> {
|
}).exceptionally(e -> {
|
||||||
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
|
ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage()));
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue