From 02d2b55d81f5a23629beb8ac1e2403af2273cfe3 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Mon, 30 May 2022 16:25:38 -0400 Subject: [PATCH] fix copying bytebuf unnecessarily --- .../fabric/recipe/FabricUnsealedIngredient.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java index a564d85b..9c423bd2 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java @@ -69,13 +69,14 @@ public class FabricUnsealedIngredient extends Ingredient { } public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { - FriendlyByteBuf copy = new FriendlyByteBuf(friendlyByteBuf.copy()); + int readerIndex = friendlyByteBuf.readerIndex(); try { - if (copy.readResourceLocation().equals(ID)) { - return new FabricUnsealedIngredient(copy.readItem()); + if (friendlyByteBuf.readResourceLocation().equals(ID)) { + return new FabricUnsealedIngredient(friendlyByteBuf.readItem()); } } catch (Exception e) { - // NO-OP, there clearly wasn't a resource location there. This is kind of a hack but ehh + // There clearly wasn't a resource location there. This is kind of a hack but ehh + friendlyByteBuf.readerIndex(readerIndex); } return null;