diff --git a/api/buildcraft/api/recipes/IFlexibleRecipeViewable.java b/api/buildcraft/api/recipes/IFlexibleRecipeViewable.java new file mode 100644 index 00000000..92a765a0 --- /dev/null +++ b/api/buildcraft/api/recipes/IFlexibleRecipeViewable.java @@ -0,0 +1,27 @@ +package buildcraft.api.recipes; + +import java.util.Collection; + +/** + * This class is intended for mods such as Not Enough Items + * in order for them to be able to look inside a recipe. + * + * It is intentionally left as a separate interface, so that + * it remains possible to register a "dynamic" flexible + * recipe which does not have static inputs and outputs. + * + * @author asie + */ +public interface IFlexibleRecipeViewable { + Object getOutput(); + + /** + * With BuildCraft's implementation (as of 6.1.3), this might + * contain either an ItemStack, a List or a FluidStack. + */ + Collection getInputs(); + + long getCraftingTime(); + + int getEnergyCost(); +} diff --git a/common/buildcraft/core/recipes/FlexibleRecipe.java b/common/buildcraft/core/recipes/FlexibleRecipe.java index 69c06f3a..31e7a0ec 100755 --- a/common/buildcraft/core/recipes/FlexibleRecipe.java +++ b/common/buildcraft/core/recipes/FlexibleRecipe.java @@ -9,6 +9,7 @@ package buildcraft.core.recipes; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import net.minecraft.block.Block; @@ -18,11 +19,12 @@ import net.minecraftforge.fluids.FluidStack; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.recipes.IFlexibleCrafter; import buildcraft.api.recipes.IFlexibleRecipe; +import buildcraft.api.recipes.IFlexibleRecipeViewable; import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; -public class FlexibleRecipe implements IFlexibleRecipe { +public class FlexibleRecipe implements IFlexibleRecipe, IFlexibleRecipeViewable { public int energyCost = 0; public long craftingTime = 0; public String id; @@ -229,4 +231,30 @@ public class FlexibleRecipe implements IFlexibleRecipe { return null; } } + + @Override + public Object getOutput() { + return output; + } + + @Override + public Collection getInputs() { + ArrayList inputs = new ArrayList(); + + inputs.addAll(inputItems); + inputs.addAll(inputItemsWithAlternatives); + inputs.addAll(inputFluids); + + return inputs; + } + + @Override + public int getEnergyCost() { + return energyCost; + } + + @Override + public long getCraftingTime() { + return craftingTime; + } } diff --git a/common/buildcraft/transport/pipes/PipeItemsStripes.java b/common/buildcraft/transport/pipes/PipeItemsStripes.java index d4a69ff3..b523a084 100755 --- a/common/buildcraft/transport/pipes/PipeItemsStripes.java +++ b/common/buildcraft/transport/pipes/PipeItemsStripes.java @@ -54,6 +54,10 @@ public class PipeItemsStripes extends Pipe implements IEnerg } public void eventHandler(PipeEventItem.DropItem event) { + if (container.getWorldObj().isRemote) { + return; + } + Position p = new Position(container.xCoord, container.yCoord, container.zCoord, event.direction); p.moveForwards(1.0); @@ -91,6 +95,10 @@ public class PipeItemsStripes extends Pipe implements IEnerg break; } + /** + * Check if there's a handler for this item type. + */ + for (IStripesHandler handler : PipeManager.stripesHandlers) { if (handler.getType() == StripesHandlerType.ITEM_USE && handler.shouldHandle(stack)) { @@ -100,7 +108,7 @@ public class PipeItemsStripes extends Pipe implements IEnerg } } } - + /** * Special, generic actions not handled by the handler. */