Implemented IBlockExtractable.java. Should close #108

This commit is contained in:
SirSengir 2012-07-26 22:47:49 +02:00
parent f6531234e0
commit 69d3a4bd4f
4 changed files with 20 additions and 9 deletions

View file

@ -0,0 +1,10 @@
package buildcraft.api.transport;
import net.minecraft.src.World;
/**
* Implemented by blocks that may want to suppress connections from wooden pipes.
*/
public interface IBlockExtractable {
boolean mayExtract(World world, int x, int y, int z);
}

View file

@ -14,6 +14,7 @@ import buildcraft.api.APIProxy;
import buildcraft.api.core.Orientations;
import buildcraft.api.liquids.ITankContainer;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IBlockExtractable;
import buildcraft.core.Utils;
import buildcraft.transport.pipes.PipeLiquidsVoid;
import buildcraft.transport.pipes.PipeLiquidsWood;
@ -22,6 +23,7 @@ import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class PipeLogicWood extends PipeLogic {
@ -38,7 +40,7 @@ public class PipeLogicWood extends PipeLogic {
TileEntity tile = container.getTile(o);
if (isInput(tile))
if (!isExcludedFromExtraction(block)) {
if (!isExcludedFromExtraction(block, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) {
newMeta = o.ordinal();
break;
}
@ -56,15 +58,14 @@ public class PipeLogicWood extends PipeLogic {
&& Utils.checkPipesConnections(container, tile);
}
public static boolean isExcludedFromExtraction(Block block) {
public static boolean isExcludedFromExtraction(Block block, World world, int x, int y, int z) {
if (block == null)
return true;
for (String excluded : excludedBlocks)
if (excluded.equals(block.getBlockName()) || excluded.equals(Integer.toString(block.blockID)))
return true;
return false;
if(!(block instanceof IBlockExtractable))
return false;
return !((IBlockExtractable)block).mayExtract(world, x, y, z);
}
@Override

View file

@ -96,7 +96,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
TileEntity tile = w.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
if (tile == null || !(tile instanceof IInventory || tile instanceof ITankContainer)
|| PipeLogicWood.isExcludedFromExtraction(Block.blocksList[blockId]))
|| PipeLogicWood.isExcludedFromExtraction(Block.blocksList[blockId], tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
return;
if (tile instanceof IInventory) {

View file

@ -66,7 +66,7 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
TileEntity tile = w.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
if (tile == null || !(tile instanceof ITankContainer)
|| PipeLogicWood.isExcludedFromExtraction(Block.blocksList[blockId]))
|| PipeLogicWood.isExcludedFromExtraction(Block.blocksList[blockId], tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
return;
if (tile instanceof ITankContainer)