From e6c8d55feaee1b3d6042e9a5283668d0ab29da53 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 20 Jul 2024 18:39:18 +0900 Subject: Check slots before modification --- RoughlyEnoughItems-runtime/build.gradle | 2 +- .../java/me/shedaniel/rei/server/InputSlotCrafter.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'RoughlyEnoughItems-runtime') diff --git a/RoughlyEnoughItems-runtime/build.gradle b/RoughlyEnoughItems-runtime/build.gradle index 870d044d0..7e31ac1a0 100644 --- a/RoughlyEnoughItems-runtime/build.gradle +++ b/RoughlyEnoughItems-runtime/build.gradle @@ -9,6 +9,6 @@ loom { } dependencies { - compile project(path: ':RoughlyEnoughItems-api', configuration: 'dev') + compileOnly project(path: ':RoughlyEnoughItems-api', configuration: 'dev') modCompileOnly("alexiil.mc.lib:libblockattributes-fluids:0.8.3-pre.3") } \ No newline at end of file diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java index 9e51a158d..c26068f1d 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java @@ -109,6 +109,10 @@ public class InputSlotCrafter implements RecipeGridAligner< } takenStack.setCount(1); + if (!slot.canPlace(takenStack)) { + return; + } + if (slot.getItemStack().isEmpty()) { slot.setItemStack(takenStack); } else { @@ -161,13 +165,22 @@ public class InputSlotCrafter implements RecipeGridAligner< } public int method_7371(ItemStack itemStack) { + boolean rejectedModification = false; for (int i = 0; i < inventoryStacks.size(); i++) { ItemStack itemStack1 = this.inventoryStacks.get(i).getItemStack(); if (!itemStack1.isEmpty() && areItemsEqual(itemStack, itemStack1) && !itemStack1.isDamaged() && !itemStack1.isEnchanted() && !itemStack1.hasCustomHoverName()) { - return i; + if (!this.inventoryStacks.get(i).allowModification(player)) { + rejectedModification = true; + } else { + return i; + } } } + if (rejectedModification) { + throw new IllegalStateException("Unable to take item from inventory due to slot not allowing modification! Item requested: " + itemStack); + } + return -1; } -- cgit