2013-05-23 05:01:19 +00:00
|
|
|
package net.minecraftforge.fluids;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a base implementation for Fluid blocks.
|
2013-07-28 17:15:00 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* It is highly recommended that you extend this class or one of the Forge-provided child classes.
|
2013-07-28 17:15:00 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* @author King Lemming, OvermindDL1
|
2013-07-28 17:15:00 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
protected final static Map<Integer, Boolean> defaultDisplacementIds = new HashMap<Integer, Boolean>();
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
static
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
defaultDisplacementIds.put(Block.doorWood.blockID, false);
|
|
|
|
defaultDisplacementIds.put(Block.doorIron.blockID, false);
|
|
|
|
defaultDisplacementIds.put(Block.signPost.blockID, false);
|
|
|
|
defaultDisplacementIds.put(Block.signWall.blockID, false);
|
2013-07-17 04:40:49 +00:00
|
|
|
defaultDisplacementIds.put(Block.reed.blockID, false);
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
protected Map<Integer, Boolean> displacementIds = new HashMap<Integer, Boolean>();
|
|
|
|
|
|
|
|
protected int quantaPerBlock = 8;
|
|
|
|
protected float quantaPerBlockFloat = 8F;
|
|
|
|
protected int density = 1;
|
|
|
|
protected int densityDir = -1;
|
2013-08-01 03:15:42 +00:00
|
|
|
protected int temperature = 295;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
protected int tickRate = 20;
|
|
|
|
protected int renderPass = 1;
|
|
|
|
protected int maxScaledLight = 0;
|
|
|
|
|
|
|
|
protected final String fluidName;
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase(int id, Fluid fluid, Material material)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
super(id, material);
|
|
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
this.setTickRandomly(true);
|
|
|
|
this.disableStats();
|
|
|
|
|
|
|
|
this.fluidName = fluid.getName();
|
|
|
|
this.density = fluid.density;
|
2013-08-01 03:15:42 +00:00
|
|
|
this.temperature = fluid.temperature;
|
2013-05-23 05:01:19 +00:00
|
|
|
this.maxScaledLight = fluid.luminosity;
|
|
|
|
this.tickRate = fluid.viscosity / 200;
|
|
|
|
fluid.setBlockID(id);
|
|
|
|
|
|
|
|
displacementIds.putAll(defaultDisplacementIds);
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase setQuantaPerBlock(int quantaPerBlock)
|
|
|
|
{
|
|
|
|
if (quantaPerBlock > 16 || quantaPerBlock < 1) quantaPerBlock = 8;
|
2013-05-23 05:01:19 +00:00
|
|
|
this.quantaPerBlock = quantaPerBlock;
|
|
|
|
this.quantaPerBlockFloat = quantaPerBlock;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase setDensity(int density)
|
|
|
|
{
|
|
|
|
if (density == 0) density = 1;
|
2013-05-23 05:01:19 +00:00
|
|
|
this.density = density;
|
|
|
|
this.densityDir = density > 0 ? -1 : 1;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-08-01 03:15:42 +00:00
|
|
|
public BlockFluidBase setTemperature(int temperature)
|
|
|
|
{
|
|
|
|
this.temperature = temperature;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase setTickRate(int tickRate)
|
|
|
|
{
|
|
|
|
if (tickRate <= 0) tickRate = 20;
|
2013-05-23 05:01:19 +00:00
|
|
|
this.tickRate = tickRate;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase setRenderPass(int renderPass)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
this.renderPass = renderPass;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public BlockFluidBase setMaxScaledLight(int maxScaledLight)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
this.maxScaledLight = maxScaledLight;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the block at (x, y, z) is displaceable. Does not displace the block.
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean canDisplace(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (world.isAirBlock(x, y, z)) return true;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
int bId = world.getBlockId(x, y, z);
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
if (bId == blockID)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
|
|
|
|
if (displacementIds.containsKey(bId))
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return displacementIds.get(bId);
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
Material material = Block.blocksList[bId].blockMaterial;
|
|
|
|
if (material.blocksMovement() || material == Material.portal)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-28 17:15:00 +00:00
|
|
|
|
2013-08-08 23:38:46 +00:00
|
|
|
int density = getDensity(world, x, y, z);
|
|
|
|
if (density == Integer.MAX_VALUE)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.density > density)
|
2013-07-26 21:25:40 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to displace the block at (x, y, z), return true if it was displaced.
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean displaceIfPossible(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (world.isAirBlock(x, y, z))
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
|
|
|
|
int bId = world.getBlockId(x, y, z);
|
|
|
|
if (bId == blockID)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
|
|
|
|
if (displacementIds.containsKey(bId))
|
|
|
|
{
|
|
|
|
if (displacementIds.get(bId))
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
Material material = Block.blocksList[bId].blockMaterial;
|
|
|
|
if (material.blocksMovement() || material == Material.portal)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-28 17:15:00 +00:00
|
|
|
|
2013-08-08 23:38:46 +00:00
|
|
|
int density = getDensity(world, x, y, z);
|
|
|
|
if (density == Integer.MAX_VALUE)
|
|
|
|
{
|
|
|
|
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.density > density)
|
2013-07-26 21:25:40 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract int getQuantaValue(IBlockAccess world, int x, int y, int z);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public abstract boolean canCollideCheck(int meta, boolean fullHit);
|
|
|
|
|
|
|
|
public abstract int getMaxRenderHeightMeta();
|
|
|
|
|
|
|
|
/* BLOCK FUNCTIONS */
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public void onBlockAdded(World world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public void onNeighborBlockChange(World world, int x, int y, int z, int blockId)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to prevent updates on chunk generation
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean func_82506_l()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int idDropped(int par1, Random par2Random, int par3)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int quantityDropped(Random par1Random)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int tickRate(World world)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return tickRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec)
|
|
|
|
{
|
|
|
|
if (densityDir > 0) return;
|
2013-05-23 05:01:19 +00:00
|
|
|
Vec3 vec_flow = this.getFlowVector(world, x, y, z);
|
|
|
|
vec.xCoord += vec_flow.xCoord * (quantaPerBlock * 4);
|
|
|
|
vec.yCoord += vec_flow.yCoord * (quantaPerBlock * 4);
|
|
|
|
vec.zCoord += vec_flow.zCoord * (quantaPerBlock * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (maxScaledLight == 0)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return super.getLightValue(world, x, y, z);
|
|
|
|
}
|
|
|
|
int data = world.getBlockMetadata(x, y, z);
|
|
|
|
return (int) (data / quantaPerBlockFloat * maxScaledLight);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getRenderType()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return FluidRegistry.renderIdFluid;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public float getBlockBrightness(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
float lightThis = world.getLightBrightness(x, y, z);
|
|
|
|
float lightUp = world.getLightBrightness(x, y + 1, z);
|
|
|
|
return lightThis > lightUp ? lightThis : lightUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
int lightThis = world.getLightBrightnessForSkyBlocks(x, y, z, 0);
|
|
|
|
int lightUp = world.getLightBrightnessForSkyBlocks(x, y + 1, z, 0);
|
2013-05-23 05:01:19 +00:00
|
|
|
int lightThisBase = lightThis & 255;
|
2013-07-17 04:40:49 +00:00
|
|
|
int lightUpBase = lightUp & 255;
|
|
|
|
int lightThisExt = lightThis >> 16 & 255;
|
|
|
|
int lightUpExt = lightUp >> 16 & 255;
|
2013-07-28 17:15:00 +00:00
|
|
|
return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) |
|
2013-07-17 04:40:49 +00:00
|
|
|
((lightThisExt > lightUpExt ? lightThisExt : lightUpExt) << 16);
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getRenderBlockPass()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return renderPass;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
|
|
|
|
{
|
|
|
|
if (world.getBlockId(x, y, z) != blockID)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return !world.isBlockOpaqueCube(x, y, z);
|
|
|
|
}
|
|
|
|
Material mat = world.getBlockMaterial(x, y, z);
|
|
|
|
return mat == this.blockMaterial ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FLUID FUNCTIONS */
|
2013-07-17 04:40:49 +00:00
|
|
|
public static final int getDensity(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
2013-07-17 04:40:49 +00:00
|
|
|
if (!(block instanceof BlockFluidBase))
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
return ((BlockFluidBase)block).density;
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
2013-08-01 03:15:42 +00:00
|
|
|
|
|
|
|
public static final int getTemperature(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
|
|
|
if (!(block instanceof BlockFluidBase))
|
|
|
|
{
|
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
return ((BlockFluidBase)block).temperature;
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public static double getFlowDirection(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
2013-08-03 21:42:38 +00:00
|
|
|
if (!world.getBlockMaterial(x, y, z).isLiquid())
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return -1000.0;
|
|
|
|
}
|
|
|
|
Vec3 vec = ((BlockFluidBase) block).getFlowVector(world, x, y, z);
|
|
|
|
return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final int getQuantaValueBelow(IBlockAccess world, int x, int y, int z, int belowThis)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int quantaRemaining = getQuantaValue(world, x, y, z);
|
2013-07-17 04:40:49 +00:00
|
|
|
if (quantaRemaining >= belowThis)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return quantaRemaining;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final int getQuantaValueAbove(IBlockAccess world, int x, int y, int z, int aboveThis)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int quantaRemaining = getQuantaValue(world, x, y, z);
|
2013-07-17 04:40:49 +00:00
|
|
|
if (quantaRemaining <= aboveThis)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return quantaRemaining;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final float getQuantaPercentage(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int quantaRemaining = getQuantaValue(world, x, y, z);
|
|
|
|
return quantaRemaining / quantaPerBlockFloat;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public Vec3 getFlowVector(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
Vec3 vec = world.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D);
|
|
|
|
int decay = quantaPerBlock - getQuantaValue(world, x, y, z);
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
for (int side = 0; side < 4; ++side)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int x2 = x;
|
|
|
|
int z2 = z;
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case 0: --x2; break;
|
|
|
|
case 1: --z2; break;
|
|
|
|
case 2: ++x2; break;
|
|
|
|
case 3: ++z2; break;
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int otherDecay = quantaPerBlock - getQuantaValue(world, x2, y, z2);
|
2013-07-17 04:40:49 +00:00
|
|
|
if (otherDecay >= quantaPerBlock)
|
|
|
|
{
|
|
|
|
if (!world.getBlockMaterial(x2, y, z2).blocksMovement())
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
otherDecay = quantaPerBlock - getQuantaValue(world, x2, y - 1, z2);
|
2013-07-17 04:40:49 +00:00
|
|
|
if (otherDecay >= 0)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int power = otherDecay - (decay - quantaPerBlock);
|
|
|
|
vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power);
|
|
|
|
}
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
}
|
|
|
|
else if (otherDecay >= 0)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
int power = otherDecay - decay;
|
|
|
|
vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power);
|
|
|
|
}
|
|
|
|
}
|
2013-07-17 04:40:49 +00:00
|
|
|
|
|
|
|
if (world.getBlockId(x, y + 1, z) == blockID)
|
|
|
|
{
|
2013-07-28 17:15:00 +00:00
|
|
|
boolean flag =
|
2013-07-17 04:40:49 +00:00
|
|
|
isBlockSolid(world, x, y, z - 1, 2) ||
|
|
|
|
isBlockSolid(world, x, y, z + 1, 3) ||
|
|
|
|
isBlockSolid(world, x - 1, y, z, 4) ||
|
|
|
|
isBlockSolid(world, x + 1, y, z, 5) ||
|
|
|
|
isBlockSolid(world, x, y + 1, z - 1, 2) ||
|
|
|
|
isBlockSolid(world, x, y + 1, z + 1, 3) ||
|
|
|
|
isBlockSolid(world, x - 1, y + 1, z, 4) ||
|
|
|
|
isBlockSolid(world, x + 1, y + 1, z, 5);
|
2013-07-28 17:15:00 +00:00
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
if (flag)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vec = vec.normalize();
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IFluidBlock */
|
|
|
|
@Override
|
2013-07-17 04:40:49 +00:00
|
|
|
public Fluid getFluid()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return FluidRegistry.getFluid(fluidName);
|
|
|
|
}
|
2013-08-19 06:16:36 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getFilledPercentage(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
int quantaRemaining = getQuantaValue(world, x, y, z) + 1;
|
|
|
|
float remaining = quantaRemaining / quantaPerBlockFloat;
|
|
|
|
if (remaining > 1) remaining = 1.0f;
|
|
|
|
return remaining * (density > 0 ? 1 : -1);
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|