added to fluid Helper
This commit is contained in:
parent
c961f3634e
commit
c20acfc473
1 changed files with 51 additions and 6 deletions
|
@ -4,6 +4,7 @@ import universalelectricity.core.vector.Vector3;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
@ -24,7 +25,11 @@ public class FluidHelper
|
|||
/** Gets a fluid from blockID */
|
||||
public static Fluid getFluidFromBlockID(int id)
|
||||
{
|
||||
if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID)
|
||||
if (Block.blocksList[id] instanceof IFluidBlock)
|
||||
{
|
||||
return ((IFluidBlock) Block.blocksList[id]).getFluid();
|
||||
}
|
||||
else if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID)
|
||||
{
|
||||
return FluidRegistry.getFluid("water");
|
||||
}
|
||||
|
@ -32,19 +37,59 @@ public class FluidHelper
|
|||
{
|
||||
return FluidRegistry.getFluid("lava");
|
||||
}
|
||||
else if (Block.blocksList[id] instanceof IFluidBlock)
|
||||
{
|
||||
return ((IFluidBlock) Block.blocksList[id]).getFluid();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FluidStack getStack(FluidStack stack, int amount)
|
||||
{
|
||||
if(stack != null)
|
||||
if (stack != null)
|
||||
{
|
||||
return new FluidStack(stack.getFluid(), amount);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static FluidStack drainBlock(World world, Vector3 vector, boolean doDrain)
|
||||
{
|
||||
Block block = Block.blocksList[vector.getBlockID(world)];
|
||||
if (block != null)
|
||||
{
|
||||
if (block instanceof IFluidBlock && ((IFluidBlock) block).canDrain(world, vector.intX(), vector.intY(), vector.intZ()))
|
||||
{
|
||||
return ((IFluidBlock) block).drain(world, vector.intX(), vector.intY(), vector.intZ(), doDrain);
|
||||
}
|
||||
else if (block.blockID == Block.waterStill.blockID && vector.getBlockMetadata(world) == 0)
|
||||
{
|
||||
if (doDrain)
|
||||
{
|
||||
vector.setBlock(world, 0);
|
||||
}
|
||||
return new FluidStack(FluidRegistry.getFluid("water"), FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
else if (block.blockID == Block.lavaStill.blockID && vector.getBlockMetadata(world) == 0)
|
||||
{
|
||||
if (doDrain)
|
||||
{
|
||||
vector.setBlock(world, 0);
|
||||
}
|
||||
return new FluidStack(FluidRegistry.getFluid("lava"), FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isFillable(World world, Vector3 node)
|
||||
{
|
||||
Block block = Block.blocksList[node.getBlockID(world)];
|
||||
if ((block.blockID == Block.waterStill.blockID || block.blockID == Block.waterMoving.blockID) && node.getBlockMetadata(world) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((block.blockID == Block.lavaStill.blockID || block.blockID == Block.lavaMoving.blockID) && node.getBlockMetadata(world) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue