Cave Flora
This commit is contained in:
parent
d0a16bf66b
commit
8a89794f08
33 changed files with 272 additions and 26 deletions
19
src/main/java/ru/betterend/blocks/BlockTerrainPlant.java
Normal file
19
src/main/java/ru/betterend/blocks/BlockTerrainPlant.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import ru.betterend.blocks.basis.BlockPlant;
|
||||
|
||||
public class BlockTerrainPlant extends BlockPlant {
|
||||
private final Block ground;
|
||||
|
||||
public BlockTerrainPlant(Block ground) {
|
||||
super(true);
|
||||
this.ground = ground;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.isOf(ground);
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import ru.betterend.blocks.BlockMossyPythadendronSapling;
|
|||
import ru.betterend.blocks.BlockOre;
|
||||
import ru.betterend.blocks.BlockPath;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
import ru.betterend.blocks.BlockTerrainPlant;
|
||||
import ru.betterend.blocks.BlockUmbrellaMoss;
|
||||
import ru.betterend.blocks.BlockUmbrellaMossTall;
|
||||
import ru.betterend.blocks.EndPortalBlock;
|
||||
|
@ -49,11 +50,13 @@ public class BlockRegistry {
|
|||
public static final Block END_MYCELIUM = registerBlock("end_mycelium", new BlockTerrain(MaterialColor.LIGHT_BLUE));
|
||||
public static final Block END_MOSS = registerBlock("end_moss", new BlockTerrain(MaterialColor.CYAN));
|
||||
public static final Block CHORUS_NYLIUM = registerBlock("chorus_nylium", new BlockTerrain(MaterialColor.MAGENTA));
|
||||
public static final Block CAVE_MOSS = registerBlock("cave_moss", new BlockTerrain(MaterialColor.PURPLE));
|
||||
|
||||
// Roads //
|
||||
public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new BlockPath(END_MYCELIUM));
|
||||
public static final Block END_MOSS_PATH = registerBlock("end_moss_path", new BlockPath(END_MOSS));
|
||||
public static final Block CHORUS_NYLIUM_PATH = registerBlock("chorus_nylium_path", new BlockPath(CHORUS_NYLIUM));
|
||||
public static final Block CAVE_MOSS_PATH = registerBlock("cave_moss_path", new BlockPath(CAVE_MOSS));
|
||||
|
||||
// Rocks //
|
||||
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND);
|
||||
|
@ -82,6 +85,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 CAVE_GRASS = registerBlock("cave_grass", new BlockTerrainPlant(CAVE_MOSS));
|
||||
|
||||
public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed());
|
||||
public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine());
|
||||
|
|
|
@ -24,6 +24,7 @@ public class BlockTagRegistry {
|
|||
addSurfaceBlock(BlockRegistry.END_MYCELIUM);
|
||||
addSurfaceBlock(BlockRegistry.CHORUS_NYLIUM);
|
||||
addSurfaceBlock(BlockRegistry.ENDSTONE_DUST);
|
||||
addSurfaceBlock(BlockRegistry.CAVE_MOSS);
|
||||
|
||||
TagHelper.addTag(GEN_TERRAIN, BlockRegistry.ENDER_ORE, BlockRegistry.FLAVOLITE.stone, BlockRegistry.VIOLECITE.stone);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.CavePlantFeature;
|
||||
import ru.betterend.world.features.DoublePlantFeature;
|
||||
import ru.betterend.world.features.EndFeature;
|
||||
import ru.betterend.world.features.EndLakeFeature;
|
||||
|
@ -36,6 +37,7 @@ public class FeatureRegistry {
|
|||
public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5);
|
||||
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 DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
|
||||
|
||||
|
@ -61,6 +63,7 @@ public class FeatureRegistry {
|
|||
addFeature(FLAVOLITE_LAYER, features);
|
||||
addFeature(ENDER_ORE, features);
|
||||
addFeature(ROUND_CAVE_RARE, features);
|
||||
addFeature(CAVE_GRASS, features);
|
||||
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
if (id.getPath().equals("end_highlands")) {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class CavePlantFeature extends FullHeightScatterFeature {
|
||||
private final Block plant;
|
||||
|
||||
public CavePlantFeature(Block plant, int radius) {
|
||||
super(radius);
|
||||
this.plant = plant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return plant.canPlaceAt(world.getBlockState(blockPos), world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
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;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public abstract class FullHeightScatterFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
private final int radius;
|
||||
|
||||
public FullHeightScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
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.down()).isAir()) {
|
||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
||||
for (int i = 0; i < count; i++) {
|
||||
float pr = r * (float) Math.sqrt(random.nextFloat());
|
||||
float theta = random.nextFloat() * MHelper.PI2;
|
||||
float x = pr * (float) Math.cos(theta);
|
||||
float z = pr * (float) Math.sin(theta);
|
||||
|
||||
POS.set(center.getX() + x, y + 5, center.getZ() + z);
|
||||
int down = BlocksHelper.downRay(world, POS, 16);
|
||||
if (down > 10) continue;
|
||||
POS.setY(POS.getY() - down);
|
||||
|
||||
if (canGenerate(world, random, center, POS, r)) {
|
||||
generate(world, random, POS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
|
@ -43,6 +44,9 @@ 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;
|
||||
|
@ -59,9 +63,17 @@ 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 (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
if ((stateGround = world.getBlockState(bpos)).isIn(BlockTagRegistry.GEN_TERRAIN) || stateGround.getMaterial().isReplaceable()) {
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue