Added pipe paramter to extraction handler
This commit is contained in:
parent
f56a166afa
commit
3ab29dcfad
6 changed files with 20 additions and 11 deletions
|
@ -183,12 +183,12 @@ public class BuildCraftTransport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItems(World world, int i, int j, int k) {
|
||||
public boolean canExtractItems(IPipe pipe, World world, int i, int j, int k) {
|
||||
return testStrings(items, world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractLiquids(World world, int i, int j, int k) {
|
||||
public boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k) {
|
||||
return testStrings(liquids, world, i, j, k);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@ import net.minecraft.src.World;
|
|||
* Implement and register with the PipeManager if you want to suppress connections from wooden pipes.
|
||||
*/
|
||||
public interface IExtractionHandler {
|
||||
boolean canExtractItems(World world, int i, int j, int k);
|
||||
boolean canExtractLiquids(World world, int i, int j, int k);
|
||||
|
||||
/**
|
||||
* Can this pipe extract items from the block located at these coordinates?
|
||||
*/
|
||||
boolean canExtractItems(IPipe pipe, World world, int i, int j, int k);
|
||||
|
||||
/**
|
||||
* Can this pipe extract liquids from the block located at these coordinates?
|
||||
*/
|
||||
boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k);
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ public abstract class PipeManager {
|
|||
extractionHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static boolean canExtractItems(World world, int i, int j, int k) {
|
||||
public static boolean canExtractItems(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractItems(world, i, j, k))
|
||||
if(!handler.canExtractItems(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canExtractLiquids(World world, int i, int j, int k) {
|
||||
public static boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractLiquids(world, i, j, k))
|
||||
if(!handler.canExtractLiquids(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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.IPipe;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.Utils;
|
||||
import buildcraft.transport.pipes.PipeLiquidsVoid;
|
||||
|
@ -38,7 +39,7 @@ public class PipeLogicWood extends PipeLogic {
|
|||
TileEntity tile = container.getTile(o);
|
||||
|
||||
if (isInput(tile))
|
||||
if (PipeManager.canExtractItems(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord) || PipeManager.canExtractLiquids(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord) ) {
|
||||
if (PipeManager.canExtractItems(container.getPipe(), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord) || PipeManager.canExtractLiquids(container.getPipe(), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord) ) {
|
||||
newMeta = o.ordinal();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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 instanceof IInventory) {
|
||||
if (!PipeManager.canExtractItems(w, (int) pos.x, (int) pos.y, (int) pos.z))
|
||||
if (!PipeManager.canExtractItems(this, w, (int) pos.x, (int) pos.y, (int) pos.z))
|
||||
return;
|
||||
|
||||
IInventory inventory = (IInventory) tile;
|
||||
|
|
|
@ -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 instanceof ITankContainer) {
|
||||
if (!PipeManager.canExtractLiquids(w, (int) pos.x, (int) pos.y, (int) pos.z))
|
||||
if (!PipeManager.canExtractLiquids(this, w, (int) pos.x, (int) pos.y, (int) pos.z))
|
||||
return;
|
||||
|
||||
if (liquidToExtract <= BuildCraftAPI.BUCKET_VOLUME)
|
||||
|
|
Loading…
Reference in a new issue