Clean up Recipe API

This commit is contained in:
CovertJaguar 2013-12-01 21:57:31 -08:00
parent 09ef987875
commit cc0298ce5b
20 changed files with 495 additions and 421 deletions

View file

@ -1,14 +1,12 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile
* or run the code. It does *NOT* grant the right to redistribute this software
* or its modifications in any form, binary or source, except if expressively
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*/
package buildcraft;
import java.io.File;
import java.util.TreeMap;
@ -29,6 +27,8 @@ import net.minecraftforge.fluids.IFluidBlock;
import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.BlockIndex;
import buildcraft.core.BlockSpring;
import buildcraft.core.BuildCraftConfiguration;
@ -64,6 +64,7 @@ import buildcraft.core.triggers.TriggerInventoryLevel;
import buildcraft.core.triggers.TriggerMachine;
import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.Localization;
import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.transport.triggers.TriggerRedstoneInput;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
@ -81,61 +82,47 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)")
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftCore {
public static enum RenderMode {
Full, NoDynamic
};
public static RenderMode render = RenderMode.Full;
public static boolean debugMode = false;
public static boolean modifyWorld = false;
public static boolean trackNetworkUsage = false;
public static boolean colorBlindMode = false;
public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks.
public static int itemLifespan = 1200;
public static int updateFactor = 10;
public static long longUpdateFactor = 40;
public static BuildCraftConfiguration mainConfiguration;
public static TreeMap<BlockIndex, PacketUpdate> bufferedDescriptions = new TreeMap<BlockIndex, PacketUpdate>();
public static final int trackedPassiveEntityId = 156;
public static boolean continuousCurrentModel;
public static Block springBlock;
public static Item woodenGearItem;
public static Item stoneGearItem;
public static Item ironGearItem;
public static Item goldGearItem;
public static Item diamondGearItem;
public static Item wrenchItem;
@SideOnly(Side.CLIENT)
public static Icon redLaserTexture;
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
public static Icon blueLaserTexture;
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
public static Icon stripesLaserTexture;
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
public static Icon transparentTexture;
@SideOnly(Side.CLIENT)
public static IIconProvider iconProvider;
@SideOnly(Side.CLIENT)
public static IIconProvider iconProvider;
public static int blockByEntityModel;
public static int legacyPipeModel;
public static int markerModel;
public static int oilModel;
public static BCTrigger triggerMachineActive = new TriggerMachine(DefaultProps.TRIGGER_MACHINE_ACTIVE, true);
public static BCTrigger triggerMachineInactive = new TriggerMachine(DefaultProps.TRIGGER_MACHINE_INACTIVE, false);
public static BCTrigger triggerEmptyInventory = new TriggerInventory(DefaultProps.TRIGGER_EMPTY_INVENTORY, TriggerInventory.State.Empty);
@ -148,34 +135,32 @@ public class BuildCraftCore {
public static BCTrigger triggerFullFluid = new TriggerFluidContainer(DefaultProps.TRIGGER_FULL_LIQUID, TriggerFluidContainer.State.Full);
public static BCTrigger triggerRedstoneActive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_ACTIVE, true);
public static BCTrigger triggerRedstoneInactive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_INACTIVE, false);
public static BCTrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25);
public static BCTrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50);
public static BCTrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75);
public static BCAction actionRedstone = new ActionRedstoneOutput(DefaultProps.ACTION_REDSTONE);
public static BCAction actionOn = new ActionMachineControl(DefaultProps.ACTION_ON, Mode.On);
public static BCAction actionOff = new ActionMachineControl(DefaultProps.ACTION_OFF, Mode.Off);
public static BCAction actionLoop = new ActionMachineControl(DefaultProps.ACTION_LOOP, Mode.Loop);
public static boolean loadDefaultRecipes = true;
public static boolean forcePneumaticPower = true;
public static boolean consumeWaterSources = false;
public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length];
@Instance("BuildCraft|Core")
public static BuildCraftCore instance;
@EventHandler
@EventHandler
public void loadConfiguration(FMLPreInitializationEvent evt) {
BCLog.initLog();
BuildcraftRecipes.assemblyTable = AssemblyRecipeManager.INSTANCE;
BuildcraftRecipes.refinery = RefineryRecipeManager.INSTANCE;
mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf"));
try {
mainConfiguration.load();
Property updateCheck = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "update.check", true);
updateCheck.comment = "set to true for version check on startup";
if (updateCheck.getBoolean(true)) {
@ -233,7 +218,7 @@ public class BuildCraftCore {
consumeWaterSources = consumeWater.getBoolean(consumeWaterSources);
consumeWater.comment = "set to true if the Pump should consume water";
if(BuildCraftCore.modifyWorld) {
if (BuildCraftCore.modifyWorld) {
springBlock = new BlockSpring(springId.getInt()).setUnlocalizedName("eternalSpring");
CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);
}
@ -252,7 +237,7 @@ public class BuildCraftCore {
LanguageRegistry.addName(ironGearItem, "Iron Gear");
CoreProxy.proxy.registerItem(ironGearItem);
OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));
goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem");
LanguageRegistry.addName(goldGearItem, "Gold Gear");
CoreProxy.proxy.registerItem(goldGearItem);
@ -266,7 +251,7 @@ public class BuildCraftCore {
Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false);
colorBlindProp.comment = "Set to true to enable alternate textures";
colorBlindMode = colorBlindProp.getBoolean(false);
MinecraftForge.EVENT_BUS.register(this);
} finally {
@ -276,8 +261,8 @@ public class BuildCraftCore {
}
}
@EventHandler
public void initialize(FMLInitializationEvent evt) {
@EventHandler
public void initialize(FMLInitializationEvent evt) {
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
ActionManager.registerActionProvider(new DefaultActionProvider());
@ -321,29 +306,29 @@ public class BuildCraftCore {
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandBuildCraft());
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Pre event){
public void textureHook(TextureStitchEvent.Pre event) {
if (event.map.textureType == 1) {
iconProvider = new CoreIconProvider();
iconProvider.registerIcons(event.map);
ActionTriggerIconProvider.INSTANCE.registerIcons(event.map);
} else if (event.map.textureType == 0) {
BuildCraftCore.redLaserTexture = event.map.registerIcon("buildcraft:blockRedLaser");
BuildCraftCore.blueLaserTexture = event.map.registerIcon("buildcraft:blockBlueLaser");
BuildCraftCore.stripesLaserTexture = event.map.registerIcon("buildcraft:blockStripesLaser");
BuildCraftCore.transparentTexture = event.map.registerIcon("buildcraft:blockTransparentLaser");
BuildCraftCore.redLaserTexture = event.map.registerIcon("buildcraft:blockRedLaser");
BuildCraftCore.blueLaserTexture = event.map.registerIcon("buildcraft:blockBlueLaser");
BuildCraftCore.stripesLaserTexture = event.map.registerIcon("buildcraft:blockStripesLaser");
BuildCraftCore.transparentTexture = event.map.registerIcon("buildcraft:blockTransparentLaser");
}
}
public void loadRecipes() {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Item.ingotIron, 'G', stoneGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Item.ingotIron, 'G', stoneGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood");
CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G',
woodenGearItem);
@ -351,9 +336,9 @@ public class BuildCraftCore {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Item.ingotGold, 'G', ironGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Item.diamond, 'G', goldGearItem);
}
@EventHandler
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
InterModComms.processIMC(event);
}
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
InterModComms.processIMC(event);
}
}

