From c28cfa69fcf0e7c65897bf62ff8e6bcb1bff4cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 20 May 2014 00:46:14 +0200 Subject: [PATCH] Disassembler won't return buckets in recipes anymore. --- .../li/cil/oc/common/tileentity/Disassembler.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala b/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala index 20c318b41..b7be9377b 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala @@ -6,7 +6,7 @@ import li.cil.oc.api.network.Visibility import li.cil.oc.server.{PacketSender => ServerPacketSender} import li.cil.oc.util.ExtendedNBT._ import li.cil.oc.util.{ItemUtils, InventoryUtils} -import net.minecraft.item.{Item, ItemStack} +import net.minecraft.item.{ItemBucket, Item, ItemStack} import net.minecraft.item.crafting.{ShapelessRecipes, ShapedRecipes, IRecipe, CraftingManager} import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.ForgeDirection @@ -119,14 +119,18 @@ class Disassembler extends traits.Environment with traits.Inventory { case Some(recipe: ShapedOreRecipe) => resolveOreDictEntries(recipe.getInput) case Some(recipe: ShapelessOreRecipe) => resolveOreDictEntries(recipe.getInput) case _ => Iterable.empty - }).toArray + }).filter(ingredient => ingredient != null && + // Strip out buckets, because those are returned when crafting, and + // we have no way of returning the fluid only (and I can't be arsed + // to make it output fluids into fluiducts or such, sorry). + !ingredient.getItem.isInstanceOf[ItemBucket]).toArray // Avoid positive feedback loops. - if (ingredients.exists(ingredient => ingredient != null && ingredient.isItemEqual(stack))) { + if (ingredients.exists(ingredient => ingredient.isItemEqual(stack))) { return Iterable.empty } // Merge equal items for size division by output size. val merged = mutable.ArrayBuffer.empty[ItemStack] - for (ingredient <- ingredients if ingredient != null) { + for (ingredient <- ingredients) { merged.find(_.isItemEqual(ingredient)) match { case Some(entry) => entry.stackSize += ingredient.stackSize case _ => merged += ingredient.copy()