Moved assembly table recipes to API.

This commit is contained in:
SirSengir 2012-07-17 22:40:36 +02:00
parent 8bf5f2b703
commit 6ac8ec1db6
6 changed files with 39 additions and 42 deletions

View file

@ -15,7 +15,7 @@ import java.util.LinkedList;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
import net.minecraft.src.buildcraft.api.recipes.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.GuiAdvancedInterface;

View file

@ -9,7 +9,6 @@
package net.minecraft.src;
import java.io.File;
import java.util.LinkedList;
import java.util.TreeMap;
import net.minecraft.src.buildcraft.api.Action;
@ -22,7 +21,6 @@ import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.core.ActionMachineControl;
import net.minecraft.src.buildcraft.core.ActionMachineControl.Mode;
import net.minecraft.src.buildcraft.core.ActionRedstoneOutput;
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.BlockIndex;
import net.minecraft.src.buildcraft.core.BptItem;
import net.minecraft.src.buildcraft.core.BuildCraftConfiguration;
@ -115,8 +113,6 @@ public class BuildCraftCore {
public static Action actionOff = new ActionMachineControl(DefaultProps.ACTION_OFF, Mode.Off);
public static Action actionLoop = new ActionMachineControl(DefaultProps.ACTION_LOOP, Mode.Loop);
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public static boolean loadDefaultRecipes = true;
public static boolean forcePneumaticPower = false;
public static boolean consumeWaterSources = true;

View file

@ -10,7 +10,7 @@ package net.minecraft.src;
import net.minecraft.src.buildcraft.api.bptblocks.BptBlockInventory;
import net.minecraft.src.buildcraft.api.bptblocks.BptBlockRotateMeta;
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
import net.minecraft.src.buildcraft.api.recipes.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.ItemRedstoneChipset;
@ -66,88 +66,88 @@ public class BuildCraftSilicon {
redstoneChipset.setItemName("redstoneChipset");
// / REDSTONE CHIPSETS
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone) }, 10000,
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone) }, 10000,
new ItemStack(redstoneChipset, 1, 0)));
CoreProxy.addName(new ItemStack(redstoneChipset, 1, 0), "Redstone Chipset");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
new ItemStack(Item.ingotIron) }, 20000, new ItemStack(redstoneChipset, 1, 1)));
CoreProxy.addName(new ItemStack(redstoneChipset, 1, 1), "Redstone Iron Chipset");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
new ItemStack(Item.ingotGold) }, 40000, new ItemStack(redstoneChipset, 1, 2)));
CoreProxy.addName(new ItemStack(redstoneChipset, 1, 2), "Redstone Golden Chipset");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
new ItemStack(Item.diamond) }, 80000, new ItemStack(redstoneChipset, 1, 3)));
CoreProxy.addName(new ItemStack(redstoneChipset, 1, 3), "Redstone Diamond Chipset");
// PULSATING CHIPSETS
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.redstone),
new ItemStack(Item.enderPearl) }, 40000, new ItemStack(redstoneChipset, 2, 4)));
CoreProxy.addName(new ItemStack(redstoneChipset, 1, 4), "Pulsating Chipset");
// / REDSTONE GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 0) }, 20000,
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 0) }, 20000,
new ItemStack(BuildCraftTransport.pipeGate, 1, 0)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 0), "Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 0), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 10000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), "Autarchic Gate");
// / IRON AND GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 1),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 1),
new ItemStack(BuildCraftTransport.redPipeWire) }, 40000, new ItemStack(BuildCraftTransport.pipeGate, 1, 1)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 1), "Iron AND Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 1), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 20000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), "Autarchic Iron AND Gate");
// / IRON OR GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 1),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 1),
new ItemStack(BuildCraftTransport.redPipeWire) }, 40000, new ItemStack(BuildCraftTransport.pipeGate, 1, 2)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 2), "Iron OR Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 2), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 20000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), "Autarchic Iron OR Gate");
// / GOLD AND GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 2),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 2),
new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire) }, 80000,
new ItemStack(BuildCraftTransport.pipeGate, 1, 3)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 3), "Gold AND Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 3), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 40000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), "Autarchic Gold AND Gate");
// / GOLD OR GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 2),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 2),
new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire) }, 80000,
new ItemStack(BuildCraftTransport.pipeGate, 1, 4)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 4), "Gold OR Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 4), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 40000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), "Autarchic Gold OR Gate");
// / DIAMOND AND GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 3),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 3),
new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire),
new ItemStack(BuildCraftTransport.greenPipeWire), new ItemStack(BuildCraftTransport.yellowPipeWire) }, 160000,
new ItemStack(BuildCraftTransport.pipeGate, 1, 5)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 5), "Diamond AND Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 5), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 80000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), "Autarchic Diamond AND Gate");
// / DIAMOND OR GATES
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 3),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(redstoneChipset, 1, 3),
new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire),
new ItemStack(BuildCraftTransport.greenPipeWire), new ItemStack(BuildCraftTransport.yellowPipeWire) }, 160000,
new ItemStack(BuildCraftTransport.pipeGate, 1, 6)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 6), "Diamond OR Gate");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] {
new ItemStack(BuildCraftTransport.pipeGate, 1, 6), new ItemStack(redstoneChipset, 1, 4),
new ItemStack(redstoneChipset, 1, 1) }, 80000, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6)));
CoreProxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate");

