From 924e3617059d1dae5aa60850bbf4ebbb25c327f9 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Mon, 11 Dec 2023 01:02:10 +0100 Subject: [PATCH] fix: Fix warp plate recipe fromNetwork mismatch #763 --- .../net/blay09/mods/waystones/recipe/WarpPlateRecipe.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/src/main/java/net/blay09/mods/waystones/recipe/WarpPlateRecipe.java b/shared/src/main/java/net/blay09/mods/waystones/recipe/WarpPlateRecipe.java index c95090f3..489f2fcc 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/recipe/WarpPlateRecipe.java +++ b/shared/src/main/java/net/blay09/mods/waystones/recipe/WarpPlateRecipe.java @@ -124,8 +124,9 @@ public Codec codec() { public WarpPlateRecipe fromNetwork(FriendlyByteBuf buf) { final var resultItem = buf.readItem(); final var primaryIngredient = Ingredient.fromNetwork(buf); - final NonNullList secondaryIngredients = NonNullList.createWithCapacity(4); - for (int i = 0; i < secondaryIngredients.size(); i++) { + final var secondaryCount = buf.readVarInt(); + final NonNullList secondaryIngredients = NonNullList.createWithCapacity(secondaryCount); + for (int i = 0; i < secondaryCount; i++) { secondaryIngredients.add(Ingredient.fromNetwork(buf)); } return new WarpPlateRecipe(resultItem, primaryIngredient, secondaryIngredients); @@ -135,6 +136,7 @@ public WarpPlateRecipe fromNetwork(FriendlyByteBuf buf) { public void toNetwork(FriendlyByteBuf buf, WarpPlateRecipe recipe) { buf.writeItem(recipe.resultItem); recipe.primaryIngredient.toNetwork(buf); + buf.writeVarInt(recipe.secondaryIngredients.size()); for (Ingredient ingredient : recipe.secondaryIngredients) { ingredient.toNetwork(buf); }