Merge branch 'master' into filler

This commit is contained in:
CovertJaguar 2013-11-20 20:21:54 -08:00
commit b89e5718db
13 changed files with 283 additions and 136 deletions

View file

@ -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. 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 <b>not</b> a mcpc+ server. * If the issues occurs on a server, be sure it's a vanilla forge server and <b>not</b> 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 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 #### Frequently reported
* java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue * java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue

View file

@ -130,7 +130,7 @@
</target> </target>
<target name="copy-src" depends="clean-src,initialize-version"> <target name="copy-src" depends="clean-src,initialize-version">
<!-- Copy sources --> <!-- Copy sources -->
<copy todir="${mcpsrc.dir}/minecraft" verbose="true"> <copy todir="${mcpsrc.dir}/minecraft" verbose="false">
<fileset dir="${src.dir}/common"/> <fileset dir="${src.dir}/common"/>
<filterset> <filterset>
<filter token="VERSION" value="${project.complete.version}" /> <filter token="VERSION" value="${project.complete.version}" />
@ -169,10 +169,30 @@
<!-- Reobfuscate --> <!-- Reobfuscate -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows"> <exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/> <arg line="/c reobfuscate_srg.bat"/>
<redirector>
<outputfilterchain>
<linecontains negate="true">
<contains value="> New"/>
</linecontains>
<linecontains negate="true">
<contains value="> Outputted"/>
</linecontains>
</outputfilterchain>
</redirector>
</exec> </exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix"> <exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh"/> <arg value="reobfuscate_srg.sh"/>
<redirector>
<outputfilterchain>
<linecontains negate="true">
<contains value="> New"/>
</linecontains>
<linecontains negate="true">
<contains value="> Outputted"/>
</linecontains>
</outputfilterchain>
</redirector>
</exec> </exec>
<!-- Copy classes --> <!-- Copy classes -->

View file

@ -313,32 +313,24 @@ public class BuildCraftTransport {
redPipeWire.setUnlocalizedName("redPipeWire"); redPipeWire.setUnlocalizedName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
CoreProxy.proxy.registerItem(redPipeWire); 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); Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE);
bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true); bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true);
bluePipeWire.setUnlocalizedName("bluePipeWire"); bluePipeWire.setUnlocalizedName("bluePipeWire");
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
CoreProxy.proxy.registerItem(bluePipeWire); 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); Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE);
greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true); greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true);
greenPipeWire.setUnlocalizedName("greenPipeWire"); greenPipeWire.setUnlocalizedName("greenPipeWire");
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
CoreProxy.proxy.registerItem(greenPipeWire); 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); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE);
yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true); yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
yellowPipeWire.setUnlocalizedName("yellowPipeWire"); yellowPipeWire.setUnlocalizedName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
CoreProxy.proxy.registerItem(yellowPipeWire); 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); Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID);
pipeGate = new ItemGate(pipeGateId.getInt(), 0); pipeGate = new ItemGate(pipeGateId.getInt(), 0);
@ -365,9 +357,6 @@ public class BuildCraftTransport {
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt()); filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock")); CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer"); CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
} finally { } finally {
BuildCraftCore.mainConfiguration.save(); BuildCraftCore.mainConfiguration.save();
} }
@ -449,6 +438,13 @@ public class BuildCraftTransport {
//Facade turning helper //Facade turning helper
GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); 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 @EventHandler

View file

@ -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();
}

View file

@ -1,13 +1,14 @@
package buildcraft.api.recipes; package buildcraft.api.recipes;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class AssemblyRecipe { public class AssemblyRecipe {
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>(); public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public final Object[] input;
public final ItemStack[] input;
public final ItemStack output; public final ItemStack output;
public final float energy; public final float energy;
@ -17,30 +18,69 @@ public class AssemblyRecipe {
this.energy = energy; 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) {
if (in == null) { input[i] = OreDictionary.getOres((String) input[i]);
continue; }
}
} }
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 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) { for (ItemStack item : items) {
if (item == null) { if (item == null)
continue; continue;
for (ItemStack oreItem : oreList) {
if (OreDictionary.itemMatches(oreItem, item, true)) {
found += item.stackSize;
break;
} }
if (item.isItemEqual(in)) {
found += item.stackSize; // Adds quantity of stack to amount
// found
} }
} }
if (found < in.stackSize) // Return false if the amount of ingredient found
return false; // Return false if the amount of ingredient found
// is not enough // is not enough
if (found < expected)
return false;
}
} }
return true; return true;

View file