View file

@ -9,7 +9,8 @@ package buildcraft;
import buildcraft.api.fuels.IronEngineCoolant;
import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.recipes.RefineryRecipes;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.BlockIndex;
import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
@ -81,7 +82,7 @@ public class BuildCraftEnergy {
public static Item bucketFuel;
public static Item fuel;
public static boolean canOilBurn;
public static double oilWellScalar;
public static double oilWellScalar = 1.0;
public static TreeMap<BlockIndex, Integer> saturationStored = new TreeMap<BlockIndex, Integer>();
public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_BLUE_ENGINE_HEAT, EnergyStage.BLUE, "buildcraft.engine.stage.blue");
public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_GREEN_ENGINE_HEAT, EnergyStage.GREEN, "buildcraft.engine.stage.green");
@ -207,7 +208,7 @@ public class BuildCraftEnergy {
BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel);
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
RefineryRecipes.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1);
BuildcraftRecipes.refinery.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1);
// Iron Engine Fuels
// IronEngineFuel.addFuel("lava", 1, 20000);

View file

@ -9,7 +9,8 @@ package buildcraft;
import buildcraft.api.bptblocks.BptBlockInventory;
import buildcraft.api.bptblocks.BptBlockRotateMeta;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.ItemRedstoneChipset;
@ -141,95 +142,65 @@ public class BuildCraftSilicon {
new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6)});
// / REDSTONE CHIPSETS
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.redstone)}, 10000, new ItemStack(redstoneChipset, 1, 0)));
CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 0), "Redstone Chipset");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)}, 20000,
new ItemStack(redstoneChipset, 1, 1)));
CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 1), "Redstone Iron Chipset");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.redstone), new ItemStack(Item.ingotGold)}, 40000,
new ItemStack(redstoneChipset, 1, 2)));
CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 2), "Redstone Golden Chipset");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.redstone), new ItemStack(Item.diamond)}, 80000,
new ItemStack(redstoneChipset, 1, 3)));
CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 3), "Redstone Diamond Chipset");
// PULSATING CHIPSETS
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.redstone), new ItemStack(Item.enderPearl)}, 40000,
new ItemStack(redstoneChipset, 2, 4)));
CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 4), "Pulsating Chipset");
// / REDSTONE GATES
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(redstoneChipset, 1, 0)}, 20000, new ItemStack(
BuildCraftTransport.pipeGate, 1, 0)));
BuildcraftRecipes.assemblyTable.addRecipe(10000, new ItemStack(redstoneChipset, 1, 0), Item.redstone);
BuildcraftRecipes.assemblyTable.addRecipe(20000, new ItemStack(redstoneChipset, 1, 1), Item.redstone, Item.ingotIron);
BuildcraftRecipes.assemblyTable.addRecipe(40000, new ItemStack(redstoneChipset, 1, 2), Item.redstone, Item.ingotGold);
BuildcraftRecipes.assemblyTable.addRecipe(80000, new ItemStack(redstoneChipset, 1, 3), Item.redstone, Item.diamond);
BuildcraftRecipes.assemblyTable.addRecipe(40000, new ItemStack(redstoneChipset, 2, 4), Item.redstone, Item.enderPearl);
// / REDSTONE GATES
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 0), "Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), "Autarchic Gate");
// / IRON AND GATES
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(redstoneChipset, 1, 1),
new ItemStack(BuildCraftTransport.redPipeWire)}, 40000, new ItemStack(BuildCraftTransport.pipeGate, 1, 1)));
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 1), "Iron AND Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), "Autarchic Iron AND Gate");
// / IRON OR GATES
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(redstoneChipset, 1, 1),
new ItemStack(BuildCraftTransport.redPipeWire)}, 40000, new ItemStack(BuildCraftTransport.pipeGate, 1, 2)));
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 2), "Iron OR Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), "Autarchic Iron OR Gate");
// / GOLD AND GATES
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 3), "Gold AND Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), "Autarchic Gold AND Gate");
// / GOLD OR GATES
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 4), "Gold OR Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), "Autarchic Gold OR Gate");
// / DIAMOND AND GATES
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 5), "Diamond AND Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), "Autarchic Diamond AND Gate");
// / DIAMOND OR GATES
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 2), "Iron OR Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 4), "Gold OR Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 6), "Diamond OR Gate");
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.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), "Autarchic Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), "Autarchic Iron AND Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), "Autarchic Gold AND Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), "Autarchic Diamond AND Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), "Autarchic Iron OR Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), "Autarchic Gold OR Gate");
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate");
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGate, 1, 0), 20000, new ItemStack(redstoneChipset, 1, 0));
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGate, 1, 1), 40000, new ItemStack(redstoneChipset, 1, 1), new ItemStack(BuildCraftTransport.redPipeWire));
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGate, 1, 2), 40000, new ItemStack(redstoneChipset, 1, 1), new ItemStack(BuildCraftTransport.redPipeWire));
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), 10000, new ItemStack(BuildCraftTransport.pipeGate, 1, 0), new ItemStack(redstoneChipset, 1, 4), new ItemStack(redstoneChipset, 1, 1));
//
//
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), 20000, new ItemStack(BuildCraftTransport.pipeGate, 1, 1), new ItemStack(redstoneChipset, 1, 4), new ItemStack(redstoneChipset, 1, 1));
//
//
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), 20000, new ItemStack(BuildCraftTransport.pipeGate, 1, 2), new ItemStack(redstoneChipset, 1, 4), new ItemStack(redstoneChipset, 1, 1));
//
// // / GOLD AND GATES
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGate, 1, 3), 80000, new ItemStack(redstoneChipset, 1, 2), new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire));
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
//
// // / GOLD OR GATES
// BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack[]{new ItemStack(redstoneChipset, 1, 2), new ItemStack(BuildCraftTransport.redPipeWire), new ItemStack(BuildCraftTransport.bluePipeWire)}, 80000, new ItemStack( BuildCraftTransport.pipeGate, 1, 4)));
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
//
// // / DIAMOND AND GATES
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
//
// // / DIAMOND OR GATES
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
// BuildcraftRecipes.assemblyTable.addRecipe(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)));
}
@EventHandler
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
InterModComms.processIMC(event);
}
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
InterModComms.processIMC(event);
}
}

