Mushrooms generation

This commit is contained in:
paulevsGitch 2020-12-25 11:50:45 +03:00
parent 989dbdb583
commit ae3756d9ee
7 changed files with 80 additions and 6 deletions

View file

@ -23,6 +23,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockAttached; import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
@ -54,6 +55,13 @@ public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypea
} }
} }
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction) && world.getBlockState(blockPos).isOpaque();
}
@Override @Override
public ERenderLayer getRenderLayer() { public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT; return ERenderLayer.CUTOUT;

View file

@ -17,12 +17,13 @@ import net.minecraft.world.WorldView;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
public abstract class BlockAttached extends BlockBaseNotFull { public abstract class BlockAttached extends BlockBaseNotFull {
public static final DirectionProperty FACING = Properties.FACING;
public BlockAttached(Settings settings) { public BlockAttached(Settings settings) {
super(settings); super(settings);
this.setDefaultState(this.getDefaultState().with(FACING, Direction.UP));
} }
public static final DirectionProperty FACING = Properties.FACING;
@Override @Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) { protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING); stateManager.add(FACING);

View file

@ -24,6 +24,7 @@ import ru.betterend.world.features.HydraluxFeature;
import ru.betterend.world.features.LanceleafFeature; import ru.betterend.world.features.LanceleafFeature;
import ru.betterend.world.features.MengerSpongeFeature; import ru.betterend.world.features.MengerSpongeFeature;
import ru.betterend.world.features.OverworldIslandFeature; import ru.betterend.world.features.OverworldIslandFeature;
import ru.betterend.world.features.SingleInvertedScatterFeature;
import ru.betterend.world.features.SinglePlantFeature; import ru.betterend.world.features.SinglePlantFeature;
import ru.betterend.world.features.UnderwaterPlantFeature; import ru.betterend.world.features.UnderwaterPlantFeature;
import ru.betterend.world.features.VineFeature; import ru.betterend.world.features.VineFeature;
@ -82,12 +83,16 @@ public class EndFeatures {
public static final EndFeature GLOW_PILLAR = new EndFeature("glow_pillar", new GlowPillarFeature(), 1); public static final EndFeature GLOW_PILLAR = new EndFeature("glow_pillar", new GlowPillarFeature(), 1);
public static final EndFeature TWISTED_UMBRELLA_MOSS = new EndFeature("twisted_umbrella_moss", new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 5); public static final EndFeature TWISTED_UMBRELLA_MOSS = new EndFeature("twisted_umbrella_moss", new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 5);
public static final EndFeature JUNGLE_GRASS = new EndFeature("jungle_grass", new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 8); public static final EndFeature JUNGLE_GRASS = new EndFeature("jungle_grass", new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 8);
public static final EndFeature SMALL_JELLYSHROOM_FLOOR = new EndFeature("small_jellyshroom_floor", new SinglePlantFeature(EndBlocks.SMALL_JELLYSHROOM, 5, 5), 4);
// Vines // // Vines //
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), 3); public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), 3);
public static final EndFeature TWISTED_VINE = new EndFeature("twisted_vine", new VineFeature(EndBlocks.TWISTED_VINE, 24), 3); public static final EndFeature TWISTED_VINE = new EndFeature("twisted_vine", new VineFeature(EndBlocks.TWISTED_VINE, 24), 3);
public static final EndFeature BULB_VINE = new EndFeature("bulb_vine", new VineFeature(EndBlocks.BULB_VINE, 24), 5); public static final EndFeature BULB_VINE = new EndFeature("bulb_vine", new VineFeature(EndBlocks.BULB_VINE, 24), 5);
// Ceil plants
public static final EndFeature SMALL_JELLYSHROOM_CEIL = new EndFeature("small_jellyshroom_ceil", new SingleInvertedScatterFeature(EndBlocks.SMALL_JELLYSHROOM, 8), 8);
// Wall Plants // // Wall Plants //
public static final EndFeature PURPLE_POLYPORE = new EndFeature("purple_polypore", new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 3), 5); public static final EndFeature PURPLE_POLYPORE = new EndFeature("purple_polypore", new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 3), 5);
public static final EndFeature PURPLE_POLYPORE_DENSE = new EndFeature("purple_polypore_dense", new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 5), 15); public static final EndFeature PURPLE_POLYPORE_DENSE = new EndFeature("purple_polypore_dense", new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 5), 15);
@ -99,6 +104,8 @@ public class EndFeatures {
public static final EndFeature TWISTED_MOSS_WOOD = new EndFeature("twisted_moss_wood", new WallPlantOnLogFeature(EndBlocks.TWISTED_MOSS, 6), 25); public static final EndFeature TWISTED_MOSS_WOOD = new EndFeature("twisted_moss_wood", new WallPlantOnLogFeature(EndBlocks.TWISTED_MOSS, 6), 25);
public static final EndFeature BULB_MOSS = new EndFeature("bulb_moss", new WallPlantFeature(EndBlocks.BULB_MOSS, 6), 1); public static final EndFeature BULB_MOSS = new EndFeature("bulb_moss", new WallPlantFeature(EndBlocks.BULB_MOSS, 6), 1);
public static final EndFeature BULB_MOSS_WOOD = new EndFeature("bulb_moss_wood", new WallPlantOnLogFeature(EndBlocks.BULB_MOSS, 6), 15); public static final EndFeature BULB_MOSS_WOOD = new EndFeature("bulb_moss_wood", new WallPlantOnLogFeature(EndBlocks.BULB_MOSS, 6), 15);
public static final EndFeature SMALL_JELLYSHROOM_WALL = new EndFeature("small_jellyshroom_wall", new WallPlantFeature(EndBlocks.SMALL_JELLYSHROOM, 6), 4);
public static final EndFeature SMALL_JELLYSHROOM_WOOD = new EndFeature("small_jellyshroom_wood", new WallPlantOnLogFeature(EndBlocks.SMALL_JELLYSHROOM, 6), 8);
// Water // // Water //
public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 6), 10); public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 6), 10);

