Эх сурвалжийг харах

Fix #402

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 4 жил өмнө
parent
commit
44e0c35623

+ 1 - 1
RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/ImmutableLiteralText.java

@@ -76,7 +76,7 @@ public final class ImmutableLiteralText implements Text {
     
     
     @Override
     @Override
     public OrderedText asOrderedText() {
     public OrderedText asOrderedText() {
-        if (orderedText != null) {
+        if (orderedText == null) {
             orderedText = Language.getInstance().reorder(this);
             orderedText = Language.getInstance().reorder(this);
         }
         }
         return orderedText;
         return orderedText;

+ 5 - 8
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java

@@ -24,7 +24,6 @@
 package me.shedaniel.rei;
 package me.shedaniel.rei;
 
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import io.netty.buffer.Unpooled;
 import io.netty.buffer.Unpooled;
 import me.shedaniel.math.api.Executor;
 import me.shedaniel.math.api.Executor;
 import me.shedaniel.rei.server.InputSlotCrafter;
 import me.shedaniel.rei.server.InputSlotCrafter;
@@ -42,11 +41,10 @@ import net.minecraft.text.TranslatableText;
 import net.minecraft.util.Formatting;
 import net.minecraft.util.Formatting;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.Util;
 import net.minecraft.util.Util;
+import net.minecraft.util.collection.DefaultedList;
 import net.minecraft.util.math.MathHelper;
 import net.minecraft.util.math.MathHelper;
 
 
-import java.util.Comparator;
 import java.util.List;
 import java.util.List;
-import java.util.Map;
 
 
 public class RoughlyEnoughItemsNetwork implements ModInitializer {
 public class RoughlyEnoughItemsNetwork implements ModInitializer {
     
     
@@ -115,7 +113,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                 PlayerContainer playerContainer = player.playerContainer;
                 PlayerContainer playerContainer = player.playerContainer;
                 try {
                 try {
                     boolean shift = packetByteBuf.readBoolean();
                     boolean shift = packetByteBuf.readBoolean();
-                    Map<Integer, List<ItemStack>> input = Maps.newHashMap();
+                    DefaultedList<List<ItemStack>> input = DefaultedList.of();
                     int mapSize = packetByteBuf.readInt();
                     int mapSize = packetByteBuf.readInt();
                     for (int i = 0; i < mapSize; i++) {
                     for (int i = 0; i < mapSize; i++) {
                         List<ItemStack> list = Lists.newArrayList();
                         List<ItemStack> list = Lists.newArrayList();
@@ -123,7 +121,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                         for (int j = 0; j < count; j++) {
                         for (int j = 0; j < count; j++) {
                             list.add(packetByteBuf.readItemStack());
                             list.add(packetByteBuf.readItemStack());
                         }
                         }
-                        input.put(i, list);
+                        input.add(list);
                     }
                     }
                     try {
                     try {
                         InputSlotCrafter.start(category, container, player, input, shift);
                         InputSlotCrafter.start(category, container, player, input, shift);
@@ -132,13 +130,12 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                             return;
                             return;
                         PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
                         PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
                         buf.writeInt(input.size());
                         buf.writeInt(input.size());
-                        input.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).forEach(entry -> {
-                            List<ItemStack> stacks = entry.getValue();
+                        for (List<ItemStack> stacks : input) {
                             buf.writeInt(stacks.size());
                             buf.writeInt(stacks.size());
                             for (ItemStack stack : stacks) {
                             for (ItemStack stack : stacks) {
                                 buf.writeItemStack(stack);
                                 buf.writeItemStack(stack);
                             }
                             }
-                        });
+                        }
                         if (ServerSidePacketRegistry.INSTANCE.canPlayerReceive(player, NOT_ENOUGH_ITEMS_PACKET)) {
                         if (ServerSidePacketRegistry.INSTANCE.canPlayerReceive(player, NOT_ENOUGH_ITEMS_PACKET)) {
                             ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NOT_ENOUGH_ITEMS_PACKET, buf);
                             ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NOT_ENOUGH_ITEMS_PACKET, buf);
                         }
                         }

+ 1 - 1
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java

@@ -195,7 +195,7 @@ public class FluidEntryStack extends AbstractEntryStack {
         if (!get(Settings.TOOLTIP_ENABLED).get() || isEmpty())
         if (!get(Settings.TOOLTIP_ENABLED).get() || isEmpty())
             return null;
             return null;
         List<Text> toolTip = Lists.newArrayList(asFormattedText());
         List<Text> toolTip = Lists.newArrayList(asFormattedText());
-        if (!amount.isLessThan(Fraction.empty())) {
+        if (!amount.isLessThan(Fraction.empty()) && !amount.equals(IGNORE_AMOUNT)) {
             String amountTooltip = get(Settings.Fluid.AMOUNT_TOOLTIP).apply(this);
             String amountTooltip = get(Settings.Fluid.AMOUNT_TOOLTIP).apply(this);
             if (amountTooltip != null)
             if (amountTooltip != null)
                 toolTip.addAll(Stream.of(amountTooltip.split("\n")).map(LiteralText::new).collect(Collectors.toList()));
                 toolTip.addAll(Stream.of(amountTooltip.split("\n")).map(LiteralText::new).collect(Collectors.toList()));

+ 10 - 7
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java

@@ -25,17 +25,20 @@ package me.shedaniel.rei.server;
 
 
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.ints.IntList;
 import it.unimi.dsi.fastutil.ints.IntList;
+import me.shedaniel.rei.utils.CollectionUtils;
 import net.minecraft.container.Container;
 import net.minecraft.container.Container;
 import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.inventory.Inventory;
-import net.minecraft.item.Item;
+import net.minecraft.item.ItemConvertible;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.ItemStack;
 import net.minecraft.recipe.Ingredient;
 import net.minecraft.recipe.Ingredient;
 import net.minecraft.server.network.ServerPlayerEntity;
 import net.minecraft.server.network.ServerPlayerEntity;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.collection.DefaultedList;
 import net.minecraft.util.collection.DefaultedList;
 
 
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
 
 
 public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<Integer>, ContainerContext {
 public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<Integer>, ContainerContext {
     
     
@@ -50,12 +53,12 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
         this.containerInfo = containerInfo;
         this.containerInfo = containerInfo;
     }
     }
     
     
-    public static <C extends Inventory> void start(Identifier category, Container craftingContainer_1, ServerPlayerEntity player, Map<Integer, List<ItemStack>> map, boolean hasShift) {
+    public static <C extends Inventory> void start(Identifier category, Container craftingContainer_1, ServerPlayerEntity player, DefaultedList<List<ItemStack>> map, boolean hasShift) {
         ContainerInfo<? extends Container> containerInfo = Objects.requireNonNull(ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()), "Container Info does not exist on the server!");
         ContainerInfo<? extends Container> containerInfo = Objects.requireNonNull(ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()), "Container Info does not exist on the server!");
         new InputSlotCrafter<C>(craftingContainer_1, containerInfo).fillInputSlots(player, map, hasShift);
         new InputSlotCrafter<C>(craftingContainer_1, containerInfo).fillInputSlots(player, map, hasShift);
     }
     }
     
     
-    private void fillInputSlots(ServerPlayerEntity player, Map<Integer, List<ItemStack>> map, boolean hasShift) {
+    private void fillInputSlots(ServerPlayerEntity player, DefaultedList<List<ItemStack>> map, boolean hasShift) {
         this.player = player;
         this.player = player;
         this.inventoryStacks = this.containerInfo.getInventoryStacks(this);
         this.inventoryStacks = this.containerInfo.getInventoryStacks(this);
         this.gridStacks = this.containerInfo.getGridStacks(this);
         this.gridStacks = this.containerInfo.getGridStacks(this);
@@ -67,9 +70,9 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
         RecipeFinder recipeFinder = new RecipeFinder();
         RecipeFinder recipeFinder = new RecipeFinder();
         this.containerInfo.getRecipeFinderPopulator().populate(this).accept(recipeFinder);
         this.containerInfo.getRecipeFinderPopulator().populate(this).accept(recipeFinder);
         DefaultedList<Ingredient> ingredients = DefaultedList.of();
         DefaultedList<Ingredient> ingredients = DefaultedList.of();
-        map.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).forEach(entry -> {
-            ingredients.add(Ingredient.ofItems(entry.getValue().stream().map(ItemStack::getItem).toArray(Item[]::new)));
-        });
+        for (List<ItemStack> itemStacks : map) {
+            ingredients.add(Ingredient.ofItems(CollectionUtils.map(itemStacks, ItemStack::getItem).toArray(new ItemConvertible[0])));
+        }
         
         
         if (recipeFinder.findRecipe(ingredients, null)) {
         if (recipeFinder.findRecipe(ingredients, null)) {
             this.fillInputSlots(recipeFinder, ingredients, hasShift);
             this.fillInputSlots(recipeFinder, ingredients, hasShift);

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx3G
 org.gradle.jvmargs=-Xmx3G
-mod_version=5.2.5
+mod_version=5.2.6
 supported_version=1.16.2
 supported_version=1.16.2
 minecraft_version=1.16.2-rc1
 minecraft_version=1.16.2-rc1
 yarn_version=1.16.2-rc1+build.4+legacy.20w09a+build.8
 yarn_version=1.16.2-rc1+build.4+legacy.20w09a+build.8