diff --git a/README.md b/README.md
index 28a79d58..2ae94aed 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,6 @@ a problem that might have fixed been already. Such things makes for very grumpy
less time coding and more time doing stuff that makes them less grumpy.
* If the issues occurs on a server, be sure it's a vanilla forge server and not a mcpc+ server.
* Issues with any logs mentioning Optifine will be closed on sight! Remove Optifine before reporting any issue.
-* Issues with any logs mentioning MineFactoryReloaded or PowerCrystalsCore will be closed on sight! They are modifying our code using core mods!
#### Frequently reported
* java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue
diff --git a/build.xml b/build.xml
index 65fbdaca..39a6a78e 100644
--- a/build.xml
+++ b/build.xml
@@ -130,7 +130,7 @@
-
+
@@ -169,10 +169,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java
index 309cd3fe..1976130b 100644
--- a/common/buildcraft/BuildCraftTransport.java
+++ b/common/buildcraft/BuildCraftTransport.java
@@ -266,7 +266,7 @@ public class BuildCraftTransport {
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant");
CoreProxy.proxy.registerItem(pipeWaterproof);
-
+
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class);
@@ -313,32 +313,24 @@ public class BuildCraftTransport {
redPipeWire.setUnlocalizedName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
CoreProxy.proxy.registerItem(redPipeWire);
- 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)));
Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE);
bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true);
bluePipeWire.setUnlocalizedName("bluePipeWire");
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
CoreProxy.proxy.registerItem(bluePipeWire);
- 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)));
Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE);
greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true);
greenPipeWire.setUnlocalizedName("greenPipeWire");
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
CoreProxy.proxy.registerItem(greenPipeWire);
- 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)));
Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE);
yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
yellowPipeWire.setUnlocalizedName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
CoreProxy.proxy.registerItem(yellowPipeWire);
- 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)));
Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID);
pipeGate = new ItemGate(pipeGateId.getInt(), 0);
@@ -365,9 +357,6 @@ public class BuildCraftTransport {
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
-
- AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
-
} finally {
BuildCraftCore.mainConfiguration.save();
}
@@ -422,7 +411,7 @@ public class BuildCraftTransport {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction);
}
-
+
for (PowerMode limit : PowerMode.VALUES) {
actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit);
}
@@ -436,7 +425,7 @@ public class BuildCraftTransport {
// Add pipe recipes
for (PipeRecipe pipe : pipeRecipes) {
if (pipe.isShapeless) {
- CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
+ CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
} else {
CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input);
}
@@ -449,11 +438,18 @@ public class BuildCraftTransport {
//Facade turning helper
GameRegistry.addRecipe(facadeItem.new FacadeRecipe());
+
+ // Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now
+ 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)));
}
@EventHandler
public void processIMCRequests(IMCEvent event) {
- InterModComms.processIMC(event);
+ InterModComms.processIMC(event);
}
public static Item buildPipe(int defaultID, Class extends Pipe> clas, String descr, Object... ingredients) {
diff --git a/common/buildcraft/api/power/ILaserTarget.java b/common/buildcraft/api/power/ILaserTarget.java
new file mode 100644
index 00000000..3d1eca59
--- /dev/null
+++ b/common/buildcraft/api/power/ILaserTarget.java
@@ -0,0 +1,46 @@
+/*
+ * 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.power;
+
+/**
+ * Specifies a Tile Entity that can receive power via laser beam.
+ *
+ * @author cpw
+ */
+public interface ILaserTarget {
+
+ /**
+ * Returns true if the target currently needs power. For example, if the Advanced
+ * Crafting Table has work to do.
+ *
+ * @return true if needs power
+ */
+ boolean requiresLaserEnergy();
+
+ /**
+ * Transfers energy from the laser to the target.
+ *
+ * @param energy
+ */
+ void receiveLaserEnergy(float energy);
+
+ /**
+ * Return true if the Tile Entity object is no longer a valid target. For
+ * example, if its been invalidated.
+ *
+ * @return true if no longer a valid target object
+ */
+ boolean isInvalidTarget();
+
+ int getXCoord();
+
+ int getYCoord();
+
+ int getZCoord();
+}
diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java
index 573db282..6ab39418 100644
--- a/common/buildcraft/api/recipes/AssemblyRecipe.java
+++ b/common/buildcraft/api/recipes/AssemblyRecipe.java
@@ -1,13 +1,14 @@
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 assemblyRecipes = new LinkedList();
-
- public final ItemStack[] input;
+ public final Object[] input;
public final ItemStack output;
public final float energy;
@@ -17,30 +18,69 @@ public class AssemblyRecipe {
this.energy = energy;
}
- public boolean canBeDone(ItemStack[] items) {
+ /**
+ * 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 (ItemStack in : input) {
+ for (int i = 0; i < input.length; i++) {
+ if (input[i] instanceof String) {
+ input[i] = OreDictionary.getOres((String) input[i]);
+ }
+ }
+ }
- if (in == null) {
+ public boolean canBeDone(ItemStack... items) {
+ for (int i = 0; i < input.length; i++) {
+ if (input[i] == null)
continue;
- }
- int found = 0; // Amount of ingredient found in inventory
+ 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
- for (ItemStack item : items) {
- if (item == null) {
- continue;
}
- if (item.isItemEqual(in)) {
- 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 oreList = (ArrayList) input[i];
+ int found = 0; // Amount of ingredient found in inventory
+ int expected = (Integer) input[i++ + 1];
- if (found < in.stackSize)
- return false; // Return false if the amount of ingredient found
- // is not enough
+ 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;
diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java
index 3b173e7b..0dde53c8 100644
--- a/common/buildcraft/core/utils/BlockUtil.java
+++ b/common/buildcraft/core/utils/BlockUtil.java
@@ -10,8 +10,12 @@ package buildcraft.core.utils;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftEnergy;
import buildcraft.api.core.BuildCraftAPI;
+import buildcraft.core.proxy.CoreProxy;
import cpw.mods.fml.common.FMLCommonHandler;
+
+import java.util.ArrayList;
import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid;
import net.minecraft.entity.item.EntityItem;
@@ -22,12 +26,14 @@ import net.minecraft.network.packet.Packet60Explosion;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
+import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
+
public class BlockUtil {
public static List getItemStackFromBlock(World world, int i, int j, int k) {
@@ -41,7 +47,19 @@ public class BlockUtil {
int meta = world.getBlockMetadata(i, j, k);
- return block.getBlockDropped(world, i, j, k, meta, 0);
+ ArrayList dropsList = block.getBlockDropped(world, i, j, k, meta, 0);
+ float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F, false, CoreProxy.proxy.getBuildCraftPlayer(world));
+
+ ArrayList returnList = new ArrayList();
+ for (ItemStack s : dropsList)
+ {
+ if (world.rand.nextFloat() <= dropChance)
+ {
+ returnList.add(s);
+ }
+ }
+
+ return returnList;
}
public static void breakBlock(World world, int x, int y, int z) {
@@ -50,8 +68,7 @@ public class BlockUtil {
public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) {
if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
- int blockId = world.getBlockId(x, y, z);
- List items = Block.blocksList[blockId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
+ List items = getItemStackFromBlock(world, x, y, z);
for (ItemStack item : items) {
float var = 0.7F;
diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java
index 6dc5585f..51d12c58 100644
--- a/common/buildcraft/factory/BlockPump.java
+++ b/common/buildcraft/factory/BlockPump.java
@@ -83,6 +83,15 @@ public class BlockPump extends BlockContainer {
return false;
}
+ @Override
+ public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
+ super.onNeighborBlockChange(world, x, y, z, id);
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+ if (tile instanceof TilePump) {
+ ((TilePump) tile).onNeighborBlockChange(id);
+ }
+ }
+
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void addCreativeItems(ArrayList itemList) {
diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java
index e6e419d3..2baa9b3b 100644
--- a/common/buildcraft/factory/TilePump.java
+++ b/common/buildcraft/factory/TilePump.java
@@ -62,6 +62,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
private SafeTimeTracker timer = new SafeTimeTracker();
private int tick = Utils.RANDOM.nextInt();
private int numFluidBlocksFound = 0;
+ private boolean powered = false;
public TilePump() {
powerHandler = new PowerHandler(this, Type.MACHINE);
@@ -73,19 +74,26 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.configurePowerPerdition(1, 100);
}
- // TODO, manage this by different levels (pump what's above first...)
@Override
public void updateEntity() {
super.updateEntity();
- if (tube == null)
- return;
+ if (powered) {
+ pumpLayerQueues.clear();
+ destroyTube();
+ } else
+ createTube();
-
- if (CoreProxy.proxy.isRenderWorld(worldObj))
+ if (worldObj.isRemote)
return;
pushToConsumers();
+
+ if(powered)
+ return;
+
+ if(tube == null)
+ return;
if (tube.posY - aimY > 0.01) {
tubeY = tube.posY - 0.01;
@@ -134,6 +142,15 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
}
}
+ public void onNeighborBlockChange(int id) {
+ boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
+ if (powered != p) {
+ powered = p;
+ if(!worldObj.isRemote)
+ sendNetworkUpdate();
+ }
+ }
+
private boolean isBlocked(int x, int y, int z) {
Material mat = worldObj.getBlockMaterial(x, y, z);
return mat.blocksMovement();
@@ -151,28 +168,37 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
return tileBuffer[side.ordinal()].getTile();
}
- @Override
- public void initialize() {
- tube = FactoryProxy.proxy.newPumpTube(worldObj);
+ private void createTube() {
+ if (tube == null) {
+ tube = FactoryProxy.proxy.newPumpTube(worldObj);
- if (!Double.isNaN(tubeY)) {
- tube.posY = tubeY;
- } else {
- tube.posY = yCoord;
+ if (!Double.isNaN(tubeY)) {
+ tube.posY = tubeY;
+ } else {
+ tube.posY = yCoord;
+ }
+
+ tubeY = tube.posY;
+
+ if (aimY == 0) {
+ aimY = yCoord;
+ }
+
+ setTubePosition();
+
+ worldObj.spawnEntityInWorld(tube);
+
+ if (!worldObj.isRemote)
+ sendNetworkUpdate();
}
+ }
- tubeY = tube.posY;
-
- if (aimY == 0) {
- aimY = yCoord;
- }
-
- setTubePosition();
-
- worldObj.spawnEntityInWorld(tube);
-
- if (CoreProxy.proxy.isSimulating(worldObj)) {
- sendNetworkUpdate();
+ private void destroyTube() {
+ if (tube != null) {
+ CoreProxy.proxy.removeEntity(tube);
+ tube = null;
+ tubeY = Double.NaN;
+ aimY = 0;
}
}
@@ -298,6 +324,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.readFromNBT(data);
tank.readFromNBT(data);
+ powered = data.getBoolean("powered");
+
aimY = data.getInteger("aimY");
tubeY = data.getFloat("tubeY");
@@ -311,6 +339,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.writeToNBT(data);
tank.writeToNBT(data);
+ data.setBoolean("powered", powered);
+
data.setInteger("aimY", aimY);
if (tube != null) {
@@ -347,6 +377,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(aimY);
data.writeFloat((float) tubeY);
+ data.writeBoolean(powered);
}
});
@@ -359,6 +390,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
DataInputStream data = payload.stream;
aimY = data.readInt();
tubeY = data.readFloat();
+ powered = data.readBoolean();
setTubePosition();
}
@@ -394,12 +426,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
public void destroy() {
tileBuffer = null;
pumpLayerQueues.clear();
- if (tube != null) {
- CoreProxy.proxy.removeEntity(tube);
- tube = null;
- tubeY = Double.NaN;
- aimY = 0;
- }
+ destroyTube();
}
@Override
@@ -431,7 +458,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
- if (resource != null && !resource.isFluidEqual(tank.getFluid()))
+ if (resource == null)
+ return null;
+ if (!resource.isFluidEqual(tank.getFluid()))
return null;
return drain(from, resource.amount, doDrain);
}
diff --git a/common/buildcraft/silicon/ILaserTarget.java b/common/buildcraft/silicon/ILaserTarget.java
deleted file mode 100644
index 46a39b60..00000000
--- a/common/buildcraft/silicon/ILaserTarget.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package buildcraft.silicon;
-
-public interface ILaserTarget {
- boolean hasCurrentWork();
-
- void receiveLaserEnergy(float energy);
-
- boolean isInvalidTarget();
-
- int getXCoord();
-
- int getYCoord();
-
- int getZCoord();
-}
diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java
index 8fd35a15..89a1e9d5 100644
--- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java
+++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java
@@ -1,5 +1,6 @@
package buildcraft.silicon;
+import buildcraft.api.power.ILaserTarget;
import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor;
@@ -413,8 +414,8 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
}
@Override
- public boolean hasCurrentWork() {
- return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off;
+ public boolean requiresLaserEnergy() {
+ return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off && storedEnergy < REQUIRED_POWER * 10;
}
@Override
@@ -440,7 +441,7 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
@Override
public boolean isActive() {
- return hasCurrentWork();
+ return requiresLaserEnergy();
}
@Override
diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java
index dd017f39..f855de21 100644
--- a/common/buildcraft/silicon/TileAssemblyTable.java
+++ b/common/buildcraft/silicon/TileAssemblyTable.java
@@ -1,15 +1,20 @@
package buildcraft.silicon;
+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 cpw.mods.fml.common.FMLCommonHandler;
+import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import net.minecraft.entity.item.EntityItem;
@@ -67,12 +72,6 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
return result;
}
- @Override
- public void receiveLaserEnergy(float energy) {
- energyStored += energy;
- recentEnergy[tick] += energy;
- }
-
@Override
public boolean canUpdate() {
return !FMLCommonHandler.instance().getEffectiveSide().isClient();
@@ -99,34 +98,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
if (currentRecipe.canBeDone(items)) {
- for (ItemStack in : currentRecipe.input) {
- if (in == null) {
- continue; // Optimisation, reduces calculation for a null ingredient
- }
-
- int found = 0; // Amount of ingredient found in inventory
-
- for (int i = 0; i < items.length; ++i) {
- if (items[i] == null) {
- continue; // Broken out of large if statement, increases clarity
- }
-
- if (StackHelper.instance().isCraftingEquivalent(in, items[i], true)) {
-
- int supply = items[i].stackSize;
- int toBeFound = in.stackSize - found;
-
- if (supply >= toBeFound) {
- found += decrStackSize(i, toBeFound).stackSize; // Adds the amount of ingredient taken (in this case the total still needed)
- } else {
- found += decrStackSize(i, supply).stackSize; // Adds the amount of ingredient taken (in this case the total in that slot)
- }
- if (found >= in.stackSize) {
- break; // Breaks out of the for loop when the required amount of ingredient has been taken
- }
- }
- }
- }
+ useItems();
ItemStack remaining = currentRecipe.output.copy();
remaining.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining);
@@ -146,6 +118,30 @@ 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 oreList = (ArrayList) 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) {
if (currentRecipe == null)
return 0;
@@ -455,8 +451,14 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
@Override
- public boolean hasCurrentWork() {
- return currentRecipe != null;
+ public boolean requiresLaserEnergy() {
+ return currentRecipe != null && energyStored < currentRequiredEnergy * 5F;
+ }
+
+ @Override
+ public void receiveLaserEnergy(float energy) {
+ energyStored += energy;
+ recentEnergy[tick] += energy;
}
@Override
diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java
index c85b983c..7dcace38 100644
--- a/common/buildcraft/silicon/TileLaser.java
+++ b/common/buildcraft/silicon/TileLaser.java
@@ -7,6 +7,7 @@
*/
package buildcraft.silicon;
+import buildcraft.api.power.ILaserTarget;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker;
@@ -125,7 +126,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
protected boolean isValidTable() {
- if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.hasCurrentWork())
+ if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.requiresLaserEnergy())
return false;
return true;
@@ -163,7 +164,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
break;
}
- List targets = new LinkedList();
+ List targets = new LinkedList();
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
@@ -173,8 +174,8 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (tile instanceof ILaserTarget) {
ILaserTarget table = (ILaserTarget) tile;
- if (table.hasCurrentWork()) {
- targets.add(new BlockIndex(x, y, z));
+ if (table.requiresLaserEnergy()) {
+ targets.add(table);
}
}
@@ -185,8 +186,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (targets.isEmpty())
return;
- BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size()));
- laserTarget = (ILaserTarget) worldObj.getBlockTileEntity(b.x, b.y, b.z);
+ laserTarget = targets.get(worldObj.rand.nextInt(targets.size()));
}
protected void createLaser() {
diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java
index dcc7fb20..2c13ee40 100644
--- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java
+++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java
@@ -40,15 +40,12 @@ import buildcraft.transport.PipeIconProvider;
public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler {
public static enum ButtonState implements IMultiButtonState {
- BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking");
+ BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking");
private final String label;
- private final ToolTip tip;
private ButtonState(String label) {
this.label = label;
- tip = new ToolTip();
- tip.add(new ToolTipLine(label + ".tip"));
}
@Override
@@ -65,8 +62,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
public ToolTip getToolTip() {
return this.tip;
}
+ private final ToolTip tip = new ToolTip(500) {
+ @Override
+ public void refresh() {
+ clear();
+ tip.add(new ToolTipLine(StringUtils.localize(label + ".tip")));
+ }
+ };
}
-
private final MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values());
private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
private int currentFilter = 0;
@@ -108,7 +111,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
/* 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());
+ ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
if (doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
@@ -168,7 +171,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
}
if (result != null) {
- return new ItemStack[] { result };
+ return new ItemStack[]{result};
}
}