View file

@ -14,9 +14,13 @@ public class BiomeUmbrellaJungle extends EndBiome {
.addFeature(EndFeatures.END_LAKE) .addFeature(EndFeatures.END_LAKE)
.addFeature(EndFeatures.UMBRELLA_TREE) .addFeature(EndFeatures.UMBRELLA_TREE)
.addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS) .addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_FLOOR)
.addFeature(EndFeatures.JUNGLE_GRASS) .addFeature(EndFeatures.JUNGLE_GRASS)
.addFeature(EndFeatures.CYAN_MOSS) .addFeature(EndFeatures.CYAN_MOSS)
.addFeature(EndFeatures.CYAN_MOSS_WOOD) .addFeature(EndFeatures.CYAN_MOSS_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_WALL)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_WOOD)
.addFeature(EndFeatures.SMALL_JELLYSHROOM_CEIL)
.addFeature(EndFeatures.CHARNIA_CYAN) .addFeature(EndFeatures.CHARNIA_CYAN)
.addFeature(EndFeatures.CHARNIA_GREEN) .addFeature(EndFeatures.CHARNIA_GREEN)
.addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE)

View file

@ -0,0 +1,39 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.util.BlocksHelper;
public class SingleInvertedScatterFeature extends InvertedScatterFeature {
private final Block block;
public SingleInvertedScatterFeature(Block block, int radius) {
super(radius);
this.block = block;
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
BlockState state = block.getDefaultState();
if (block instanceof BlockAttached) {
state = state.with(Properties.FACING, Direction.DOWN);
}
return state.canPlaceAt(world, blockPos);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
BlockState state = block.getDefaultState();
if (block instanceof BlockAttached) {
state = state.with(Properties.FACING, Direction.DOWN);
}
BlocksHelper.setWithoutUpdate(world, blockPos, state);
}
}

View file

@ -4,9 +4,11 @@ import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.state.property.Properties;
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.world.StructureWorldAccess; import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.blocks.basis.BlockWallPlant; import ru.betterend.blocks.basis.BlockWallPlant;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
@ -20,13 +22,26 @@ public class WallPlantFeature extends WallScatterFeature {
@Override @Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) { public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
if (block instanceof BlockWallPlant) {
BlockState state = block.getDefaultState().with(BlockWallPlant.FACING, dir); BlockState state = block.getDefaultState().with(BlockWallPlant.FACING, dir);
return block.canPlaceAt(state, world, pos); return block.canPlaceAt(state, world, pos);
} }
else if (block instanceof BlockAttached) {
BlockState state = block.getDefaultState().with(Properties.FACING, dir);
return block.canPlaceAt(state, world, pos);
}
return block.canPlaceAt(block.getDefaultState(), world, pos);
}
@Override @Override
public void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) { public void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
BlockState state = block.getDefaultState().with(BlockWallPlant.FACING, dir); BlockState state = block.getDefaultState();
if (block instanceof BlockWallPlant) {
state = state.with(BlockWallPlant.FACING, dir);
}
else if (block instanceof BlockAttached) {
state = state.with(Properties.FACING, dir);
}
BlocksHelper.setWithoutUpdate(world, pos, state); BlocksHelper.setWithoutUpdate(world, pos, state);
} }
} }

View file

@ -10,8 +10,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.client.util.math.Vector3f; import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;