Oh this is going to hurt

This commit is contained in:
DarkGuardsman 2013-07-08 03:21:40 -04:00
parent c304f3e6d0
commit d5fc3aaf85
9 changed files with 29 additions and 224 deletions

View file

@ -1,23 +1,18 @@
package dark.core.network.fluid;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.fluids.FluidStack;
public class FluidPressurePack implements Cloneable
{
public LiquidStack liquidStack;
public FluidStack liquidStack;
public double pressure;
public FluidPressurePack(LiquidStack liquidStack, double voltage)
public FluidPressurePack(FluidStack liquidStack, double voltage)
{
this.liquidStack = liquidStack;
this.pressure = voltage;
}
public FluidPressurePack()
{
this(new LiquidStack(0, 0, 0), 0);
}
@Override
public FluidPressurePack clone()
{

View file

@ -2,7 +2,7 @@ package dark.core.network.fluid;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.fluids.IFluidHandler;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import dark.core.api.INetworkPart;
@ -12,9 +12,7 @@ import dark.fluid.api.IDrain;
public class HydraulicNetworkHelper
{
/**
* Invalidates a TileEntity
*/
/** Invalidates a TileEntity */
public static void invalidate(TileEntity tileEntity)
{
for (int i = 0; i < 6; i++)
@ -29,7 +27,7 @@ public class HydraulicNetworkHelper
if (network != null && network instanceof NetworkFluidTiles)
{
network.removeEntity(tileEntity);
for (ITankContainer tank : ((NetworkFluidTiles) network).connectedTanks)
for (IFluidHandler tank : ((NetworkFluidTiles) network).connectedTanks)
{
if (tank instanceof IDrain)
{

View file

@ -1,44 +1,36 @@
package dark.fluid.api;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
/**
* Interface to make or use the TileEntityDrain. In real life a drain would do nothing but act as an
/** Interface to make or use the TileEntityDrain. In real life a drain would do nothing but act as an
* input or output for a pipe system. In code in order to interact with the pump the drain actual
* has to do the filling/draining for the pump. The pump only need to find the drain and tell it to
* fill or drain an area.
*
* The use of ITankContainer is optional but is need for the drain to be added to a Fluid Network
*/
public interface IDrain extends ITankContainer
* The use of ITankContainer is optional but is need for the drain to be added to a Fluid Network */
public interface IDrain extends IFluidHandler
{
/**
* In the drain you can use the ITankContainer.fill methods or use this to get the drain to
/** In the drain you can use the ITankContainer.fill methods or use this to get the drain to
* place a liquid into the world
*
* @param stack - valid LiquidStack that has a Liquid Block for it
* @param doFill - actual do the action of filling or check if it can
* @return amount of liquid used
*/
public int fillArea(LiquidStack stack, boolean doFill);
* @return amount of liquid used */
public int fillArea(FluidStack stack, boolean doFill);
/**
* Requests that this drain give the pump this liquid. The pump will have to decide if it can
/** Requests that this drain give the pump this liquid. The pump will have to decide if it can
* accept, request, and maintain this demand
*
* @param pump - requesting pump
* @param stack - liquid this pump wants for this request
*/
public void requestLiquid(TileEntity pump, LiquidStack stack);
* @param stack - liquid this pump wants for this request */
public void requestLiquid(TileEntity pump, FluidStack stack);
/**
* Request that this drain no longer supply the pump with a volume. By default a request will be
/** Request that this drain no longer supply the pump with a volume. By default a request will be
* removed from the request map after being filled. However, this can be used too stop a request
* short if the pump becomes full before the request is filled
*
* @param tileEntity - requesting pump
*/
* @param tileEntity - requesting pump */
public void stopRequesting(TileEntity tileEntity);
}

View file

@ -1,21 +1,16 @@
package dark.fluid.api;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import dark.core.api.IColorCoded;
import dark.core.api.INetworkPart;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
public interface INetworkFluidPart extends IColorCoded, ITankContainer, INetworkPart
public interface INetworkFluidPart extends IColorCoded, IFluidHandler, INetworkPart
{
/**
* Gets the part's main tank for shared storage
*/
public ILiquidTank getTank();
/** Gets the part's main tank for shared storage */
public IFluidTank getTank();
/**
* Sets the content of the part's main tank
*/
public void setTankContent(LiquidStack stack);
/** Sets the content of the part's main tank */
public void setTankContent(FluidStack stack);
}

View file

@ -3,6 +3,7 @@ package dark.fluid.client.render.pipe;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;
@ -85,7 +86,7 @@ public class RenderPipe extends TileEntitySpecialRenderer
{
if (bool && FluidRestrictionHandler.hasRestrictedStack(meta))
{
LiquidStack stack = FluidRestrictionHandler.getStackForColor(ColorCode.get(meta));
FluidStack stack = FluidRestrictionHandler.getStackForColor(ColorCode.get(meta));
String name = LiquidDictionary.findLiquidName(stack);
if (name != null)
{

View file

@ -1,131 +0,0 @@
package dark.fluid.common.fluids;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
/**
* Block prefab for gas that will spread and decay in the world as time goes on. Useful for filling
* the world with an air like gas that poisons or changes the color
*/
public class BlockGas extends Block
{
private boolean canDecay = true;
public BlockGas(String name, int id)
{
super(id, Material.air);
this.setUnlocalizedName(name);
this.setTickRandomly(true);
}
/**
* Sets the blocks decay flag
*/
public void setDecay(boolean bool)
{
this.canDecay = bool;
}
/**
* Can this block decay over time
*/
public boolean canDecay()
{
return this.canDecay;
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (!world.isRemote && world.getBlockId(x, y, z) == this.blockID)
{
Vector3 currentPos = new Vector3(x, y, z);
int meta = currentPos.getBlockMetadata(world);
if (meta-- <= 0)
{
world.setBlock(x, y, z, 0);
}
else
{
currentPos.setBlock(world, this.blockID, meta--);
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
Vector3 pos = currentPos.clone().modifyPositionFromSide(direction);
Block block = Block.blocksList[pos.getBlockID(world)];
if (block != null && block.isBlockReplaceable(world, pos.intX(), pos.intY(), pos.intZ()))
{
pos.setBlock(world, this.blockID, meta--);
}
}
}
}
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
// Suggest using this if you want the gas to harm the play when he enters it
}
@Override
public boolean canDropFromExplosion(Explosion par1Explosion)
{
return false;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
return false;
}
@Override
public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
{
return true;
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, World world, int x, int y, int z)
{
return false;
}
@Override
public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
{
return false;
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
return 0;
}
@Override
public boolean isAirBlock(World world, int x, int y, int z)
{
return false;
}
}

View file

@ -1,6 +0,0 @@
package dark.fluid.common.fluids;
public class BlockLiquidFinite
{
}

View file

@ -1,6 +0,0 @@
package dark.fluid.common.fluids;
public class BlockLiquidInfinite
{
}

View file

@ -1,33 +0,0 @@
package dark.fluid.common.fluids;
import net.minecraft.block.BlockFluid;
import net.minecraft.block.material.Material;
import net.minecraftforge.liquids.ILiquid;
public class BlockWasteLiquid extends BlockFluid implements ILiquid
{
//TODO turn into a lava type liquid with chance of corrupting connected water blocks
public BlockWasteLiquid(int par1)
{
super(par1, Material.water);
}
@Override
public int stillLiquidId()
{
return this.blockID;
}
@Override
public boolean isMetaSensitive()
{
return false;
}
@Override
public int stillLiquidMeta()
{
return this.blockID;
}
}