Lily generation

This commit is contained in:
paulevsGitch 2020-10-10 01:12:35 +03:00
parent 819de9ae0a
commit ce568b4204
3 changed files with 36 additions and 5 deletions

View file

@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
@ -50,7 +51,17 @@ public class BlockEndLily extends BlockUnderwaterPlant {
}
@Override
protected boolean isTerrain(BlockState state) {
return super.isTerrain(state) || state.getBlock() == this;
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (state.get(SHAPE) == TripleShape.TOP) {
return world.getBlockState(pos.down()).getBlock() == this;
}
else if (state.get(SHAPE) == TripleShape.BOTTOM) {
return isTerrain(world.getBlockState(pos.down()));
}
else {
BlockState up = world.getBlockState(pos.up());
BlockState down = world.getBlockState(pos.down());
return up.getBlock() == this && down.getBlock() == this;
}
}
}

View file

@ -10,6 +10,9 @@ import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import ru.betterend.blocks.BlockEndLily;
import ru.betterend.blocks.BlockEndLilySeed;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry;
@ -65,7 +68,7 @@ public class EndLakeFeature extends DefaultFeature {
POS.setZ(z);
int mz = z - maskMinZ;
if (!mask[mx][mz]) {
for (int y = waterLevel; y <= waterLevel + 20; y++) {
for (int y = waterLevel + 1; y <= waterLevel + 20; y++) {
POS.setY(y);
FluidState fluid = world.getFluidState(POS);
if (!fluid.isEmpty()) {
@ -163,8 +166,19 @@ public class EndLakeFeature extends DefaultFeature {
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.END_GROUND))
{
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
if (y < waterLevel - 1 && random.nextInt(3) == 0 && NOISE.eval(x * 0.1, z * 0.1) > 0.3) {
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.BUBBLE_CORAL.getDefaultState());
if (y < waterLevel - 1 && random.nextInt(3) == 0 && ((x + z) & 1) == 0) {
if (NOISE.eval(x * 0.1, z * 0.1, 0) > 0) {
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.BUBBLE_CORAL.getDefaultState());
}
else if (NOISE.eval(x * 0.1, z * 0.1, 1) > 0) {
world.setBlockState(POS, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM), 0);
BlockPos up = POS.up();
while (up.getY() < waterLevel) {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));
up = up.up();
}
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
}
}
}
pos = POS.up();

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:item/end_lily_seed"
}
}