Add extra getters to FlexibleRecipe for #2078
This commit is contained in:
parent
95c85ae535
commit
645deeb3ea
3 changed files with 65 additions and 2 deletions
27
api/buildcraft/api/recipes/IFlexibleRecipeViewable.java
Normal file
27
api/buildcraft/api/recipes/IFlexibleRecipeViewable.java
Normal file
|
@ -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<ItemStack> or a FluidStack.
|
||||
*/
|
||||
Collection<Object> getInputs();
|
||||
|
||||
long getCraftingTime();
|
||||
|
||||
int getEnergyCost();
|
||||
}
|
|
@ -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<T> implements IFlexibleRecipe<T> {
|
||||
public class FlexibleRecipe<T> implements IFlexibleRecipe<T>, IFlexibleRecipeViewable {
|
||||
public int energyCost = 0;
|
||||
public long craftingTime = 0;
|
||||
public String id;
|
||||
|
@ -229,4 +231,30 @@ public class FlexibleRecipe<T> implements IFlexibleRecipe<T> {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getInputs() {
|
||||
ArrayList<Object> inputs = new ArrayList<Object>();
|
||||
|
||||
inputs.addAll(inputItems);
|
||||
inputs.addAll(inputItemsWithAlternatives);
|
||||
inputs.addAll(inputFluids);
|
||||
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyCost() {
|
||||
return energyCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCraftingTime() {
|
||||
return craftingTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> 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<PipeTransportItems> 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)) {
|
||||
|
|
Loading…
Reference in a new issue