Integration Table API changes
This commit is contained in:
parent
d8070e9baa
commit
80b173db62
|
@ -16,6 +16,7 @@ public interface IIntegrationRecipe {
|
|||
int getEnergyCost();
|
||||
List<ItemStack> getExampleInput();
|
||||
List<List<ItemStack>> getExampleExpansions();
|
||||
List<ItemStack> getExampleOutput();
|
||||
boolean isValidInput(ItemStack input);
|
||||
boolean isValidExpansion(ItemStack expansion);
|
||||
ItemStack craft(ItemStack input, List<ItemStack> expansions, boolean preview);
|
||||
|
|
|
@ -10,6 +10,7 @@ import buildcraft.api.recipes.IIntegrationRecipe;
|
|||
public abstract class IntegrationRecipeBC implements IIntegrationRecipe {
|
||||
private final int energyCost, maxExpansionCount;
|
||||
private SoftReference<List<ItemStack>> exampleInputs;
|
||||
private SoftReference<List<ItemStack>> exampleOutputs;
|
||||
private SoftReference<List<List<ItemStack>>> exampleExpansions;
|
||||
|
||||
public IntegrationRecipeBC(int energyCost) {
|
||||
|
@ -22,6 +23,7 @@ public abstract class IntegrationRecipeBC implements IIntegrationRecipe {
|
|||
}
|
||||
|
||||
public abstract List<ItemStack> generateExampleInput();
|
||||
public abstract List<ItemStack> generateExampleOutput();
|
||||
public abstract List<List<ItemStack>> generateExampleExpansions();
|
||||
|
||||
@Override
|
||||
|
@ -47,6 +49,15 @@ public abstract class IntegrationRecipeBC implements IIntegrationRecipe {
|
|||
return exampleExpansions.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getExampleOutput() {
|
||||
if (exampleOutputs != null && exampleOutputs.get() != null) {
|
||||
return exampleOutputs.get();
|
||||
}
|
||||
exampleOutputs = new SoftReference<List<ItemStack>>(generateExampleOutput());
|
||||
return exampleOutputs.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumExpansionCount() {
|
||||
return maxExpansionCount;
|
||||
|
|
|
@ -13,6 +13,10 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import buildcraft.BuildCraftRobotics;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.lib.utils.NBTUtils;
|
||||
import buildcraft.core.recipes.IntegrationRecipeBC;
|
||||
|
||||
public class RobotIntegrationRecipe extends IntegrationRecipeBC {
|
||||
|
@ -29,8 +33,26 @@ public class RobotIntegrationRecipe extends IntegrationRecipeBC {
|
|||
|
||||
@Override
|
||||
public List<List<ItemStack>> generateExampleExpansions() {
|
||||
// TODO!
|
||||
return null;
|
||||
ArrayList<List<ItemStack>> list = new ArrayList<List<ItemStack>>();
|
||||
ArrayList<ItemStack> example = new ArrayList<ItemStack>();
|
||||
for (RedstoneBoardNBT nbt : RedstoneBoardRegistry.instance.getAllBoardNBTs()) {
|
||||
ItemStack stack = new ItemStack(BuildCraftRobotics.redstoneBoard);
|
||||
nbt.createBoard(NBTUtils.getItemData(stack));
|
||||
example.add(stack);
|
||||
}
|
||||
list.add(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> generateExampleOutput() {
|
||||
ArrayList<ItemStack> example = new ArrayList<ItemStack>();
|
||||
for (RedstoneBoardNBT nbt : RedstoneBoardRegistry.instance.getAllBoardNBTs()) {
|
||||
ItemStack stack = new ItemStack(BuildCraftRobotics.redstoneBoard);
|
||||
nbt.createBoard(NBTUtils.getItemData(stack));
|
||||
example.add(ItemRobot.createRobotStack(stack, 0));
|
||||
}
|
||||
return example;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,11 @@ public class AdvancedFacadeRecipe extends IntegrationRecipeBC {
|
|||
return ItemFacade.allFacades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> generateExampleOutput() {
|
||||
return ItemFacade.allFacades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<ItemStack>> generateExampleExpansions() {
|
||||
List<List<ItemStack>> list = new ArrayList<List<ItemStack>>();
|
||||
|
|
|
@ -54,6 +54,30 @@ public class GateExpansionRecipe extends IntegrationRecipeBC {
|
|||
return Collections.unmodifiableList(ItemGate.getAllGates());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> generateExampleOutput() {
|
||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||
ArrayList<IGateExpansion> exps = new ArrayList<IGateExpansion>();
|
||||
int combinations = recipes.size();
|
||||
for (IGateExpansion exp : recipes.keySet()) {
|
||||
exps.add(exp);
|
||||
}
|
||||
for (int i = 0; i < (1 << combinations); i++) {
|
||||
for (GateDefinition.GateLogic l : GateDefinition.GateLogic.VALUES) {
|
||||
for (GateDefinition.GateMaterial m : GateDefinition.GateMaterial.VALUES) {
|
||||
ItemStack s = ItemGate.makeGateItem(m, l);
|
||||
for (int j = 0; j < combinations; j++) {
|
||||
if (((i >> j) & 1) != 0) {
|
||||
ItemGate.addGateExpansion(s, exps.get(j));
|
||||
}
|
||||
}
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<ItemStack>> generateExampleExpansions() {
|
||||
ArrayList<List<ItemStack>> list = new ArrayList<List<ItemStack>>();
|
||||
|
|
Loading…
Reference in a new issue