fix copying bytebuf unnecessarily

This commit is contained in:
yrsegal@gmail.com 2022-05-30 16:25:38 -04:00
parent 4b98cb26da
commit 02d2b55d81

View file

@ -69,13 +69,14 @@ public class FabricUnsealedIngredient extends Ingredient {
} }
public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) {
FriendlyByteBuf copy = new FriendlyByteBuf(friendlyByteBuf.copy()); int readerIndex = friendlyByteBuf.readerIndex();
try { try {
if (copy.readResourceLocation().equals(ID)) { if (friendlyByteBuf.readResourceLocation().equals(ID)) {
return new FabricUnsealedIngredient(copy.readItem()); return new FabricUnsealedIngredient(friendlyByteBuf.readItem());
} }
} catch (Exception e) { } 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; return null;