Skip to content

Commit

Permalink
fix effect UI packet decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Jan 2, 2024
1 parent 67223d1 commit 7b50b0c
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public PacketOpenEffectGUI(int good, int bad, EffectsInfo effects) {
}

public static PacketOpenEffectGUI decode(FriendlyByteBuf buf) {
int goodNum = buf.readInt();
int badNum = buf.readInt();
int goodNum = buf.readVarInt();
int badNum = buf.readVarInt();

var lastChanged = Instant.ofEpochSecond(buf.readLong());
int size = buf.readVarInt();
List<TribeEffect> effectList = new ArrayList<>();
for (int i = 0; i < size; i++) {
int level = buf.readVarInt();
MobEffect effect = buf.readRegistryIdSafe(MobEffect.class);
MobEffect effect = buf.readRegistryId();
effectList.add(new TribeEffect(effect, level));
}

Expand All @@ -57,7 +57,7 @@ public static void encode(PacketOpenEffectGUI packet, FriendlyByteBuf buf) {
buf.writeVarInt(packet.numGood);
buf.writeVarInt(packet.numBad);

packet.effects.getLastChanged().ifPresentOrElse((time) -> buf.writeLong(time.getEpochSecond()), () -> buf.writeLong(0));
buf.writeLong(packet.effects.getLastChanged().orElse(Instant.EPOCH).getEpochSecond());

buf.writeVarInt(packet.effects.getEffects().size());
packet.effects.getEffects().forEach((tribeEffect) -> {
Expand All @@ -73,8 +73,7 @@ public static void handle(PacketOpenEffectGUI packet, Supplier<NetworkEvent.Cont


@OnlyIn(Dist.CLIENT)
private static void doOpen(PacketOpenEffectGUI packet){
Screen gui = new TribeEffectScreen(packet.numGood, packet.numBad, packet.effects);
Minecraft.getInstance().setScreen(gui);
private static void doOpen(PacketOpenEffectGUI packet) {
Minecraft.getInstance().setScreen(new TribeEffectScreen(packet.numGood, packet.numBad, packet.effects));
}
}

0 comments on commit 7b50b0c

Please sign in to comment.