View file

@ -10,7 +10,8 @@ package buildcraft;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.api.transport.IExtractionHandler;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.PipeManager;
@ -450,13 +451,13 @@ public class BuildCraftTransport {
// Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now
try {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
BuildcraftRecipes.assemblyTable.addRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron));
BuildcraftRecipes.assemblyTable.addRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron));
BuildcraftRecipes.assemblyTable.addRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron));
BuildcraftRecipes.assemblyTable.addRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron));
BuildcraftRecipes.assemblyTable.addRecipe(1000, new ItemStack(plugItem, 8), new ItemStack(pipeStructureCobblestone));
} catch (Error error) {
BCLog.logErrorAPI("Buildcraft", error, AssemblyRecipe.class);
BCLog.logErrorAPI("Buildcraft", error, BuildcraftRecipes.class);
}
}

View file

@ -1,23 +0,0 @@
package buildcraft.api.inventory;
import net.minecraftforge.common.ForgeDirection;
public interface ISecuredInventory {
/**
* @param name
* @return true if the user/player with the given name has access permissions on this machine.
*/
boolean canAccess(String name);
/**
* Informs the inventory with whose permissions the next item or liquid transaction will be performed. It is up to the inventory to determine the effect.
*
* @param orientation
* Orientation the transaction will be performed from.
* @param name
* Name of the user/player who owns the transaction.
*/
void prepareTransaction(ForgeDirection orientation, String name);
}

View file

