Explorar o código

Fix crash on server

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel %!s(int64=5) %!d(string=hai) anos
pai
achega
0f61446265

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx3G
-mod_version=4.6.5
+mod_version=4.6.6
 supported_version=1.16.x
 minecraft_version=1.16.1
 yarn_version=1.16.1+build.4+legacy.20w09a+build.8

+ 4 - 5
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java

@@ -27,7 +27,6 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import io.netty.buffer.Unpooled;
 import me.shedaniel.math.api.Executor;
-import me.shedaniel.rei.api.EntryStack;
 import me.shedaniel.rei.server.InputSlotCrafter;
 import net.fabricmc.api.ModInitializer;
 import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
@@ -97,15 +96,15 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                 
                 PlayerInventory inventory = player.inventory;
                 ItemStack itemStack = packetByteBuf.readItemStack();
-                EntryStack stack = EntryStack.create(itemStack.copy());
-                if (!inventory.getCursorStack().isEmpty() && EntryStack.create(inventory.getCursorStack()).equalsIgnoreAmount(stack)) {
-                    stack.setAmount(MathHelper.clamp(stack.getAmount() + inventory.getCursorStack().getCount(), 1, stack.getItemStack().getMaxCount()));
+                ItemStack stack = itemStack.copy();
+                if (!inventory.getCursorStack().isEmpty() && ItemStack.areItemsEqual(inventory.getCursorStack(), stack) && ItemStack.areTagsEqual(inventory.getCursorStack(), stack)) {
+                    stack.setCount(MathHelper.clamp(stack.getCount() + inventory.getCursorStack().getCount(), 1, stack.getMaxCount()));
                 } else if (!inventory.getCursorStack().isEmpty()) {
                     inventory.setCursorStack(ItemStack.EMPTY);
                     player.updateCursorStack();
                     return;
                 }
-                inventory.setCursorStack(stack.getItemStack().copy());
+                inventory.setCursorStack(stack.copy());
                 player.updateCursorStack();
                 ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(itemStack.copy()).writeString(player.getEntityName(), 32767));
             });

+ 3 - 0
src/main/java/me/shedaniel/rei/api/EntryStack.java

@@ -33,6 +33,8 @@ import me.shedaniel.rei.impl.EmptyEntryStack;
 import me.shedaniel.rei.impl.FluidEntryStack;
 import me.shedaniel.rei.impl.ItemEntryStack;
 import me.shedaniel.rei.utils.CollectionUtils;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.fluid.Fluid;
@@ -56,6 +58,7 @@ import java.util.Optional;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
+@Environment(EnvType.CLIENT)
 @SuppressWarnings("deprecation")
 public interface EntryStack extends TextRepresentable {