worked on tank and network a bit
This commit is contained in:
parent
34e7e6c7a6
commit
1f7e4ce470
6 changed files with 55 additions and 35 deletions
|
@ -142,7 +142,7 @@ public class FluidMech extends DummyModContainer
|
|||
static
|
||||
{
|
||||
/* EVENT BUS (done here to ensure all fluid events are caught) */
|
||||
MinecraftForge.EVENT_BUS.register(new FluidEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new FluidRestrictionHandler());
|
||||
}
|
||||
|
||||
@PreInit
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.liquids.LiquidStack;
|
|||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class FluidEvents
|
||||
public class FluidRestrictionHandler
|
||||
{
|
||||
private static BiMap<ColorCode, LiquidStack> restrictedStacks = HashBiMap.create();
|
||||
|
||||
|
@ -37,16 +37,23 @@ public class FluidEvents
|
|||
{
|
||||
restrictedStacks.put(ColorCode.WHITE, event.Liquid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks too see if a color has a restricted stack
|
||||
*/
|
||||
public static boolean hasRestrictedStack(int meta)
|
||||
{
|
||||
if (restrictedStacks.containsKey(ColorCode.get(meta)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return restrictedStacks.containsKey(ColorCode.get(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the liquid stack that is restricted to this color
|
||||
*
|
||||
*/
|
||||
public static LiquidStack getStackForColor(ColorCode color)
|
||||
{
|
||||
return restrictedStacks.get(color);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ import net.minecraftforge.liquids.LiquidContainerRegistry;
|
|||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import universalelectricity.prefab.block.BlockAdvanced;
|
||||
import fluidmech.client.render.BlockRenderHelper;
|
||||
import fluidmech.common.FluidEvents;
|
||||
import fluidmech.common.FluidRestrictionHandler;
|
||||
import fluidmech.common.FluidMech;
|
||||
import fluidmech.common.TabFluidMech;
|
||||
import fluidmech.common.tiles.TileEntityTank;
|
||||
|
@ -161,7 +161,7 @@ public class BlockTank extends BlockAdvanced
|
|||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (FluidEvents.hasRestrictedStack(i))
|
||||
if (FluidRestrictionHandler.hasRestrictedStack(i))
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fluidmech.common.tiles;
|
||||
|
||||
import fluidmech.common.FluidMech;
|
||||
import fluidmech.common.FluidRestrictionHandler;
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IColorCoded;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
|
@ -101,6 +102,10 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec
|
|||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (FluidRestrictionHandler.hasRestrictedStack(this.getColor().ordinal()) && !FluidRestrictionHandler.getStackForColor(this.getColor()).isLiquidEqual(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (this.isFull())
|
||||
{
|
||||
TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
|
|
@ -14,7 +14,7 @@ import universalelectricity.core.block.IConnectionProvider;
|
|||
* that doesn't change the over all network pressure. So pipes, gauges, tubes, buffers, decor
|
||||
* blocks.
|
||||
*/
|
||||
public interface IFluidNetworkPart extends IPipeConnection, IColorCoded, ITankContainer
|
||||
public interface IFluidNetworkPart extends IPipeConnection, IColorCoded, ITankContainer, INetworkPath
|
||||
{
|
||||
/**
|
||||
* gets the devices pressure from a given side for input
|
||||
|
@ -24,17 +24,7 @@ public interface IFluidNetworkPart extends IPipeConnection, IColorCoded, ITankCo
|
|||
/**
|
||||
* The max amount of liquid that can flow per request
|
||||
*/
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side);
|
||||
|
||||
/**
|
||||
* The Fluid network that this machine is part of
|
||||
*/
|
||||
public HydraulicNetwork getNetwork();
|
||||
|
||||
/**
|
||||
* sets the machines network
|
||||
*/
|
||||
public void setNetwork(HydraulicNetwork network);
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side);
|
||||
|
||||
/**
|
||||
* Called when the pressure on the machine reachs max
|
||||
|
@ -53,18 +43,5 @@ public interface IFluidNetworkPart extends IPipeConnection, IColorCoded, ITankCo
|
|||
|
||||
public void setTankContent(LiquidStack stack);
|
||||
|
||||
/**
|
||||
* Gets a list of all the connected TileEntities that this conductor is connected to. The
|
||||
* array's length should be always the 6 adjacent wires.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TileEntity[] getAdjacentConnections();
|
||||
|
||||
/**
|
||||
* Instantly refreshes all connected blocks around the conductor, recalculating the connected
|
||||
* blocks.
|
||||
*/
|
||||
public void updateAdjacentConnections();
|
||||
|
||||
}
|
||||
|
|
31
src/minecraft/hydraulic/fluidnetwork/INetworkPath.java
Normal file
31
src/minecraft/hydraulic/fluidnetwork/INetworkPath.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package hydraulic.fluidnetwork;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface INetworkPath
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a list of all the connected TileEntities that this conductor is connected to. The
|
||||
* array's length should be always the 6 adjacent wires.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TileEntity[] getAdjacentConnections();
|
||||
|
||||
/**
|
||||
* Instantly refreshes all connected blocks around the conductor, recalculating the connected
|
||||
* blocks.
|
||||
*/
|
||||
public void updateAdjacentConnections();
|
||||
|
||||
/**
|
||||
* The Fluid network that this machine is part of
|
||||
*/
|
||||
public HydraulicNetwork getNetwork();
|
||||
|
||||
/**
|
||||
* sets the machines network
|
||||
*/
|
||||
public void setNetwork(HydraulicNetwork network);
|
||||
}
|
Loading…
Reference in a new issue