Lotus generation
This commit is contained in:
parent
d3c279bf53
commit
cac7be60b1
18 changed files with 469 additions and 11 deletions
50
src/main/java/ru/betterend/blocks/BlockEndLotusLeaf.java
Normal file
50
src/main/java/ru/betterend/blocks/BlockEndLotusLeaf.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.block.ShapeContext;
|
||||||
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
|
import net.minecraft.state.StateManager;
|
||||||
|
import net.minecraft.state.property.EnumProperty;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.util.BlockMirror;
|
||||||
|
import net.minecraft.util.BlockRotation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
|
public class BlockEndLotusLeaf extends BlockBaseNotFull {
|
||||||
|
public static final EnumProperty<Direction> HORIZONTAL_FACING = Properties.HORIZONTAL_FACING;
|
||||||
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
|
private static final VoxelShape VSHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
|
||||||
|
|
||||||
|
public BlockEndLotusLeaf() {
|
||||||
|
super(FabricBlockSettings.of(Material.PLANT).sounds(BlockSoundGroup.WET_GRASS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(SHAPE, HORIZONTAL_FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
|
return VSHAPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||||
|
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||||
|
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
|
||||||
|
}
|
||||||
|
}
|
109
src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java
Normal file
109
src/main/java/ru/betterend/blocks/BlockEndLotusSeed.java
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
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.BlockProperties.TripleShape;
|
||||||
|
import ru.betterend.blocks.basis.BlockUnderwaterPlantWithAge;
|
||||||
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
|
public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge {
|
||||||
|
@Override
|
||||||
|
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
|
if (canGrow(world, pos)) {
|
||||||
|
BlockState startLeaf = BlockRegistry.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.LEAF, true);
|
||||||
|
BlockState roots = BlockRegistry.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.SHAPE, TripleShape.BOTTOM).with(BlockEndLotusStem.WATERLOGGED, true);
|
||||||
|
BlockState stem = BlockRegistry.END_LOTUS_STEM.getDefaultState();
|
||||||
|
BlockState flower = BlockRegistry.END_LOTUS_FLOWER.getDefaultState();
|
||||||
|
|
||||||
|
BlocksHelper.setWithoutUpdate(world, pos, roots);
|
||||||
|
Mutable bpos = new Mutable().set(pos);
|
||||||
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
while (world.getFluidState(bpos).isStill()) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(BlockEndLotusStem.WATERLOGGED, true));
|
||||||
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1;
|
||||||
|
TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE;
|
||||||
|
Direction dir = BlocksHelper.randomHorizontal(random);
|
||||||
|
BlockPos leafCenter = bpos.toImmutable().offset(dir);
|
||||||
|
if (hasLeaf(world, leafCenter)) {
|
||||||
|
generateLeaf(world, leafCenter);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.with(BlockEndLotusStem.SHAPE, shape).with(BlockEndLotusStem.FACING, dir));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(BlockEndLotusStem.SHAPE, shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
for (int i = 1; i <= height; i++) {
|
||||||
|
if (!world.isAir(bpos)) {
|
||||||
|
System.out.println("Set incorrect flower!");
|
||||||
|
bpos.setY(bpos.getY() - 1);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, flower);
|
||||||
|
bpos.setY(bpos.getY() - 1);
|
||||||
|
stem = world.getBlockState(bpos);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(BlockEndLotusStem.SHAPE, TripleShape.TOP));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, stem);
|
||||||
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world.isAir(bpos) || height < 0) {
|
||||||
|
bpos.setY(bpos.getY() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Set flower!");
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, flower);
|
||||||
|
bpos.setY(bpos.getY() - 1);
|
||||||
|
stem = world.getBlockState(bpos);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(BlockEndLotusStem.SHAPE, TripleShape.TOP));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canGrow(StructureWorldAccess world, BlockPos pos) {
|
||||||
|
Mutable bpos = new Mutable();
|
||||||
|
bpos.set(pos);
|
||||||
|
while (world.getBlockState(bpos).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
|
||||||
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
}
|
||||||
|
return world.isAir(bpos) && world.isAir(bpos.up());
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.util.BlockMirror;
|
||||||
|
import net.minecraft.util.BlockRotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
@ -20,15 +22,18 @@ import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class BlockEndLotusStem extends BlockBase implements Waterloggable {
|
public class BlockEndLotusStem extends BlockBase implements Waterloggable {
|
||||||
|
public static final EnumProperty<Direction> FACING = Properties.FACING;
|
||||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||||
|
public static final BooleanProperty LEAF = BooleanProperty.of("leaf");
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
private static final VoxelShape VSHAPE = Block.createCuboidShape(6, 0, 6, 10, 16, 10);
|
private static final VoxelShape VSHAPE = Block.createCuboidShape(6, 0, 6, 10, 16, 10);
|
||||||
|
|
||||||
public BlockEndLotusStem() {
|
public BlockEndLotusStem() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
|
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
|
||||||
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE));
|
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE).with(LEAF, false).with(FACING, Direction.UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +43,7 @@ public class BlockEndLotusStem extends BlockBase implements Waterloggable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
builder.add(WATERLOGGED, SHAPE);
|
builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,9 +55,20 @@ public class BlockEndLotusStem extends BlockBase implements Waterloggable {
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
WorldAccess worldAccess = ctx.getWorld();
|
WorldAccess worldAccess = ctx.getWorld();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER);
|
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||||
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||||
|
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||||
if ((Boolean) state.get(WATERLOGGED)) {
|
if ((Boolean) state.get(WATERLOGGED)) {
|
||||||
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
|
|
|
@ -16,6 +16,8 @@ import ru.betterend.blocks.BlockChorusGrass;
|
||||||
import ru.betterend.blocks.BlockEndLily;
|
import ru.betterend.blocks.BlockEndLily;
|
||||||
import ru.betterend.blocks.BlockEndLilySeed;
|
import ru.betterend.blocks.BlockEndLilySeed;
|
||||||
import ru.betterend.blocks.BlockEndLotusFlower;
|
import ru.betterend.blocks.BlockEndLotusFlower;
|
||||||
|
import ru.betterend.blocks.BlockEndLotusLeaf;
|
||||||
|
import ru.betterend.blocks.BlockEndLotusSeed;
|
||||||
import ru.betterend.blocks.BlockEndLotusStem;
|
import ru.betterend.blocks.BlockEndLotusStem;
|
||||||
import ru.betterend.blocks.BlockEndstoneDust;
|
import ru.betterend.blocks.BlockEndstoneDust;
|
||||||
import ru.betterend.blocks.BlockGlowingMoss;
|
import ru.betterend.blocks.BlockGlowingMoss;
|
||||||
|
@ -70,7 +72,9 @@ public class BlockRegistry {
|
||||||
public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new BlockLeaves(MaterialColor.MAGENTA));
|
public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new BlockLeaves(MaterialColor.MAGENTA));
|
||||||
public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE);
|
public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE);
|
||||||
|
|
||||||
|
public static final Block END_LOTUS_SEED = registerBlock("end_lotus_seed", new BlockEndLotusSeed());
|
||||||
public static final Block END_LOTUS_STEM = registerBlock("end_lotus_stem", new BlockEndLotusStem());
|
public static final Block END_LOTUS_STEM = registerBlock("end_lotus_stem", new BlockEndLotusStem());
|
||||||
|
public static final Block END_LOTUS_LEAF = registerBlockNI("end_lotus_leaf", new BlockEndLotusLeaf());
|
||||||
public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new BlockEndLotusFlower());
|
public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new BlockEndLotusFlower());
|
||||||
public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.LIGHT_BLUE, MaterialColor.CYAN);
|
public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.LIGHT_BLUE, MaterialColor.CYAN);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import ru.betterend.world.features.DoublePlantFeature;
|
||||||
import ru.betterend.world.features.EndFeature;
|
import ru.betterend.world.features.EndFeature;
|
||||||
import ru.betterend.world.features.EndLakeFeature;
|
import ru.betterend.world.features.EndLakeFeature;
|
||||||
import ru.betterend.world.features.EndLilyFeature;
|
import ru.betterend.world.features.EndLilyFeature;
|
||||||
|
import ru.betterend.world.features.EndLotusFeature;
|
||||||
|
import ru.betterend.world.features.EndLotusLeafFeature;
|
||||||
import ru.betterend.world.features.MossyGlowshroomFeature;
|
import ru.betterend.world.features.MossyGlowshroomFeature;
|
||||||
import ru.betterend.world.features.PythadendronBushFeature;
|
import ru.betterend.world.features.PythadendronBushFeature;
|
||||||
import ru.betterend.world.features.PythadendronTreeFeature;
|
import ru.betterend.world.features.PythadendronTreeFeature;
|
||||||
|
@ -35,8 +37,12 @@ public class FeatureRegistry {
|
||||||
|
|
||||||
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
||||||
|
|
||||||
public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(BlockRegistry.BUBBLE_CORAL, 4), 20);
|
public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(BlockRegistry.BUBBLE_CORAL, 10), 10);
|
||||||
public static final EndFeature END_LILY = new EndFeature("end_lily", new EndLilyFeature(5), 20);
|
public static final EndFeature BUBBLE_CORAL_RARE = new EndFeature("bubble_coral_rare", new UnderwaterPlantFeature(BlockRegistry.BUBBLE_CORAL, 3), 2);
|
||||||
|
public static final EndFeature END_LILY = new EndFeature("end_lily", new EndLilyFeature(10), 10);
|
||||||
|
public static final EndFeature END_LILY_RARE = new EndFeature("end_lily_rare", new EndLilyFeature(3), 1);
|
||||||
|
public static final EndFeature END_LOTUS = new EndFeature("end_lotus", new EndLotusFeature(5), 5);
|
||||||
|
public static final EndFeature END_LOTUS_LEAF = new EndFeature("end_lotus_leaf", new EndLotusLeafFeature(5), 5);
|
||||||
|
|
||||||
// Features //
|
// Features //
|
||||||
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
||||||
|
|
|
@ -219,6 +219,10 @@ public class BlocksHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction[] makeHorizontal() {
|
public static Direction[] makeHorizontal() {
|
||||||
return new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST };
|
return new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Direction randomHorizontal(Random random) {
|
||||||
|
return HORIZONTAL[random.nextInt(4)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ public class BiomeMegalake extends EndBiome {
|
||||||
.setSurface(BlockRegistry.ENDSTONE_DUST)
|
.setSurface(BlockRegistry.ENDSTONE_DUST)
|
||||||
.addStructureFeature(StructureRegistry.MEGALAKE)
|
.addStructureFeature(StructureRegistry.MEGALAKE)
|
||||||
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
||||||
.addFeature(FeatureRegistry.BUBBLE_CORAL)
|
.addFeature(FeatureRegistry.END_LOTUS)
|
||||||
.addFeature(FeatureRegistry.END_LILY)
|
.addFeature(FeatureRegistry.END_LOTUS_LEAF)
|
||||||
|
.addFeature(FeatureRegistry.BUBBLE_CORAL_RARE)
|
||||||
|
.addFeature(FeatureRegistry.END_LILY_RARE)
|
||||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=north,shape=bottom": { "model": "betterend:block/end_lotus_leaf_center" },
|
||||||
|
"facing=south,shape=bottom": { "model": "betterend:block/end_lotus_leaf_center" },
|
||||||
|
"facing=east,shape=bottom": { "model": "betterend:block/end_lotus_leaf_center" },
|
||||||
|
"facing=west,shape=bottom": { "model": "betterend:block/end_lotus_leaf_center" },
|
||||||
|
|
||||||
|
"facing=north,shape=middle": { "model": "betterend:block/end_lotus_leaf_side" },
|
||||||
|
"facing=south,shape=middle": { "model": "betterend:block/end_lotus_leaf_side", "y": 180 },
|
||||||
|
"facing=east,shape=middle": { "model": "betterend:block/end_lotus_leaf_side", "y": 90 },
|
||||||
|
"facing=west,shape=middle": { "model": "betterend:block/end_lotus_leaf_side", "y": 270 },
|
||||||
|
|
||||||
|
"facing=north,shape=top": { "model": "betterend:block/end_lotus_leaf_corner" },
|
||||||
|
"facing=south,shape=top": { "model": "betterend:block/end_lotus_leaf_corner", "y": 180 },
|
||||||
|
"facing=east,shape=top": { "model": "betterend:block/end_lotus_leaf_corner", "y": 90 },
|
||||||
|
"facing=west,shape=top": { "model": "betterend:block/end_lotus_leaf_corner", "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,46 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
"shape=top": { "model": "betterend:block/end_lotus_stem_top" },
|
"leaf=false,shape=top,facing=north": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
"shape=middle": { "model": "betterend:block/end_lotus_stem" },
|
"leaf=false,shape=top,facing=south": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
"shape=bottom": { "model": "betterend:block/end_lotus_roots" }
|
"leaf=false,shape=top,facing=east": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
|
"leaf=false,shape=top,facing=west": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
|
"leaf=false,shape=top,facing=up": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
|
"leaf=false,shape=top,facing=down": { "model": "betterend:block/end_lotus_stem_top" },
|
||||||
|
|
||||||
|
"leaf=false,shape=bottom,facing=north": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
"leaf=false,shape=bottom,facing=south": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
"leaf=false,shape=bottom,facing=east": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
"leaf=false,shape=bottom,facing=west": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
"leaf=false,shape=bottom,facing=up": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
"leaf=false,shape=bottom,facing=down": { "model": "betterend:block/end_lotus_roots" },
|
||||||
|
|
||||||
|
"leaf=false,shape=middle,facing=north": { "model": "betterend:block/end_lotus_stem", "x": 90 },
|
||||||
|
"leaf=false,shape=middle,facing=south": { "model": "betterend:block/end_lotus_stem", "z": 90 },
|
||||||
|
"leaf=false,shape=middle,facing=east": { "model": "betterend:block/end_lotus_stem", "x": 90 },
|
||||||
|
"leaf=false,shape=middle,facing=west": { "model": "betterend:block/end_lotus_stem", "z": 90 },
|
||||||
|
"leaf=false,shape=middle,facing=up": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=false,shape=middle,facing=down": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
|
||||||
|
"leaf=true,shape=middle,facing=north": { "model": "betterend:block/end_lotus_stem_leaf", "y": 180 },
|
||||||
|
"leaf=true,shape=middle,facing=south": { "model": "betterend:block/end_lotus_stem_leaf" },
|
||||||
|
"leaf=true,shape=middle,facing=east": { "model": "betterend:block/end_lotus_stem_leaf", "y": 270 },
|
||||||
|
"leaf=true,shape=middle,facing=west": { "model": "betterend:block/end_lotus_stem_leaf", "y": 90 },
|
||||||
|
|
||||||
|
"leaf=true,shape=middle,facing=up": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=middle,facing=down": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
|
||||||
|
"leaf=true,shape=top,facing=north": { "model": "betterend:block/end_lotus_stem_top_leaf", "y": 180 },
|
||||||
|
"leaf=true,shape=top,facing=east": { "model": "betterend:block/end_lotus_stem_top_leaf", "y": 270 },
|
||||||
|
"leaf=true,shape=top,facing=south": { "model": "betterend:block/end_lotus_stem_top_leaf" },
|
||||||
|
"leaf=true,shape=top,facing=west": { "model": "betterend:block/end_lotus_stem_top_leaf", "y": 90 },
|
||||||
|
"leaf=true,shape=top,facing=up": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=top,facing=down": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
|
||||||
|
"leaf=true,shape=bottom,facing=north": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=bottom,facing=east": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=bottom,facing=south": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=bottom,facing=west": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=bottom,facing=up": { "model": "betterend:block/end_lotus_stem" },
|
||||||
|
"leaf=true,shape=bottom,facing=down": { "model": "betterend:block/end_lotus_stem" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/plane_bottom",
|
||||||
|
"textures": {
|
||||||
|
"texture": "betterend:block/end_lotus_leaf_center"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/plane_bottom",
|
||||||
|
"textures": {
|
||||||
|
"texture": "betterend:block/end_lotus_leaf_corner"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/plane_bottom",
|
||||||
|
"textures": {
|
||||||
|
"texture": "betterend:block/end_lotus_leaf_side"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"particle": "betterend:block/end_lotus_stem",
|
||||||
|
"texture": "betterend:block/end_lotus_stem",
|
||||||
|
"texture1": "betterend:block/end_lotus_leaf_cutout"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"__comment": "Box1",
|
||||||
|
"from": [ 6, 0, 6 ],
|
||||||
|
"to": [ 10, 16, 10 ],
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture", "cullface": "down" },
|
||||||
|
"up": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture", "cullface": "up" },
|
||||||
|
"north": { "uv": [ 0, 0, 4, 16 ], "texture": "#texture" },
|
||||||
|
"south": { "uv": [ 0, 0, 4, 16 ], "texture": "#texture" },
|
||||||
|
"west": { "uv": [ 0, 0, 4, 16 ], "texture": "#texture" },
|
||||||
|
"east": { "uv": [ 0, 0, 4, 16 ], "texture": "#texture" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "PlaneY2",
|
||||||
|
"from": [ 0, 0, 0 ],
|
||||||
|
"to": [ 16, 0.001, 16 ],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1" },
|
||||||
|
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"particle": "betterend:block/end_lotus_stem",
|
||||||
|
"texture": "betterend:block/end_lotus_stem",
|
||||||
|
"leaf": "betterend:block/end_lotus_leaf_cutout"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"__comment": "Box1",
|
||||||
|
"from": [ 6, 0, 6 ],
|
||||||
|
"to": [ 10, 12, 10 ],
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture", "cullface": "down" },
|
||||||
|
"north": { "uv": [ 0, 4, 4, 16 ], "texture": "#texture" },
|
||||||
|
"south": { "uv": [ 0, 4, 4, 16 ], "texture": "#texture" },
|
||||||
|
"west": { "uv": [ 0, 4, 4, 16 ], "texture": "#texture" },
|
||||||
|
"east": { "uv": [ 0, 4, 4, 16 ], "texture": "#texture" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "Box2",
|
||||||
|
"from": [ 5, 12, 5 ],
|
||||||
|
"to": [ 11, 16, 11 ],
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 4, 8, 10, 14 ], "texture": "#texture" },
|
||||||
|
"up": { "uv": [ 4, 8, 10, 14 ], "texture": "#texture", "cullface": "up" },
|
||||||
|
"north": { "uv": [ 4, 4, 10, 8 ], "texture": "#texture" },
|
||||||
|
"south": { "uv": [ 4, 4, 10, 8 ], "texture": "#texture" },
|
||||||
|
"west": { "uv": [ 4, 4, 10, 8 ], "texture": "#texture" },
|
||||||
|
"east": { "uv": [ 4, 4, 10, 8 ], "texture": "#texture" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "PlaneY3",
|
||||||
|
"from": [ 0, 0, 0 ],
|
||||||
|
"to": [ 16, 0.001, 16 ],
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 0, 16, 16, 0 ], "texture": "#leaf" },
|
||||||
|
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"textures": {
|
||||||
|
"particle": "#texture"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"__comment": "PlaneY1",
|
||||||
|
"from": [ 0, 0, 0 ],
|
||||||
|
"to": [ 16, 0.001, 16 ],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 0, 16, 16, 0 ], "texture": "#texture" },
|
||||||
|
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Add table
Add a link
Reference in a new issue