View file

@ -14,7 +14,7 @@ import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
import net.minecraft.src.buildcraft.api.recipes.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.ItemBuildCraft;
@ -275,25 +275,25 @@ public class BuildCraftTransport {
redPipeWire = new ItemBuildCraft(DefaultProps.RED_PIPE_WIRE).setIconIndex(4 * 16 + 0);
redPipeWire.setItemName("redPipeWire");
CoreProxy.addName(redPipeWire, "Red Pipe Wire");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 1),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 1),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(redPipeWire, 8)));
bluePipeWire = new ItemBuildCraft(DefaultProps.BLUE_PIPE_WIRE).setIconIndex(4 * 16 + 1);
bluePipeWire.setItemName("bluePipeWire");
CoreProxy.addName(bluePipeWire, "Blue Pipe Wire");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 4),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 4),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(bluePipeWire, 8)));
greenPipeWire = new ItemBuildCraft(DefaultProps.GREEN_PIPE_WIRE).setIconIndex(4 * 16 + 2);
greenPipeWire.setItemName("greenPipeWire");
CoreProxy.addName(greenPipeWire, "Green Pipe Wire");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 2),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 2),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(greenPipeWire, 8)));
yellowPipeWire = new ItemBuildCraft(DefaultProps.YELLOW_PIPE_WIRE).setIconIndex(4 * 16 + 3);
yellowPipeWire.setItemName("yellowPipeWire");
CoreProxy.addName(yellowPipeWire, "Yellow Pipe Wire");
BuildCraftCore.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 11),
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 11),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(yellowPipeWire, 8)));
pipeGate = new ItemGate(DefaultProps.GATE_ID, 0).setIconIndex(2 * 16 + 3);

View file

@ -1,9 +1,13 @@
package net.minecraft.src.buildcraft.core;
package net.minecraft.src.buildcraft.api.recipes;
import java.util.LinkedList;
import net.minecraft.src.ItemStack;
public class AssemblyRecipe {
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public final ItemStack[] input;
public final ItemStack output;
public final float energy;
@ -19,15 +23,13 @@ public class AssemblyRecipe {
for (ItemStack in : input) {
if (in == null)
continue; // Optimisation, reduces calculation on a null
// ingredient
continue;
int found = 0; // Amount of ingredient found in inventory
for (ItemStack item : items) {
if (item == null)
continue; // Broken out of large if statement, increases
// clarity
continue;
if (item.isItemEqual(in))
found += item.stackSize; // Adds quantity of stack to amount
@ -39,6 +41,6 @@ public class AssemblyRecipe {
// is not enough
}
return true; // Otherwise, returns true
return true;
}
}

View file

@ -2,7 +2,6 @@ package net.minecraft.src.buildcraft.factory;
import java.util.LinkedList;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.Container;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
@ -16,7 +15,7 @@ import net.minecraft.src.mod_BuildCraftSilicon;
import net.minecraft.src.buildcraft.api.IPipeConnection;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
import net.minecraft.src.buildcraft.api.recipes.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.StackUtil;
@ -62,7 +61,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
public LinkedList<AssemblyRecipe> getPotentialOutputs() {
LinkedList<AssemblyRecipe> result = new LinkedList<AssemblyRecipe>();
for (AssemblyRecipe recipe : BuildCraftCore.assemblyRecipes) {
for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
if (recipe.canBeDone(items)) {
result.add(recipe);
}
@ -257,7 +256,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);
for (AssemblyRecipe r : BuildCraftCore.assemblyRecipes) {
for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
plannedOutput.add(r);
}
@ -381,7 +380,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
}
public void handleSelectionMessage(SelectionMessage message) {
for (AssemblyRecipe recipe : BuildCraftCore.assemblyRecipes) {
for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
if (recipe.output.itemID == message.itemID && recipe.output.getItemDamage() == message.itemDmg) {
if (message.select) {
planOutput(recipe);
@ -395,7 +394,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
}
public void sendSelectionTo(EntityPlayer player) {
for (AssemblyRecipe r : BuildCraftCore.assemblyRecipes) {
for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
SelectionMessage message = new SelectionMessage();
message.itemID = r.output.itemID;