diff options
| author | Danielshe <shekwancheung0528@gmail.com> | 2019-09-08 17:51:58 +0800 |
|---|---|---|
| committer | Danielshe <shekwancheung0528@gmail.com> | 2019-09-08 17:51:58 +0800 |
| commit | 1b71bba8dde93522c400afb7111bd72d4fe5993e (patch) | |
| tree | bcbd0a3f4a94c34368f6b3e5303efb310e8e8e16 /src | |
| parent | fd148a6c9fb758da308193e93c091cd8f8d00809 (diff) | |
| download | RoughlyEnoughItems-1b71bba8dde93522c400afb7111bd72d4fe5993e.tar.gz RoughlyEnoughItems-1b71bba8dde93522c400afb7111bd72d4fe5993e.tar.bz2 RoughlyEnoughItems-1b71bba8dde93522c400afb7111bd72d4fe5993e.zip | |
Close #159
Diffstat (limited to 'src')
4 files changed, 12 insertions, 14 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index d906de774..26b96e243 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/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()); diff --git a/src/main/java/me/shedaniel/rei/api/Renderer.java b/src/main/java/me/shedaniel/rei/api/Renderer.java index 3f5c2f03d..5bd86e058 100644 --- a/src/main/java/me/shedaniel/rei/api/Renderer.java +++ b/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 diff --git a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index e329a51aa..850e1973a 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/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); } diff --git a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java b/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java index c84f43388..c7eba25b1 100644 --- a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java +++ b/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 { + } + } |
