Fix terrain block

This commit is contained in:
paulevsGitch 2021-04-29 18:08:18 +03:00
parent 98b740782d
commit 27bac7373d
5 changed files with 69 additions and 40 deletions

View file

@ -74,13 +74,12 @@ public class EndTerrainBlock extends BlockBase {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
if (random.nextInt(16) == 0 && !canStay(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
public boolean canStay(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {

View file

@ -83,14 +83,14 @@ public class TripleTerrainBlock extends EndTerrainBlock {
return;
}
else if (random.nextInt(16) == 0) {
boolean bottom = canSurviveBottom(world, pos);
boolean bottom = canStayBottom(world, pos);
if (shape == TripleShape.TOP) {
if (!bottom) {
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
}
}
else {
boolean top = canSurvive(state, world, pos) || isMiddle(world.getBlockState(pos.above()));
boolean top = canStay(state, world, pos) || isMiddle(world.getBlockState(pos.above()));
if (!top && !bottom) {
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
}
@ -104,7 +104,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
}
}
protected boolean canSurviveBottom(LevelReader world, BlockPos pos) {
protected boolean canStayBottom(LevelReader world, BlockPos pos) {
BlockPos blockPos = pos.below();
BlockState blockState = world.getBlockState(blockPos);
if (isMiddle(blockState)) {