@ -10,8 +10,12 @@ package buildcraft.core.utils;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftEnergy; import buildcraft.BuildCraftEnergy;
import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.BuildCraftAPI;
import buildcraft.core.proxy.CoreProxy;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid; import net.minecraft.block.BlockFluid;
import net.minecraft.entity.item.EntityItem; 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.ChunkPosition;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
public class BlockUtil { public class BlockUtil {
public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) { public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) {
@ -41,7 +47,19 @@ public class BlockUtil {
int meta = world.getBlockMetadata(i, j, k); int meta = world.getBlockMetadata(i, j, k);
return block.getBlockDropped(world, i, j, k, meta, 0); ArrayList<ItemStack> 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<ItemStack> returnList = new ArrayList<ItemStack>();
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) { 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) { 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")) { if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
int blockId = world.getBlockId(x, y, z); List<ItemStack> items = getItemStackFromBlock(world, x, y, z);
List<ItemStack> items = Block.blocksList[blockId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
for (ItemStack item : items) { for (ItemStack item : items) {
float var = 0.7F; float var = 0.7F;

View file

@ -83,6 +83,15 @@ public class BlockPump extends BlockContainer {
return false; 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"}) @SuppressWarnings({"unchecked", "rawtypes"})
@Override @Override
public void addCreativeItems(ArrayList itemList) { public void addCreativeItems(ArrayList itemList) {

View file

@ -62,6 +62,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
private SafeTimeTracker timer = new SafeTimeTracker(); private SafeTimeTracker timer = new SafeTimeTracker();
private int tick = Utils.RANDOM.nextInt(); private int tick = Utils.RANDOM.nextInt();
private int numFluidBlocksFound = 0; private int numFluidBlocksFound = 0;
private boolean powered = false;
public TilePump() { public TilePump() {
powerHandler = new PowerHandler(this, Type.MACHINE); powerHandler = new PowerHandler(this, Type.MACHINE);
@ -73,20 +74,27 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.configurePowerPerdition(1, 100); powerHandler.configurePowerPerdition(1, 100);
} }
// TODO, manage this by different levels (pump what's above first...)
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
if (tube == null) if (powered) {
return; pumpLayerQueues.clear();
destroyTube();
} else
createTube();
if (worldObj.isRemote)
if (CoreProxy.proxy.isRenderWorld(worldObj))
return; return;
pushToConsumers(); pushToConsumers();
if(powered)
return;
if(tube == null)
return;
if (tube.posY - aimY > 0.01) { if (tube.posY - aimY > 0.01) {
tubeY = tube.posY - 0.01; tubeY = tube.posY - 0.01;
setTubePosition(); setTubePosition();
@ -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) { private boolean isBlocked(int x, int y, int z) {
Material mat = worldObj.getBlockMaterial(x, y, z); Material mat = worldObj.getBlockMaterial(x, y, z);
return mat.blocksMovement(); return mat.blocksMovement();
@ -151,8 +168,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
return tileBuffer[side.ordinal()].getTile(); return tileBuffer[side.ordinal()].getTile();
} }
@Override private void createTube() {
public void initialize() { if (tube == null) {
tube = FactoryProxy.proxy.newPumpTube(worldObj); tube = FactoryProxy.proxy.newPumpTube(worldObj);
if (!Double.isNaN(tubeY)) { if (!Double.isNaN(tubeY)) {
@ -171,11 +188,20 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
worldObj.spawnEntityInWorld(tube); worldObj.spawnEntityInWorld(tube);
if (CoreProxy.proxy.isSimulating(worldObj)) { if (!worldObj.isRemote)
sendNetworkUpdate(); sendNetworkUpdate();
} }
} }
private void destroyTube() {
if (tube != null) {
CoreProxy.proxy.removeEntity(tube);
tube = null;
tubeY = Double.NaN;
aimY = 0;
}
}
private BlockIndex getNextIndexToPump(boolean remove) { private BlockIndex getNextIndexToPump(boolean remove) {
if (pumpLayerQueues.isEmpty()) { if (pumpLayerQueues.isEmpty()) {
if (timer.markTimeIfDelay(worldObj, REBUID_DELAY)) { if (timer.markTimeIfDelay(worldObj, REBUID_DELAY)) {
@ -298,6 +324,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.readFromNBT(data); powerHandler.readFromNBT(data);
tank.readFromNBT(data); tank.readFromNBT(data);
powered = data.getBoolean("powered");
aimY = data.getInteger("aimY"); aimY = data.getInteger("aimY");
tubeY = data.getFloat("tubeY"); tubeY = data.getFloat("tubeY");
@ -311,6 +339,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
powerHandler.writeToNBT(data); powerHandler.writeToNBT(data);
tank.writeToNBT(data); tank.writeToNBT(data);
data.setBoolean("powered", powered);
data.setInteger("aimY", aimY); data.setInteger("aimY", aimY);
if (tube != null) { if (tube != null) {
@ -347,6 +377,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
public void writeData(DataOutputStream data) throws IOException { public void writeData(DataOutputStream data) throws IOException {
data.writeInt(aimY); data.writeInt(aimY);
data.writeFloat((float) tubeY); data.writeFloat((float) tubeY);
data.writeBoolean(powered);
} }
}); });
@ -359,6 +390,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
DataInputStream data = payload.stream; DataInputStream data = payload.stream;
aimY = data.readInt(); aimY = data.readInt();
tubeY = data.readFloat(); tubeY = data.readFloat();
powered = data.readBoolean();
setTubePosition(); setTubePosition();
} }
@ -394,12 +426,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
public void destroy() { public void destroy() {
tileBuffer = null; tileBuffer = null;
pumpLayerQueues.clear(); pumpLayerQueues.clear();
if (tube != null) { destroyTube();
CoreProxy.proxy.removeEntity(tube);
tube = null;
tubeY = Double.NaN;
aimY = 0;
}
} }
@Override @Override
@ -431,7 +458,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { 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 null;
return drain(from, resource.amount, doDrain); return drain(from, resource.amount, doDrain);
} }

View file

@ -1,15 +0,0 @@
package buildcraft.silicon;
public interface ILaserTarget {
boolean hasCurrentWork();
void receiveLaserEnergy(float energy);
boolean isInvalidTarget();
int getXCoord();
int getYCoord();
int getZCoord();
}

View file

@ -1,5 +1,6 @@
package buildcraft.silicon; package buildcraft.silicon;
import buildcraft.api.power.ILaserTarget;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
@ -413,8 +414,8 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
} }
@Override @Override
public boolean hasCurrentWork() { public boolean requiresLaserEnergy() {
return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off; return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off && storedEnergy < REQUIRED_POWER * 10;
} }
@Override @Override
@ -440,7 +441,7 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
@Override @Override
public boolean isActive() { public boolean isActive() {
return hasCurrentWork(); return requiresLaserEnergy();
} }
@Override @Override

View file

@ -1,15 +1,20 @@
package buildcraft.silicon; package buildcraft.silicon;
import buildcraft.api.power.ILaserTarget;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.StackHelper; 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.PacketIds;
import buildcraft.core.network.PacketNBT; import buildcraft.core.network.PacketNBT;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -67,12 +72,6 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
return result; return result;
} }
@Override
public void receiveLaserEnergy(float energy) {
energyStored += energy;
recentEnergy[tick] += energy;
}
@Override @Override
public boolean canUpdate() { public boolean canUpdate() {
return !FMLCommonHandler.instance().getEffectiveSide().isClient(); return !FMLCommonHandler.instance().getEffectiveSide().isClient();
@ -99,34 +98,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
if (currentRecipe.canBeDone(items)) { if (currentRecipe.canBeDone(items)) {
for (ItemStack in : currentRecipe.input) { useItems();
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
}
}
}
}
ItemStack remaining = currentRecipe.output.copy(); ItemStack remaining = currentRecipe.output.copy();
remaining.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining); 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<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 float getCompletionRatio(float ratio) {
if (currentRecipe == null) if (currentRecipe == null)
return 0; return 0;
@ -455,8 +451,14 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
} }
@Override @Override
public boolean hasCurrentWork() { public boolean requiresLaserEnergy() {
return currentRecipe != null; return currentRecipe != null && energyStored < currentRequiredEnergy * 5F;
}
@Override
public void receiveLaserEnergy(float energy) {
energyStored += energy;
recentEnergy[tick] += energy;
} }
@Override @Override

View file

@ -7,6 +7,7 @@
*/ */
package buildcraft.silicon; package buildcraft.silicon;
import buildcraft.api.power.ILaserTarget;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.core.SafeTimeTracker;
@ -125,7 +126,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
protected boolean isValidTable() { protected boolean isValidTable() {
if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.hasCurrentWork()) if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.requiresLaserEnergy())
return false; return false;
return true; return true;
@ -163,7 +164,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
break; break;
} }
List<BlockIndex> targets = new LinkedList<BlockIndex>(); List<ILaserTarget> targets = new LinkedList<ILaserTarget>();
for (int x = minX; x <= maxX; ++x) { for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) { for (int y = minY; y <= maxY; ++y) {
@ -173,8 +174,8 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (tile instanceof ILaserTarget) { if (tile instanceof ILaserTarget) {
ILaserTarget table = (ILaserTarget) tile; ILaserTarget table = (ILaserTarget) tile;
if (table.hasCurrentWork()) { if (table.requiresLaserEnergy()) {
targets.add(new BlockIndex(x, y, z)); targets.add(table);
} }
} }
@ -185,8 +186,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (targets.isEmpty()) if (targets.isEmpty())
return; return;
BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size())); laserTarget = targets.get(worldObj.rand.nextInt(targets.size()));
laserTarget = (ILaserTarget) worldObj.getBlockTileEntity(b.x, b.y, b.z);
} }
protected void createLaser() { protected void createLaser() {

View file

@ -40,15 +40,12 @@ import buildcraft.transport.PipeIconProvider;
public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler { public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler {
public static enum ButtonState implements IMultiButtonState { 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 String label;
private final ToolTip tip;
private ButtonState(String label) { private ButtonState(String label) {
this.label = label; this.label = label;
tip = new ToolTip();
tip.add(new ToolTipLine(label + ".tip"));
} }
@Override @Override
@ -65,8 +62,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
public ToolTip getToolTip() { public ToolTip getToolTip() {
return this.tip; 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 MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values());
private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1); private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
private int currentFilter = 0; private int currentFilter = 0;