This commit is contained in:
paulevsGitch 2020-10-16 21:14:23 +03:00
parent e588237fd8
commit 4dd1c55924
2 changed files with 34 additions and 20 deletions

View file

@ -137,8 +137,13 @@ public class BlocksHelper {
for (int y = start.getY(); y <= end.getY(); y++) { for (int y = start.getY(); y <= end.getY(); y++) {
POS.setY(y); POS.setY(y);
state = world.getBlockState(POS); state = world.getBlockState(POS);
// Liquids
if (!state.getFluidState().isEmpty()) {
continue;
}
// Falling blocks // Falling blocks
if (state.getBlock() instanceof FallingBlock) { else if (state.getBlock() instanceof FallingBlock) {
BlockState falling = state; BlockState falling = state;
POS.setY(POS.getY() - 1); POS.setY(POS.getY() - 1);

View file

@ -4,6 +4,7 @@ import java.util.Random;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
@ -136,7 +137,7 @@ public class EndLakeFeature extends DefaultFeature {
} }
double aspect = ((double) radius / (double) depth); double aspect = ((double) radius / (double) depth);
for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) { for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) {
POS.setX(x); POS.setX(x);
int x2 = x - blockPos.getX(); int x2 = x - blockPos.getX();
@ -158,15 +159,14 @@ public class EndLakeFeature extends DefaultFeature {
rb *= rb; rb *= rb;
if (y2 + x2 + z2 <= r) { if (y2 + x2 + z2 <= r) {
state = world.getBlockState(POS); state = world.getBlockState(POS);
if (state.isIn(BlockTagRegistry.GEN_TERRAIN) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) { if (canReplace(state)) {
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR); BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
if (y == waterLevel - 1) { if (y == waterLevel - 1) {
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0); world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
} }
} }
pos = POS.down(); pos = POS.down();
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
{
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState()); BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
if (random.nextInt(3) == 0 && pos.getY() < waterLevel - 1) { if (random.nextInt(3) == 0 && pos.getY() < waterLevel - 1) {
EndBiome biome = BiomeRegistry.getFromBiome(world.getBiome(POS)); EndBiome biome = BiomeRegistry.getFromBiome(world.getBiome(POS));
@ -176,8 +176,8 @@ public class EndLakeFeature extends DefaultFeature {
} }
} }
pos = POS.up(); pos = POS.up();
if (world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) { if (canReplace(world.getBlockState(pos))) {
while (world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) { while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR); BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
if (y == waterLevel - 1) { if (y == waterLevel - 1) {
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0); world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
@ -185,20 +185,20 @@ public class EndLakeFeature extends DefaultFeature {
pos = pos.up(); pos = pos.up();
} }
} }
} else if (y < waterLevel && y2 + x2 + z2 <= rb) { }
if (world.getBlockState(POS).getMaterial().isReplaceable()) { // Make border
if (world.isAir(POS.up())) { else if (y < waterLevel && y2 + x2 + z2 <= rb) {
state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig() //if (world.getBlockState(POS).getMaterial().isReplaceable()) {
.getTopMaterial(); if (world.isAir(POS.up())) {
BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig().getTopMaterial();
: BlockRegistry.ENDSTONE_DUST.getDefaultState()); BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state : BlockRegistry.ENDSTONE_DUST.getDefaultState());
BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE); BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE);
} else {
BlocksHelper.setWithoutUpdate(world, POS,
BlockRegistry.ENDSTONE_DUST.getDefaultState());
BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE);
}
} }
else {
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.ENDSTONE_DUST.getDefaultState());
BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE);
}
//}
} }
} }
} }
@ -224,4 +224,13 @@ public class EndLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP)); BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
} }
} }
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable()
|| state.isIn(BlockTagRegistry.GEN_TERRAIN)
|| state.isOf(BlockRegistry.ENDSTONE_DUST)
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.UNDERWATER_PLANT)
|| state.getMaterial().equals(Material.UNUSED_PLANT);
}
} }