@ -1,23 +0,0 @@
package buildcraft.api.inventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
public interface ISelectiveInventory extends ISpecialInventory {
/**
* Requests specified items to be extracted from the inventory
*
* @param desired
* Array which can contain ItemStacks, Items, or classes describing the type of item accepted or excluded.
* @param exclusion
* If true desired items are not eligible for returning.
* @param doRemove
* If false no actual extraction may occur.
* @param from
* Orientation the ItemStack is requested from.
* @param maxItemCount
* Maximum amount of items to extract (spread over all returned item stacks)
* @return Array of item stacks extracted from the inventory
*/
ItemStack[] extractItem(Object[] desired, boolean exclusion, boolean doRemove, ForgeDirection from, int maxItemCount);
}

View file

@ -1,88 +0,0 @@
package buildcraft.api.recipes;
import java.util.ArrayList;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class AssemblyRecipe {
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public final Object[] input;
public final ItemStack output;
public final float energy;
public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) {
this.input = input;
this.output = output;
this.energy = energy;
}
/**
* This version of AssemblyRecipe supports the OreDictionary
*
* @param input Object... containing either an ItemStack, or a paired string
* and integer(ex: "dyeBlue", 1)
* @param energy MJ cost to produce
* @param output resulting ItemStack
*/
public AssemblyRecipe(int energy, ItemStack output, Object... input) {
this.output = output;
this.energy = energy;
this.input = input;
for (int i = 0; i < input.length; i++) {
if (input[i] instanceof String) {
input[i] = OreDictionary.getOres((String) input[i]);
}
}
}
public boolean canBeDone(ItemStack... items) {
for (int i = 0; i < input.length; i++) {
if (input[i] == null)
continue;
if (input[i] instanceof ItemStack) {
ItemStack requirement = (ItemStack) input[i];
int found = 0; // Amount of ingredient found in inventory
int expected = requirement.stackSize;
for (ItemStack item : items) {
if (item == null)
continue;
if (item.isItemEqual(requirement))
found += item.stackSize; // Adds quantity of stack to amount found
}
// Return false if the amount of ingredient found
// is not enough
if (found < expected)
return false;
} else if (input[i] instanceof ArrayList) {
ArrayList<ItemStack> oreList = (ArrayList<ItemStack>) input[i];
int found = 0; // Amount of ingredient found in inventory
int expected = (Integer) input[i++ + 1];
for (ItemStack item : items) {
if (item == null)
continue;
for (ItemStack oreItem : oreList) {
if (OreDictionary.itemMatches(oreItem, item, true)) {
found += item.stackSize;
break;
}
}
}
// Return false if the amount of ingredient found
// is not enough
if (found < expected)
return false;
}
}
return true;
}
}

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.recipes;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public final class BuildcraftRecipes {
public static IAssemblyRecipeManager assemblyTable;
public static IRefineryRecipeManager refinery;
private BuildcraftRecipes() {
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.recipes;
import java.util.List;
import net.minecraft.item.ItemStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IAssemblyRecipeManager {
public static interface IAssemblyRecipe {
ItemStack getOutput();
Object[] getInputs();
double getEnergyCost();
}
/**
* Add an Assembly Table recipe.
*
* @param input Object... containing either an ItemStack, or a paired string
* and integer(ex: "dyeBlue", 1)
* @param energy MJ cost to produce
* @param output resulting ItemStack
*/
void addRecipe(double energyCost, ItemStack output, Object... input);
List<? extends IAssemblyRecipe> getRecipes();
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.recipes;
import java.util.SortedSet;
import net.minecraftforge.fluids.FluidStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IRefineryRecipeManager {
void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay);
void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay);
SortedSet<? extends IRefineryRecipe> getRecipes();
IRefineryRecipe findRefineryRecipe(FluidStack ingredient1, FluidStack ingredient2);
public static interface IRefineryRecipe {
FluidStack getIngredient1();
FluidStack getIngredient2();
FluidStack getResult();
int getEnergyCost();
int getTimeRequired();
}
}

View file

@ -1,3 +1,3 @@
@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|recipes")
@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|recipes")
package buildcraft.api.recipes;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,148 @@
package buildcraft.core.recipes;
import buildcraft.api.recipes.IAssemblyRecipeManager;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
import buildcraft.core.inventory.Transactor;
import buildcraft.core.inventory.filters.ArrayStackFilter;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
public class AssemblyRecipeManager implements IAssemblyRecipeManager {
public static final AssemblyRecipeManager INSTANCE = new AssemblyRecipeManager();
private List<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
@Override
public void addRecipe(double energyCost, ItemStack output, Object... input) {
assemblyRecipes.add(new AssemblyRecipe(output, energyCost, input));
}
@Override
public List<AssemblyRecipe> getRecipes() {
return assemblyRecipes;
}
public static class AssemblyRecipe implements IAssemblyRecipe {
public final ItemStack output;
public final double energyCost;
private final Object[] originalInput;
private final Object[] processedInput;
public AssemblyRecipe(ItemStack output, double energyCost, Object... inputs) {
this.output = output.copy();
this.energyCost = energyCost;
this.originalInput = inputs;
processedInput = new Object[inputs.length];
for (int i = 0; i < inputs.length; i++) {
if (inputs[i] instanceof String)
processedInput[i] = OreDictionary.getOres((String) inputs[i]);
if (inputs[i] instanceof Item)
processedInput[i] = new ItemStack((Item) inputs[i]);
else
processedInput[i] = inputs[i];
}
}
@Override
public ItemStack getOutput() {
return output.copy();
}
@Override
public Object[] getInputs() {
return originalInput;
}
@Override
public double getEnergyCost() {
return energyCost;
}
public boolean canBeDone(IInventory inv) {
for (int i = 0; i < processedInput.length; i++) {
if (processedInput[i] == null)
continue;
if (processedInput[i] instanceof ItemStack) {
ItemStack requirement = (ItemStack) processedInput[i];
int found = 0; // Amount of ingredient found in inventory
int expected = requirement.stackSize;
for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
ItemStack item = slot.getStackInSlot();
if (item == null)
continue;
if (item.isItemEqual(requirement))
found += item.stackSize; // Adds quantity of stack to amount found
if (found >= expected)
break;
}
// Return false if the amount of ingredient found
// is not enough
if (found < expected)
return false;
} else if (processedInput[i] instanceof List) {
List<ItemStack> oreList = (List<ItemStack>) processedInput[i];
int found = 0; // Amount of ingredient found in inventory
int expected = (Integer) processedInput[i++ + 1];
for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
ItemStack item = slot.getStackInSlot();
if (item == null)
continue;
for (ItemStack oreItem : oreList) {
if (OreDictionary.itemMatches(oreItem, item, true)) {
found += item.stackSize;
break;
}
}
if (found >= expected)
break;
}
// Return false if the amount of ingredient found
// is not enough
if (found < expected)
return false;
}
}
return true;
}
public void useItems(IInventory inv) {
ITransactor tran = Transactor.getTransactorFor(inv);
Object[] input = processedInput;
for (int i = 0; i < input.length; i++) {
if (input[i] instanceof ItemStack) {
ItemStack requirement = (ItemStack) input[i];
for (int num = 0; num < requirement.stackSize; num++) {
tran.remove(new ArrayStackFilter(requirement), ForgeDirection.UNKNOWN, true);
}
} else if (input[i] instanceof List) {
List<ItemStack> oreList = (List<ItemStack>) input[i];
int required = (Integer) input[i + 1];
for (ItemStack ore : oreList) {
for (int num = 0; num < required; num++) {
if (tran.remove(new ArrayStackFilter(ore), ForgeDirection.UNKNOWN, true) != null)
required--;
}
if (required <= 0)
break;
}
}
}
}
}
}

