First draft handling sided tanks

This commit is contained in:
Christian 2012-11-12 21:45:11 -05:00
parent 252ed9df9d
commit 98be088256
10 changed files with 16 additions and 13 deletions

View file

@ -12,6 +12,7 @@ import buildcraft.core.IMachine;
import net.minecraft.src.Block;
import net.minecraft.src.IInventory;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ITankContainer;
public class DefaultTriggerProvider implements ITriggerProvider {
@ -30,7 +31,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
res.add(BuildCraftCore.triggerFullInventory);
}
if (tile instanceof ITankContainer && ((ITankContainer) tile).getTanks().length > 0) {
if (tile instanceof ITankContainer && ((ITankContainer) tile).getTanks(ForgeDirection.UNKNOWN).length > 0) {
res.add(BuildCraftCore.triggerEmptyLiquid);
res.add(BuildCraftCore.triggerContainsLiquid);
res.add(BuildCraftCore.triggerSpaceLiquid);

View file

@ -13,6 +13,7 @@ import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.gates.Trigger;
import buildcraft.core.DefaultProps;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidManager;
@ -76,7 +77,7 @@ public class TriggerLiquidContainer extends Trigger {
if (parameter != null && parameter.getItem() != null)
seachedLiquidId = LiquidManager.getLiquidIDForFilledItem(parameter.getItem());
ILiquidTank[] liquids = container.getTanks();
ILiquidTank[] liquids = container.getTanks(ForgeDirection.UNKNOWN);
if (liquids == null || liquids.length == 0)
return false;

View file

@ -468,7 +468,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
}
@Override
public LiquidTank[] getTanks() {
public LiquidTank[] getTanks(ForgeDirection direction) {
if (engine == null) {
return new LiquidTank[0];
} else {

View file

@ -111,7 +111,7 @@ public class BlockTank extends BlockContainer {
// Handle empty containers
} else {
LiquidStack available = tank.getTanks()[0].getLiquid();
LiquidStack available = tank.getTanks(ForgeDirection.UNKNOWN)[0].getLiquid();
if(available != null){
ItemStack filled = LiquidManager.fillLiquidContainer(available, current);

View file

@ -449,7 +449,7 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
}
@Override
public ILiquidTank[] getTanks() {
public ILiquidTank[] getTanks(ForgeDirection direction) {
return new ILiquidTank[] {
new LiquidTank(slot1.liquidId, slot1.quantity, LIQUID_PER_SLOT),
new LiquidTank(slot2.liquidId, slot2.quantity, LIQUID_PER_SLOT),

View file

@ -223,7 +223,7 @@ public class TileTank extends TileBuildCraft implements ITankContainer
}
@Override
public ILiquidTank[] getTanks()
public ILiquidTank[] getTanks(ForgeDirection direction)
{
ILiquidTank compositeTank = new LiquidTank(tank.getCapacity());

View file

@ -406,7 +406,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
if (tile instanceof ITankContainer) {
ITankContainer liq = (ITankContainer) tile;
if (liq.getTanks() != null && liq.getTanks().length > 0)
if (liq.getTanks(ForgeDirection.UNKNOWN) != null && liq.getTanks(ForgeDirection.UNKNOWN).length > 0)
return true;
}
@ -460,7 +460,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
}
@Override
public ILiquidTank[] getTanks() {
public ILiquidTank[] getTanks(ForgeDirection direction) {
return internalTanks;
}

View file

@ -546,9 +546,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
@Override
public ILiquidTank[] getTanks() {
public ILiquidTank[] getTanks(ForgeDirection direction) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer)
return ((ITankContainer) pipe.transport).getTanks();
return ((ITankContainer) pipe.transport).getTanks(ForgeDirection.UNKNOWN);
else
return null;
}

View file

@ -41,6 +41,6 @@ public class PipeLiquidsSandstone extends Pipe implements IPipeTransportLiquidsH
if (!(container.tileBuffer[from.ordinal()].getTile() instanceof TileGenericPipe))
return 0;
return ((PipeTransportLiquids)this.transport).getTanks()[from.ordinal()].fill(resource, doFill);
return ((PipeTransportLiquids)this.transport).getTanks(ForgeDirection.UNKNOWN)[from.ordinal()].fill(resource, doFill);
}
}

View file

@ -9,6 +9,7 @@
package buildcraft.transport.triggers;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.LiquidManager;
import net.minecraftforge.liquids.LiquidStack;
@ -102,13 +103,13 @@ public class TriggerPipeContents extends Trigger implements ITriggerPipe {
searchedLiquid = LiquidManager.getLiquidForFilledItem(parameter.getItem());
if (kind == Kind.Empty) {
for (ILiquidTank b : transportLiquids.getTanks())
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN))
if (b.getLiquid() != null && b.getLiquid().amount != 0)
return false;
return true;
} else {
for (ILiquidTank b : transportLiquids.getTanks())
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN))
if (b.getLiquid() != null && b.getLiquid().amount != 0)
if (searchedLiquid == null || searchedLiquid.isLiquidEqual(b.getLiquid()))
return true;