Danielshe 5 years ago
parent
commit
99dba59cde

+ 1 - 1
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java

@@ -76,7 +76,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                 }
                 try {
                     InputSlotCrafter.start(category, container, player, input, shift);
-                } catch (NullPointerException e) {
+                } catch (InputSlotCrafter.NotEnoughMaterialsException e) {
                     if (!(container instanceof CraftingContainer))
                         return;
                     PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());

+ 2 - 2
src/main/java/me/shedaniel/rei/api/Renderer.java

@@ -113,7 +113,7 @@ public abstract class Renderer extends DrawableHelper {
         return fromItemStacks(stacksSupplier, stack -> renderCounts ? null : "", extraTooltipSupplier);
     }
     
-    public static ItemStackRenderer fromItemStacks(Supplier<List<ItemStack>> stacksSupplier, Function<ItemStack, String> countsFunction, @Nullable Function<ItemStack, List<String>> extraTooltipSupplier) {
+    public static ItemStackRenderer fromItemStacks(Supplier<List<ItemStack>> stacksSupplier, @Nullable Function<ItemStack, String> countsFunction, @Nullable Function<ItemStack, List<String>> extraTooltipSupplier) {
         return new ItemStackRenderer() {
             @Override
             public ItemStack getItemStack() {
@@ -124,7 +124,7 @@ public abstract class Renderer extends DrawableHelper {
             
             @Override
             protected String getCounts() {
-                return countsFunction.apply(getItemStack());
+                return countsFunction == null ? null : countsFunction.apply(getItemStack());
             }
             
             @Override

+ 2 - 7
src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java

@@ -308,13 +308,6 @@ public class EntryListWidget extends Widget {
                 Tessellator tessellator = Tessellator.getInstance();
                 BufferBuilder buffer = tessellator.getBufferBuilder();
                 double maxScroll = height;
-                //                int scrollBarHeight = MathHelper.floor((rectangle.height) * (rectangle.height) / maxScroll);
-                //                scrollBarHeight = MathHelper.clamp(scrollBarHeight, 32, rectangle.height - 8);
-                //                int minY = (int) (scroll * (rectangle.height - scrollBarHeight) / maxScroll) + rectangle.y + 1;
-                //                if (minY < this.rectangle.y + 1)
-                //                    minY = this.rectangle.y;
-                //                if (minY + scrollBarHeight >= rectangle.getMaxY())
-                //                    minY = rectangle.getMaxY() - scrollBarHeight;
                 int scrollBarHeight = MathHelper.floor((rectangle.height) * (rectangle.height) / maxScroll);
                 scrollBarHeight = MathHelper.clamp(scrollBarHeight, 32, rectangle.height - 8);
                 scrollBarHeight = (int) ((double) scrollBarHeight - Math.min((double) (this.scroll < 0.0D ? (int) (-this.scroll) : (this.scroll > (double) this.getMaxScroll() ? (int) this.scroll - this.getMaxScroll() : 0)), (double) scrollBarHeight * 0.75D));
@@ -537,6 +530,8 @@ public class EntryListWidget extends Widget {
             if (any.isPresent())
                 newList.add(any.get());
         }
+        if (newList.isEmpty())
+            return Collections.unmodifiableList(stacks);
         return Collections.unmodifiableList(newList);
     }
     

+ 7 - 4
src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java

@@ -62,11 +62,11 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
                 this.fillInputSlots(recipeFinder, ingredients, hasShift);
             } else {
                 this.returnInputs();
-                craftingContainer.sendContentUpdates();
-                throw new NullPointerException();
+                player.inventory.markDirty();
+                throw new NotEnoughMaterialsException();
             }
-            
-            craftingContainer.sendContentUpdates();
+    
+            player.inventory.markDirty();
         }
     }
     
@@ -241,4 +241,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
         return int_1;
     }
     
+    public static class NotEnoughMaterialsException extends RuntimeException {
+    }
+    
 }