View file

@ -5,33 +5,40 @@
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.recipes;
package buildcraft.core.recipes;
import buildcraft.api.recipes.IRefineryRecipeManager;
import buildcraft.api.recipes.IRefineryRecipeManager.IRefineryRecipe;
import com.google.common.base.Objects;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;
import net.minecraftforge.fluids.FluidStack;
public final class RefineryRecipes {
public final class RefineryRecipeManager implements IRefineryRecipeManager {
private static SortedSet<Recipe> recipes = new TreeSet<Recipe>();
public static final RefineryRecipeManager INSTANCE = new RefineryRecipeManager();
private SortedSet<RefineryRecipe> recipes = new TreeSet<RefineryRecipe>();
public static void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay) {
@Override
public void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay) {
addRecipe(ingredient, null, result, energy, delay);
}
public static void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
Recipe recipe = new Recipe(ingredient1, ingredient2, result, energy, delay);
@Override
public void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
RefineryRecipe recipe = new RefineryRecipe(ingredient1, ingredient2, result, energy, delay);
recipes.add(recipe);
}
public static SortedSet<Recipe> getRecipes() {
@Override
public SortedSet<RefineryRecipe> getRecipes() {
return Collections.unmodifiableSortedSet(recipes);
}
public static Recipe findRefineryRecipe(FluidStack liquid1, FluidStack liquid2) {
for (Recipe recipe : recipes) {
@Override
public RefineryRecipe findRefineryRecipe(FluidStack liquid1, FluidStack liquid2) {
for (RefineryRecipe recipe : recipes) {
if (recipe.matches(liquid1, liquid2))
return recipe;
}
@ -39,25 +46,25 @@ public final class RefineryRecipes {
return null;
}
private RefineryRecipes() {
private RefineryRecipeManager() {
}
public static final class Recipe implements Comparable<Recipe> {
public static final class RefineryRecipe implements IRefineryRecipe, Comparable<RefineryRecipe> {
public final FluidStack ingredient1;
public final FluidStack ingredient2;
public final FluidStack result;
public final int energy;
public final int delay;
public final int energyCost;
public final int timeRequired;
private Recipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
private RefineryRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
if (ingredient1 == null)
throw new IllegalArgumentException("First Ingredient cannot be null!");
this.ingredient1 = ingredient1;
this.ingredient2 = ingredient2;
this.result = result;
this.energy = energy;
this.delay = delay;
this.energyCost = energy;
this.timeRequired = delay;
}
public boolean matches(FluidStack liquid1, FluidStack liquid2) {
@ -90,7 +97,7 @@ public final class RefineryRecipes {
// We consider non-null < null in order that one-ingredient recipe is checked after
// the failure of matching two-ingredient recipes which include that liquid.
@Override
public int compareTo(Recipe other) {
public int compareTo(RefineryRecipe other) {
if (other == null)
return -1;
else if (ingredient1.getFluid() != other.ingredient1.getFluid())
@ -112,9 +119,9 @@ public final class RefineryRecipes {
// equals() should be consistent with compareTo().
@Override
public boolean equals(Object obj) {
return obj instanceof Recipe
&& Objects.equal(ingredient1, ((Recipe) obj).ingredient1)
&& Objects.equal(ingredient2, ((Recipe) obj).ingredient2);
return obj instanceof RefineryRecipe
&& Objects.equal(ingredient1, ((RefineryRecipe) obj).ingredient1)
&& Objects.equal(ingredient2, ((RefineryRecipe) obj).ingredient2);
}
// hashCode() should be overridden because equals() was overridden.
@ -122,5 +129,30 @@ public final class RefineryRecipes {
public int hashCode() {
return Objects.hashCode(ingredient1, ingredient2);
}
@Override
public FluidStack getIngredient1() {
return ingredient1;
}
@Override
public FluidStack getIngredient2() {
return ingredient2;
}
@Override
public FluidStack getResult() {
return result;
}
@Override
public int getEnergyCost() {
return energyCost;
}
@Override
public int getTimeRequired() {
return timeRequired;
}
}
}

View file

@ -14,8 +14,8 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import buildcraft.api.recipes.RefineryRecipes;
import buildcraft.api.recipes.RefineryRecipes.Recipe;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.recipes.RefineryRecipeManager.RefineryRecipe;
import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.fluids.SingleUseTank;
@ -130,7 +130,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe
isActive = false;
Recipe currentRecipe = RefineryRecipes.findRefineryRecipe(tank1.getFluid(), tank2.getFluid());
RefineryRecipe currentRecipe = RefineryRecipeManager.INSTANCE.findRefineryRecipe(tank1.getFluid(), tank2.getFluid());
if (currentRecipe == null) {
decreaseAnimation();
@ -149,16 +149,16 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe
isActive = true;
if (powerHandler.getEnergyStored() >= currentRecipe.energy) {
if (powerHandler.getEnergyStored() >= currentRecipe.energyCost) {
increaseAnimation();
} else {
decreaseAnimation();
}
if (!time.markTimeIfDelay(worldObj, currentRecipe.delay))
if (!time.markTimeIfDelay(worldObj, currentRecipe.timeRequired))
return;
float energyUsed = powerHandler.useEnergy(currentRecipe.energy, currentRecipe.energy, true);
float energyUsed = powerHandler.useEnergy(currentRecipe.energyCost, currentRecipe.energyCost, true);
if (energyUsed != 0) {
if (consumeInput(currentRecipe.ingredient1) && consumeInput(currentRecipe.ingredient2)) {

View file

@ -1,16 +1,14 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.factory.gui;
import buildcraft.api.recipes.RefineryRecipes;
import buildcraft.api.recipes.RefineryRecipes.Recipe;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.recipes.RefineryRecipeManager.RefineryRecipe;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface;
import buildcraft.core.utils.StringUtils;
@ -89,7 +87,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
}
} else {
TileRefinery ref = (TileRefinery) this.tile;
if (position == 0)
container.setFilter(position, ref.tank1.getFluidType());
else if (position == 1)
@ -116,7 +114,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
liquid1 = new FluidStack(filter1, FluidContainerRegistry.BUCKET_VOLUME);
}
Recipe recipe = RefineryRecipes.findRefineryRecipe(liquid0, liquid1);
RefineryRecipe recipe = RefineryRecipeManager.INSTANCE.findRefineryRecipe(liquid0, liquid1);
if (recipe != null) {
((FluidSlot) slots[2]).fluid = recipe.result.getFluid();
@ -124,5 +122,4 @@ public class GuiRefinery extends GuiAdvancedInterface {
((FluidSlot) slots[2]).fluid = null;
}
}
}

View file

@ -1,22 +1,20 @@
package buildcraft.silicon;
import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.api.power.ILaserTarget;
import buildcraft.api.gates.IAction;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.DefaultProps;
import buildcraft.core.IMachine;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.StackHelper;
import buildcraft.core.inventory.Transactor;
import buildcraft.core.inventory.filters.ArrayStackFilter;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketNBT;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
import cpw.mods.fml.common.FMLCommonHandler;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -31,11 +29,11 @@ import net.minecraftforge.common.ForgeDirection;
public class TileAssemblyTable extends TileEntity implements IMachine, IInventory, ILaserTarget {
ItemStack[] items = new ItemStack[12];
LinkedHashSet<AssemblyRecipe> plannedOutput = new LinkedHashSet<AssemblyRecipe>();
Set<AssemblyRecipe> plannedOutput = new LinkedHashSet<AssemblyRecipe>();
public AssemblyRecipe currentRecipe;
private float currentRequiredEnergy = 0;
private double currentRequiredEnergy = 0;
private float energyStored = 0;
private float[] recentEnergy = new float[20];
private double[] recentEnergy = new double[20];
private int tick = 0;
private int recentEnergyAverage;
@ -60,13 +58,12 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
}
public LinkedList<AssemblyRecipe> getPotentialOutputs() {
LinkedList<AssemblyRecipe> result = new LinkedList<AssemblyRecipe>();
public List<AssemblyRecipe> getPotentialOutputs() {
List<AssemblyRecipe> result = new LinkedList<AssemblyRecipe>();
for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
if (recipe.canBeDone(items)) {
for (AssemblyRecipe recipe : AssemblyRecipeManager.INSTANCE.getRecipes()) {
if (recipe.canBeDone(this))
result.add(recipe);
}
}
return result;
@ -86,19 +83,19 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
if (currentRecipe == null)
return;
if (!currentRecipe.canBeDone(items)) {
if (!currentRecipe.canBeDone(this)) {
setNextCurrentRecipe();
if (currentRecipe == null)
return;
}
if (energyStored >= currentRecipe.energy) {
if (energyStored >= currentRecipe.getEnergyCost()) {
energyStored = 0;
if (currentRecipe.canBeDone(items)) {
if (currentRecipe.canBeDone(this)) {
useItems();
currentRecipe.useItems(this);
ItemStack remaining = currentRecipe.output.copy();
remaining.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining);
@ -118,31 +115,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
}
private void useItems() {
ITransactor tran = Transactor.getTransactorFor(this);
Object[] input = currentRecipe.input;
for (int i = 0; i < input.length; i++) {
if (input[i] instanceof ItemStack) {
ItemStack requirement = (ItemStack) input[i];
for (int num = 0; num < requirement.stackSize; num++) {
tran.remove(new ArrayStackFilter(requirement), ForgeDirection.UNKNOWN, true);
}
} else if (input[i] instanceof ArrayList) {
ArrayList<ItemStack> oreList = (ArrayList<ItemStack>) input[i];
int required = (Integer) input[i + 1];
for (ItemStack ore : oreList) {
for (int num = 0; num < required; num++) {
if (tran.remove(new ArrayStackFilter(ore), ForgeDirection.UNKNOWN, true) != null)
required--;
}
if (required <= 0)
break;
}
}
}
}
public float getCompletionRatio(float ratio) {
public double getCompletionRatio(float ratio) {
if (currentRecipe == null)
return 0;
else if (energyStored >= currentRequiredEnergy)
@ -214,21 +187,21 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
Utils.readStacksFromNBT(nbttagcompound, "items", items);
Utils.readStacksFromNBT(nbt, "items", items);
energyStored = nbttagcompound.getFloat("energyStored");
energyStored = nbt.getFloat("energyStored");
NBTTagList list = nbttagcompound.getTagList("planned");
NBTTagList list = nbt.getTagList("planned");
for (int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound cpt = (NBTTagCompound) list.tagAt(i);
ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);
for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
for (AssemblyRecipe r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
plannedOutput.add(r);
break;
@ -236,8 +209,8 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
}
if (nbttagcompound.hasKey("recipe")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("recipe"));
if (nbt.hasKey("recipe")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("recipe"));
for (AssemblyRecipe r : plannedOutput) {
if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
@ -249,12 +222,12 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
Utils.writeStacksToNBT(nbttagcompound, "items", items);
Utils.writeStacksToNBT(nbt, "items", items);
nbttagcompound.setFloat("energyStored", energyStored);
nbt.setFloat("energyStored", energyStored);
NBTTagList list = new NBTTagList();
@ -264,12 +237,12 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
list.appendTag(cpt);
}
nbttagcompound.setTag("planned", list);
nbt.setTag("planned", list);
if (currentRecipe != null) {
NBTTagCompound recipe = new NBTTagCompound();
currentRecipe.output.writeToNBT(recipe);
nbttagcompound.setTag("recipe", recipe);
nbt.setTag("recipe", recipe);
}
}
@ -287,7 +260,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
private void setCurrentRecipe(AssemblyRecipe recipe) {
this.currentRecipe = recipe;
if (recipe != null) {
this.currentRequiredEnergy = recipe.energy;
this.currentRequiredEnergy = recipe.getEnergyCost();
} else {
this.currentRequiredEnergy = 0;
}
@ -321,14 +294,14 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
for (AssemblyRecipe recipe : plannedOutput) {
if (recipe == currentRecipe) {
takeNext = true;
} else if (takeNext && recipe.canBeDone(items)) {
} else if (takeNext && recipe.canBeDone(this)) {
setCurrentRecipe(recipe);
return;
}
}
for (AssemblyRecipe recipe : plannedOutput) {
if (recipe.canBeDone(items)) {
if (recipe.canBeDone(this)) {
setCurrentRecipe(recipe);
return;
}
@ -338,7 +311,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
public void handleSelectionMessage(SelectionMessage message) {
for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
for (AssemblyRecipe recipe : AssemblyRecipeManager.INSTANCE.getRecipes()) {
if (recipe.output.isItemEqual(message.stack) && ItemStack.areItemStackTagsEqual(recipe.output, message.stack)) {
if (message.select) {
planOutput(recipe);
@ -352,12 +325,12 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
public void sendSelectionTo(EntityPlayer player) {
for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
for (AssemblyRecipe recipe : AssemblyRecipeManager.INSTANCE.getRecipes()) {
SelectionMessage message = new SelectionMessage();
message.stack = r.output;
message.stack = recipe.output;
if (isPlanned(r)) {
if (isPlanned(recipe)) {
message.select = true;
} else {
message.select = false;
@ -446,7 +419,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
return energyStored;
}
public float getRequiredEnergy() {
public double getRequiredEnergy() {
return currentRequiredEnergy;
}
@ -484,7 +457,6 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
// TODO Auto-generated method stub
return true;
}

View file

@ -1,16 +1,13 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.silicon.gui;
import buildcraft.BuildCraftCore;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.CoreIconProvider;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface;
@ -19,10 +16,11 @@ import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketNBT;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtils;
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
import buildcraft.silicon.TileAssemblyTable;
import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@ -30,10 +28,12 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiAssemblyTable extends GuiAdvancedInterface {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",DefaultProps.TEXTURE_PATH_GUI + "/assembly_table.png");
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/assembly_table.png");
TileAssemblyTable assemblyTable;
class AssemblyLedger extends Ledger {
int headerColour = 0xe1c92f;
int subheaderColour = 0xaaafb8;
int textColour = 0x000000;
@ -50,7 +50,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
drawBackground(x, y);
// Draw icon
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4);
if (!isFullyOpened())
@ -70,7 +70,6 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
public String getTooltip() {
return String.format("%3.2f MJ/t", assemblyTable.getRecentEnergyAverage() / 100.0f);
}
}
class RecipeSlot extends AdvancedSlot {
@ -84,7 +83,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
public ItemStack getItemStack() {
if (this.recipe != null)
return this.recipe.output;
return this.recipe.getOutput();
else
return null;
}
@ -118,15 +117,16 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
}
public void updateRecipes() {
LinkedList<AssemblyRecipe> potentialRecipes = assemblyTable.getPotentialOutputs();
List<AssemblyRecipe> potentialRecipes = assemblyTable.getPotentialOutputs();
Iterator<AssemblyRecipe> cur = potentialRecipes.iterator();
for (int p = 0; p < 8; ++p)
for (int p = 0; p < 8; ++p) {
if (cur.hasNext()) {
((RecipeSlot) slots[p]).recipe = cur.next();
} else {
((RecipeSlot) slots[p]).recipe = null;
}
}
}
@Override
@ -140,7 +140,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(TEXTURE);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;

View file

@ -2,7 +2,7 @@ package buildcraft.transport;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.Position;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.proxy.CoreProxy;
@ -160,8 +160,7 @@ public class ItemFacade extends ItemBuildCraft {
facade6.stackSize = 6;
// 3 Structurepipes + this block makes 6 facades
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack},
8000, facade6));
BuildcraftRecipes.assemblyTable.addRecipe(8000, facade6, new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack);
if (itemStack.itemID < Block.blocksList.length && Block.blocksList[itemStack.itemID] != null) {
Block bl = Block.blocksList[itemStack.itemID];

View file

@ -19,7 +19,6 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.inventory.ISelectiveInventory;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.GuiIds;
import buildcraft.core.gui.buttons.IButtonTextureSet;
@ -108,23 +107,24 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
@Override
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
/* ISELECTIVEINVENTORY */
// ISELECTIVEINVENTORY
// non blocking mode is not implemented for ISelectiveInventory yet
if (inventory instanceof ISelectiveInventory) {
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
if (doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
}
}
incrementFilter();
}
return stacks;
// if (inventory instanceof ISelectiveInventory) {
// ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
// if (doRemove) {
// for (ItemStack stack : stacks) {
// if (stack != null) {
// powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
// }
// }
// incrementFilter();
// }
// return stacks;
// } else
/* ISPECIALINVENTORY */
// non blocking mode is not needed for ISpecialInventory since its not round robin anyway
} else if (inventory instanceof ISpecialInventory) {
// ISPECIALINVENTORY
// non blocking mode is not needed for ISpecialInventory since its not round robin anyway
if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
if (stacks != null) {
for (ItemStack stack : stacks) {

View file

@ -21,7 +21,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.IAction;
import buildcraft.api.inventory.ISelectiveInventory;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.GuiIds;
import buildcraft.core.inventory.SimpleInventory;
@ -103,19 +102,20 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
}
/* ISELECTIVEINVENTORY */
if (inventory instanceof ISelectiveInventory) {
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
if (doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
}
}
}
return stacks;
// if (inventory instanceof ISelectiveInventory) {
// ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
// if (doRemove) {
// for (ItemStack stack : stacks) {
// if (stack != null) {
// powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
// }
// }
// }
// return stacks;
// } else
/* ISPECIALINVENTORY */
} else if (inventory instanceof ISpecialInventory) {
if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
if (stacks != null) {
for (ItemStack stack : stacks) {