Lotus generation

This commit is contained in:
paulevsGitch 2020-10-20 21:26:33 +03:00
parent d3c279bf53
commit cac7be60b1
18 changed files with 469 additions and 11 deletions

View file

@ -16,8 +16,10 @@ public class BiomeMegalake extends EndBiome {
.setSurface(BlockRegistry.ENDSTONE_DUST)
.addStructureFeature(StructureRegistry.MEGALAKE)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
.addFeature(FeatureRegistry.BUBBLE_CORAL)
.addFeature(FeatureRegistry.END_LILY)
.addFeature(FeatureRegistry.END_LOTUS)
.addFeature(FeatureRegistry.END_LOTUS_LEAF)
.addFeature(FeatureRegistry.BUBBLE_CORAL_RARE)
.addFeature(FeatureRegistry.END_LILY_RARE)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
}
}

View file

@ -0,0 +1,25 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockEndLotusSeed;
import ru.betterend.registry.BlockRegistry;
public class EndLotusFeature extends UnderwaterPlantScatter {
public EndLotusFeature(int radius) {
super(radius);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
BlockEndLotusSeed seed = (BlockEndLotusSeed) BlockRegistry.END_LOTUS_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;
}
}

View file

@ -0,0 +1,71 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockEndLotusLeaf;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.BlocksHelper;
public class EndLotusLeafFeature extends ScatterFeature {
public EndLotusLeafFeature(int radius) {
super(radius);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
if (hasLeaf(world, blockPos)) {
generateLeaf(world, blockPos);
}
}
@Override
protected int getChance() {
return 15;
}
@Override
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
return getPosOnSurface(world, pos);
}
private void generateLeaf(StructureWorldAccess world, BlockPos pos) {
Mutable p = new Mutable();
BlockState leaf = BlockRegistry.END_LOTUS_LEAF.getDefaultState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(BlockEndLotusLeaf.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(BlockEndLotusLeaf.HORIZONTAL_FACING, move).with(BlockEndLotusLeaf.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i ++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.with(BlockEndLotusLeaf.HORIZONTAL_FACING, d1).with(BlockEndLotusLeaf.SHAPE, TripleShape.TOP));
}
}
private boolean hasLeaf(StructureWorldAccess world, BlockPos pos) {
Mutable p = new Mutable();
p.setY(pos.getY());
int count = 0;
for (int x = -1; x < 2; x ++) {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z ++) {
p.setZ(pos.getZ() + z);
if (world.isAir(p))
count ++;
}
}
return count == 9;
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.isAir(blockPos) && world.getBlockState(blockPos.down()).isOf(Blocks.WATER);
}
}