Cave bushes
This commit is contained in:
parent
8a89794f08
commit
28d501f351
19 changed files with 264 additions and 11 deletions
|
@ -24,7 +24,14 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
|
|||
private static final Vec3i[] COLORS;
|
||||
|
||||
public AuroraCrystalBlock() {
|
||||
super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES).sounds(BlockSoundGroup.GLASS).lightLevel(15).nonOpaque());
|
||||
super(FabricBlockSettings.of(Material.GLASS)
|
||||
.breakByTool(FabricToolTags.PICKAXES)
|
||||
.suffocates((state, world, pos) -> { return false; })
|
||||
.hardness(1F)
|
||||
.resistance(1F)
|
||||
.sounds(BlockSoundGroup.GLASS)
|
||||
.lightLevel(15)
|
||||
.nonOpaque());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,9 +17,11 @@ 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.client.ERenderLayer;
|
||||
import ru.betterend.client.IRenderTypeable;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class BlockEndLotusLeaf extends BlockBaseNotFull {
|
||||
public class BlockEndLotusLeaf extends BlockBaseNotFull implements IRenderTypeable {
|
||||
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);
|
||||
|
@ -47,4 +49,9 @@ public class BlockEndLotusLeaf extends BlockBaseNotFull {
|
|||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.client.ERenderLayer;
|
||||
import ru.betterend.client.IRenderTypeable;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
|
||||
public class BlockSimpleLeaves extends BlockBaseNotFull implements IRenderTypeable {
|
||||
public BlockSimpleLeaves(MaterialColor color) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.sounds(BlockSoundGroup.GRASS)
|
||||
.nonOpaque()
|
||||
.allowsSpawning((state, world, pos, type) -> { return false; })
|
||||
.suffocates((state, world, pos) -> { return false; })
|
||||
.blockVision((state, world, pos) -> { return false; })
|
||||
.materialColor(color));
|
||||
}
|
||||
|
||||
public BlockSimpleLeaves(MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.sounds(BlockSoundGroup.GRASS)
|
||||
.nonOpaque()
|
||||
.lightLevel(light)
|
||||
.allowsSpawning((state, world, pos, type) -> { return false; })
|
||||
.suffocates((state, world, pos) -> { return false; })
|
||||
.blockVision((state, world, pos) -> { return false; })
|
||||
.materialColor(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
return Patterned.createJson(data, blockId, blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
return Patterned.createJson(Patterned.BASE_BLOCK_MODEL, blockId, blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.BLOCK_STATES_PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ import ru.betterend.blocks.RunedFlavolite;
|
|||
import ru.betterend.blocks.TerminiteBlock;
|
||||
import ru.betterend.blocks.basis.BlockGlowingFur;
|
||||
import ru.betterend.blocks.basis.BlockLeaves;
|
||||
import ru.betterend.blocks.basis.BlockSimpleLeaves;
|
||||
import ru.betterend.blocks.basis.BlockVine;
|
||||
import ru.betterend.blocks.complex.StoneMaterial;
|
||||
import ru.betterend.blocks.complex.WoodenMaterial;
|
||||
|
@ -85,6 +86,7 @@ public class BlockRegistry {
|
|||
public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new BlockUmbrellaMoss());
|
||||
public static final Block UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new BlockUmbrellaMossTall());
|
||||
public static final Block CREEPING_MOSS = registerBlock("creeping_moss", new BlockGlowingMoss(11));
|
||||
public static final Block CHORUS_GRASS = registerBlock("chorus_grass", new BlockChorusGrass());
|
||||
public static final Block CAVE_GRASS = registerBlock("cave_grass", new BlockTerrainPlant(CAVE_MOSS));
|
||||
|
||||
public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed());
|
||||
|
@ -96,7 +98,7 @@ public class BlockRegistry {
|
|||
public static final Block END_LILY = registerBlockNI("end_lily", new BlockEndLily());
|
||||
public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new BlockEndLilySeed());
|
||||
|
||||
public static final Block CHORUS_GRASS = registerBlock("chorus_grass", new BlockChorusGrass());
|
||||
public static final Block CAVE_BUSH = registerBlock("cave_bush", new BlockSimpleLeaves(MaterialColor.MAGENTA));
|
||||
|
||||
// Vines //
|
||||
public static final Block DENSE_VINE = registerBlock("dense_vine", new BlockVine(15, true));
|
||||
|
|
|
@ -9,6 +9,8 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import ru.betterend.world.features.BlueVineFeature;
|
||||
import ru.betterend.world.features.CaveBushFeature;
|
||||
import ru.betterend.world.features.CaveBushFeatureCeil;
|
||||
import ru.betterend.world.features.CavePlantFeature;
|
||||
import ru.betterend.world.features.DoublePlantFeature;
|
||||
import ru.betterend.world.features.EndFeature;
|
||||
|
@ -38,6 +40,8 @@ public class FeatureRegistry {
|
|||
public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1);
|
||||
public static final EndFeature CHORUS_GRASS = new EndFeature("chorus_grass", new SinglePlantFeature(BlockRegistry.CHORUS_GRASS, 4), 5);
|
||||
public static final EndFeature CAVE_GRASS = new EndFeature("cave_grass", new CavePlantFeature(BlockRegistry.CAVE_GRASS, 7), 5);
|
||||
public static final EndFeature CAVE_BUSH = new EndFeature("cave_bush", new CaveBushFeature(5), 2);
|
||||
public static final EndFeature CAVE_BUSH_CEIL = new EndFeature("cave_bush_ceil", new CaveBushFeatureCeil(15), 10);
|
||||
|
||||
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
||||
|
||||
|
@ -64,6 +68,8 @@ public class FeatureRegistry {
|
|||
addFeature(ENDER_ORE, features);
|
||||
addFeature(ROUND_CAVE_RARE, features);
|
||||
addFeature(CAVE_GRASS, features);
|
||||
addFeature(CAVE_BUSH, features);
|
||||
addFeature(CAVE_BUSH_CEIL, features);
|
||||
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
if (id.getPath().equals("end_highlands")) {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class CaveBushFeature extends FullHeightScatterFeature {
|
||||
public CaveBushFeature(int radius) {
|
||||
super(radius);
|
||||
}
|
||||
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return world.getBlockState(blockPos.down()).isOf(BlockRegistry.CAVE_MOSS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
float radius = MHelper.randRange(0.8F, 2.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(BlockRegistry.CAVE_BUSH);
|
||||
sphere = new SDFScale3D().setScale(MHelper.randRange(0.8F, 1.2F, random), MHelper.randRange(0.8F, 1.2F, random), MHelper.randRange(0.8F, 1.2F, random)).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
sphere.fillRecursive(world, blockPos);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, BlockRegistry.CAVE_BUSH);
|
||||
}
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class CaveBushFeatureCeil extends InvertedScatterFeature {
|
||||
public CaveBushFeatureCeil(int radius) {
|
||||
super(radius);
|
||||
}
|
||||
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return blockPos.getY() < 64 && world.isAir(blockPos) && world.getBlockState(blockPos.up()).isIn(BlockTagRegistry.GEN_TERRAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
float radius = MHelper.randRange(0.8F, 2.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(BlockRegistry.CAVE_BUSH);
|
||||
sphere = new SDFScale3D().setScale(MHelper.randRange(0.8F, 1.2F, random), MHelper.randRange(0.8F, 1.2F, random), MHelper.randRange(0.8F, 1.2F, random)).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
sphere.fillRecursive(world, blockPos.down());
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.down(), BlockRegistry.CAVE_BUSH);
|
||||
}
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -24,7 +25,9 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
|
|||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
for (int y = 128; y > 0; y--) {
|
||||
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, center.getX(), center.getZ());
|
||||
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
|
||||
for (int y = maxY; y > minY; y--) {
|
||||
POS.set(center.getX(), y, center.getZ());
|
||||
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.up()).isAir()) {
|
||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.world.features;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
|
@ -44,9 +45,7 @@ public class RoundCave extends DefaultFeature {
|
|||
double nr = radius * 0.25;
|
||||
|
||||
Mutable bpos = new Mutable();
|
||||
BlockState stateGround;
|
||||
BlockState terrain = BlockRegistry.CAVE_MOSS.getDefaultState();
|
||||
//BlockState grass = BlockRegistry.CAVE_GRASS.getDefaultState();
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xsq = x - pos.getX();
|
||||
xsq *= xsq;
|
||||
|
@ -63,16 +62,12 @@ public class RoundCave extends DefaultFeature {
|
|||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||
double dist = xsq + ysq + zsq;
|
||||
if (dist < r * r) {
|
||||
if ((stateGround = world.getBlockState(bpos)).isIn(BlockTagRegistry.GEN_TERRAIN) || stateGround.getMaterial().isReplaceable()) {
|
||||
if (isReplaceable(world.getBlockState(bpos))) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, AIR);
|
||||
}
|
||||
bpos.setY(y - 1);
|
||||
if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, terrain);
|
||||
/*if (random.nextInt(8) == 0) {
|
||||
bpos.setY(y);
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, grass);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +90,15 @@ public class RoundCave extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isReplaceable(BlockState state) {
|
||||
return state.isIn(BlockTagRegistry.GEN_TERRAIN)
|
||||
|| state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.LEAVES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"variants": {
|
||||
"": [
|
||||
{ "model": "betterend:block/cave_bush_01", "weight": 3 },
|
||||
{ "model": "betterend:block/cave_bush_02" },
|
||||
{ "model": "betterend:block/cave_bush_03" },
|
||||
{ "model": "betterend:block/cave_bush_04" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"defaultMaterial": "betterend:waving_floor_glow_50_blue"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"defaultMaterial": "betterend:glow_50_blue"
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"layers": [
|
||||
{
|
||||
"vertexSource": "canvas:shaders/material/default.vert",
|
||||
"fragmentSource": "betterend:shaders/material/glow_50_blue.frag",
|
||||
"disableAo": true,
|
||||
"disableDiffuse": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "betterend:block/cave_bush_leaves_1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "betterend:block/cave_bush_leaves_2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "betterend:block/cave_bush_leaves_3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "betterend:block/cave_bush_leaves_4"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "betterend:block/cave_bush_01"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Add table
Add a link
Reference in a new issue