Skip to content
Permalink
Browse files

I think I finally cleared up most of the discrepancies.

  • Loading branch information
DavidTriphon committed Aug 13, 2019
1 parent 728b9c8 commit ff2f117a250065d69726ce4ebc1c2e1e94c1b7d8
Showing with 51 additions and 25 deletions.
  1. +51 −25 src/main/java/net/dries007/tfc/objects/blocks/BlockFluidTFC.java
@@ -52,35 +52,61 @@ public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random ra
@Override
public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand)
{
IBlockState newState = world.getBlockState(pos);

super.updateTick(world, pos, state, rand);

// have to catch the updates that the super call did
IBlockState newState = world.getBlockState(pos);

// detect if we should replace ourselves with a different BlockFluidTFC type
if (newState.getBlock() == this)
if (!isSourceBlock(world, pos))
{
// we have to make sure we're getting the updated state as a result of the super call
int flowMeta = newState.getValue(LEVEL) + 1;

// if we are being powered from above, use a meta of 1
if (world.getBlockState(pos.down(densityDir)).getBlock() == this)
{
flowMeta = 1;
}
int minMeta = 100;
int currentMeta = quantaPerBlock - 1;
BlockFluidTFC blockType = this;

if (flowMeta >= quantaPerBlock)
return;
if (newState.getBlock() == this)
currentMeta = newState.getValue(LEVEL);

for (EnumFacing side : EnumFacing.HORIZONTALS)
// only check adjacently if here isn't powered from above
if (world.getBlockState(pos.down(densityDir)).getBlock() != this)
{
BlockPos neighborPos = pos.offset(side);
IBlockState neighborState = world.getBlockState(neighborPos);
Block neighborBlock = neighborState.getBlock();
if (neighborBlock != this && neighborBlock instanceof BlockFluidTFC)
for (EnumFacing side : EnumFacing.HORIZONTALS)
{
flowIntoBlock(world, neighborPos, flowMeta);
BlockPos neighborPos = pos.offset(side);
IBlockState neighborState = world.getBlockState(neighborPos);
Block block = neighborState.getBlock();

if (block instanceof BlockFluidTFC)
{
BlockFluidTFC neighborBlock = (BlockFluidTFC) block;
int neighborMeta;
Block neighborAboveBlock = world.getBlockState(neighborPos.up(densityDir)).getBlock();
if (neighborAboveBlock == neighborBlock)
neighborMeta = 0;
else
neighborMeta = neighborState.getValue(LEVEL);

if (neighborMeta < minMeta)
{
blockType = neighborBlock;
minMeta = neighborMeta;
}
else if (neighborMeta == minMeta)
{
if (neighborBlock.getDensity() > blockType.getDensity() ||
(neighborBlock == this && neighborBlock.getDensity() >= blockType.getDensity()))
{
blockType = neighborBlock;
}
}
}
}
}

if (minMeta + 1 < currentMeta && blockType != this)
{
world.setBlockState(pos, blockType.getDefaultState().withProperty(LEVEL, currentMeta), 3);
}
}
}

@@ -317,8 +343,8 @@ protected boolean canFlowInto(IBlockAccess world, BlockPos pos)
@Override
public IBlockState getExtendedState(@Nonnull IBlockState oldState, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
{
IExtendedBlockState state = (IExtendedBlockState)oldState;
state = state.withProperty(FLOW_DIRECTION, (float)getFlowDirection(world, pos));
IExtendedBlockState state = (IExtendedBlockState) oldState;
state = state.withProperty(FLOW_DIRECTION, (float) getFlowDirection(world, pos));
IBlockState[][] upBlockState = new IBlockState[3][3];
float[][] height = new float[3][3];
float[][] corner = new float[2][2];
@@ -355,10 +381,10 @@ public IBlockState getExtendedState(@Nonnull IBlockState oldState, @Nonnull IBlo
}
}
//check for downflow above corners
boolean n = isMergeableFluid(upBlockState[0][1]);
boolean s = isMergeableFluid(upBlockState[2][1]);
boolean w = isMergeableFluid(upBlockState[1][0]);
boolean e = isMergeableFluid(upBlockState[1][2]);
boolean n = isMergeableFluid(upBlockState[0][1]);
boolean s = isMergeableFluid(upBlockState[2][1]);
boolean w = isMergeableFluid(upBlockState[1][0]);
boolean e = isMergeableFluid(upBlockState[1][2]);
boolean nw = isMergeableFluid(upBlockState[0][0]);
boolean ne = isMergeableFluid(upBlockState[0][2]);
boolean sw = isMergeableFluid(upBlockState[2][0]);

0 comments on commit ff2f117

Please sign in to comment.
You can’t perform that action at this time.