From deb29135ec13b735f18695deb6ffccc49a74c9db Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 21 Aug 2020 05:12:39 +0800 Subject: Fix not being able to move items to grid in survival. --- .../me/shedaniel/rei/server/InputSlotCrafter.java | 39 +++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java b/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java index 8d8eeb4cb..4447256e2 100644 --- a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java +++ b/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java @@ -59,30 +59,29 @@ public class InputSlotCrafter implements RecipeGridAligner< this.player = player; this.inventoryStacks = this.containerInfo.getInventoryStacks(this); this.gridStacks = this.containerInfo.getGridStacks(this); - if (player.isCreative()) { - player.skipPacketSlotUpdates = true; - // Return the already placed items on the grid + + player.skipPacketSlotUpdates = true; + // Return the already placed items on the grid + this.returnInputs(); + + RecipeFinder recipeFinder = new RecipeFinder(); + this.containerInfo.getRecipeFinderPopulator().populate(this).accept(recipeFinder); + DefaultedList 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))); + }); + + if (recipeFinder.findRecipe(ingredients, null)) { + this.fillInputSlots(recipeFinder, ingredients, hasShift); + } else { this.returnInputs(); - - RecipeFinder recipeFinder = new RecipeFinder(); - this.containerInfo.getRecipeFinderPopulator().populate(this).accept(recipeFinder); - DefaultedList 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))); - }); - - if (recipeFinder.findRecipe(ingredients, null)) { - this.fillInputSlots(recipeFinder, ingredients, hasShift); - } else { - this.returnInputs(); - player.skipPacketSlotUpdates = false; - this.containerInfo.markDirty(this); - throw new NotEnoughMaterialsException(); - } - player.skipPacketSlotUpdates = false; this.containerInfo.markDirty(this); + throw new NotEnoughMaterialsException(); } + + player.skipPacketSlotUpdates = false; + this.containerInfo.markDirty(this); } @Override -- cgit