- 4,167
- 68
- 693
По итогам исследований, получил следующих код:
Теперь ваша жидкость будет адекватно стыковаться с ванильной водой.
Код:
public class BlockFluidClassicFix extends BlockFluidClassic {
public MistWaterBlock(Fluid fluid) {
super(fluid, Material.WATER);
}
@Override
public float getFluidHeightForRender(IBlockAccess world, BlockPos pos) {
IBlockState here = world.getBlockState(pos);
IBlockState up = world.getBlockState(pos.down(densityDir));
if (here.getBlock() == this) {
if (up.getMaterial() == Material.WATER) return 1;
if (getMetaFromState(here) == getMaxRenderHeightMeta()) return 8F/9;
}
if (here.getBlock() instanceof BlockLiquid) {
if (here.getValue(BlockLiquid.LEVEL) == 8) return 1;
else if (up.getMaterial() == Material.WATER) return 1;
return Math.min(1 - BlockLiquid.getLiquidHeightPercent(here.getValue(BlockLiquid.LEVEL)), 8F/9);
}
return !here.getMaterial().isSolid() && up.getMaterial() == Material.WATER ? 1 : here.getBlock() == Blocks.AIR ? 0.0F : this.getQuantaPercentage(world, pos) * 8F/9;
}
@Override
public float getFluidHeightAverage(float... flow) {
float total = 0;
int count = 0;
float end = 0;
for (int i = 0; i < flow.length; i++) {
if (flow[i] == 1) return 1;
if (flow[i] >= 8F/9) {
total += flow[i] * 10;
count += 10;
}
if (flow[i] >= 0) {
total += flow[i];
count++;
}
}
if (end == 0) end = total / count;
return end - 0.001F;
}
@Override
public boolean displaceIfPossible(World world, BlockPos pos) {
if (world.isAirBlock(pos)) return true;
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == this || block instanceof BlockLiquid) return false;
if (displacements.containsKey(block)) {
if (displacements.get(block)) {
if (state.getBlock() != Blocks.SNOW_LAYER)
block.dropBlockAsItem(world, pos, state, 0);
return true;
}
return false;
}
Material material = state.getMaterial();
if (material.blocksMovement() || material == Material.PORTAL) {
return false;
}
int density = getDensity(world, pos);
if (density == Integer.MAX_VALUE) {
block.dropBlockAsItem(world, pos, state, 0);
return true;
}
return this.density > density;
}
@Override
public int getQuantaValue(IBlockAccess world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == Blocks.AIR) return 0;
if (state.getBlock() instanceof BlockLiquid) return quantaPerBlock - state.getValue(BlockLiquid.LEVEL);
if (state.getBlock() != this) return -1;
return quantaPerBlock - state.getValue(LEVEL);
}
}