From 7ca7269f61154d87ac6c152ee9c863c1f039b174 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 30 Sep 2023 01:28:28 +0800 Subject: Fix #1492 --- .../main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java') diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 5e8e49475..f76efdd65 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -172,7 +172,9 @@ public class RoughlyEnoughItemsNetwork { boolean shift = packetByteBuf.readBoolean(); try { CompoundTag nbt = packetByteBuf.readAnySizeNbt(); - List> inputs = readInputs(nbt.getCompound("Inputs")); + int version = nbt.getInt("Version"); + if (version != 1) throw new IllegalStateException("Server and client REI protocol version mismatch! Server: 1, Client: " + version); + List> inputs = readInputs(nbt.getList("Inputs", Tag.TAG_COMPOUND)); List input = readSlots(container, player, nbt.getList("InputSlots", Tag.TAG_COMPOUND)); List inventory = readSlots(container, player, nbt.getList("InventorySlots", Tag.TAG_COMPOUND)); NewInputSlotCrafter crafter = new NewInputSlotCrafter<>(container, input, inventory, inputs); @@ -201,10 +203,11 @@ public class RoughlyEnoughItemsNetwork { return slots; } - private static List> readInputs(CompoundTag tag) { + private static List> readInputs(ListTag tag) { List> inputs = new ArrayList<>(); - for (Map.Entry entry : tag.tags.entrySet()) { - InputIngredient> stacks = InputIngredient.of(Integer.parseInt(entry.getKey()), EntryIngredient.read((ListTag) entry.getValue())); + for (Tag t : tag) { + CompoundTag compoundTag = (CompoundTag) t; + InputIngredient> stacks = InputIngredient.of(compoundTag.getInt("Index"), EntryIngredient.read(compoundTag.getList("Ingredient", Tag.TAG_COMPOUND))); inputs.add(InputIngredient.withType(stacks, VanillaEntryTypes.ITEM)); } return inputs; -- cgit