Cave Flora

This commit is contained in:
paulevsGitch 2020-10-21 16:12:18 +03:00
parent d0a16bf66b
commit 8a89794f08
33 changed files with 272 additions and 26 deletions

View 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);
}
}

View file

@ -28,6 +28,7 @@ import ru.betterend.blocks.BlockMossyPythadendronSapling;
import ru.betterend.blocks.BlockOre; import ru.betterend.blocks.BlockOre;
import ru.betterend.blocks.BlockPath; import ru.betterend.blocks.BlockPath;
import ru.betterend.blocks.BlockTerrain; import ru.betterend.blocks.BlockTerrain;
import ru.betterend.blocks.BlockTerrainPlant;
import ru.betterend.blocks.BlockUmbrellaMoss; import ru.betterend.blocks.BlockUmbrellaMoss;
import ru.betterend.blocks.BlockUmbrellaMossTall; import ru.betterend.blocks.BlockUmbrellaMossTall;
import ru.betterend.blocks.EndPortalBlock; 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_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 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 CHORUS_NYLIUM = registerBlock("chorus_nylium", new BlockTerrain(MaterialColor.MAGENTA));
public static final Block CAVE_MOSS = registerBlock("cave_moss", new BlockTerrain(MaterialColor.PURPLE));
// Roads // // Roads //
public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new BlockPath(END_MYCELIUM)); 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 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 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 // // Rocks //
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND); 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 = registerBlock("umbrella_moss", new BlockUmbrellaMoss());
public static final Block UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new BlockUmbrellaMossTall()); 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 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_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed());
public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine()); public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine());

View file

@ -24,6 +24,7 @@ public class BlockTagRegistry {
addSurfaceBlock(BlockRegistry.END_MYCELIUM); addSurfaceBlock(BlockRegistry.END_MYCELIUM);
addSurfaceBlock(BlockRegistry.CHORUS_NYLIUM); addSurfaceBlock(BlockRegistry.CHORUS_NYLIUM);
addSurfaceBlock(BlockRegistry.ENDSTONE_DUST); addSurfaceBlock(BlockRegistry.ENDSTONE_DUST);
addSurfaceBlock(BlockRegistry.CAVE_MOSS);
TagHelper.addTag(GEN_TERRAIN, BlockRegistry.ENDER_ORE, BlockRegistry.FLAVOLITE.stone, BlockRegistry.VIOLECITE.stone); TagHelper.addTag(GEN_TERRAIN, BlockRegistry.ENDER_ORE, BlockRegistry.FLAVOLITE.stone, BlockRegistry.VIOLECITE.stone);
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import ru.betterend.world.features.BlueVineFeature; import ru.betterend.world.features.BlueVineFeature;
import ru.betterend.world.features.CavePlantFeature;
import ru.betterend.world.features.DoublePlantFeature; 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;
@ -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 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 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 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); 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(FLAVOLITE_LAYER, features);
addFeature(ENDER_ORE, features); addFeature(ENDER_ORE, features);
addFeature(ROUND_CAVE_RARE, features); addFeature(ROUND_CAVE_RARE, features);
addFeature(CAVE_GRASS, features);
if (id.getNamespace().equals("minecraft")) { if (id.getNamespace().equals("minecraft")) {
if (id.getPath().equals("end_highlands")) { if (id.getPath().equals("end_highlands")) {

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -2,6 +2,7 @@ package ru.betterend.world.features;
import java.util.Random; import java.util.Random;
import net.minecraft.block.BlockState;
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.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
@ -43,6 +44,9 @@ public class RoundCave extends DefaultFeature {
double nr = radius * 0.25; double nr = radius * 0.25;
Mutable bpos = new Mutable(); 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++) { for (int x = x1; x <= x2; x++) {
int xsq = x - pos.getX(); int xsq = x - pos.getX();
xsq *= xsq; 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 r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
double dist = xsq + ysq + zsq; double dist = xsq + ysq + zsq;
if (dist < r * r) { 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); 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);
}*/
}
} }
} }
} }

View file

@ -0,0 +1,14 @@
{
"variants": {
"": [
{ "model": "betterend:block/cave_grass_01" },
{ "model": "betterend:block/cave_grass_02" },
{ "model": "betterend:block/cave_grass_03" },
{ "model": "betterend:block/cave_grass_04" },
{ "model": "betterend:block/cave_grass_05" },
{ "model": "betterend:block/cave_grass_06" },
{ "model": "betterend:block/cave_grass_07" },
{ "model": "betterend:block/cave_grass_08" }
]
}
}

View file

@ -0,0 +1,21 @@
{
"variants": {
"": [
{
"model": "betterend:block/cave_moss"
},
{
"model": "betterend:block/cave_moss",
"y": 90
},
{
"model": "betterend:block/cave_moss",
"y": 180
},
{
"model": "betterend:block/cave_moss",
"y": 270
}
]
}
}

View file

@ -0,0 +1,10 @@
{
"variants": {
"": [
{ "model": "betterend:block/cave_moss_path" },
{ "model": "betterend:block/cave_moss_path", "y": 90 },
{ "model": "betterend:block/cave_moss_path", "y": 180 },
{ "model": "betterend:block/cave_moss_path", "y": 270 }
]
}
}

View file

@ -8,31 +8,7 @@
{ "model": "betterend:block/chorus_grass_05" }, { "model": "betterend:block/chorus_grass_05" },
{ "model": "betterend:block/chorus_grass_06" }, { "model": "betterend:block/chorus_grass_06" },
{ "model": "betterend:block/chorus_grass_07" }, { "model": "betterend:block/chorus_grass_07" },
{ "model": "betterend:block/chorus_grass_08" }, { "model": "betterend:block/chorus_grass_08" }
{ "model": "betterend:block/chorus_grass_01", "y": 90 },
{ "model": "betterend:block/chorus_grass_02", "y": 90 },
{ "model": "betterend:block/chorus_grass_03", "y": 90 },
{ "model": "betterend:block/chorus_grass_04", "y": 90 },
{ "model": "betterend:block/chorus_grass_05", "y": 90 },
{ "model": "betterend:block/chorus_grass_06", "y": 90 },
{ "model": "betterend:block/chorus_grass_07", "y": 90 },
{ "model": "betterend:block/chorus_grass_08", "y": 90 },
{ "model": "betterend:block/chorus_grass_01", "y": 180 },
{ "model": "betterend:block/chorus_grass_02", "y": 180 },
{ "model": "betterend:block/chorus_grass_03", "y": 180 },
{ "model": "betterend:block/chorus_grass_04", "y": 180 },
{ "model": "betterend:block/chorus_grass_05", "y": 180 },
{ "model": "betterend:block/chorus_grass_06", "y": 180 },
{ "model": "betterend:block/chorus_grass_07", "y": 180 },
{ "model": "betterend:block/chorus_grass_08", "y": 180 },
{ "model": "betterend:block/chorus_grass_01", "y": 270 },
{ "model": "betterend:block/chorus_grass_02", "y": 270 },
{ "model": "betterend:block/chorus_grass_03", "y": 270 },
{ "model": "betterend:block/chorus_grass_04", "y": 270 },
{ "model": "betterend:block/chorus_grass_05", "y": 270 },
{ "model": "betterend:block/chorus_grass_06", "y": 270 },
{ "model": "betterend:block/chorus_grass_07", "y": 270 },
{ "model": "betterend:block/chorus_grass_08", "y": 270 }
] ]
} }
} }

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "betterend:block/cave_grass_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "betterend:block/cave_grass_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_inverted",
"textures": {
"cross": "betterend:block/cave_grass_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_inverted",
"textures": {
"cross": "betterend:block/cave_grass_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/crop_block",
"textures": {
"texture": "betterend:block/cave_grass_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/crop_block",
"textures": {
"texture": "betterend:block/cave_grass_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/crop_block_inverted",
"textures": {
"texture": "betterend:block/cave_grass_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/crop_block_inverted",
"textures": {
"texture": "betterend:block/cave_grass_2"
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "block/cube",
"textures": {
"down": "block/end_stone",
"east": "betterend:block/cave_moss_side",
"north": "betterend:block/cave_moss_side",
"particle": "betterend:block/cave_moss_side",
"south": "betterend:block/cave_moss_side",
"up": "betterend:block/cave_moss_top",
"west": "betterend:block/cave_moss_side"
}
}

View file

@ -0,0 +1,7 @@
{ "parent": "betterend:block/path",
"textures": {
"top": "betterend:block/cave_moss_path_top",
"side": "betterend:block/cave_moss_side",
"bottom": "block/end_stone"
}
}

View file

@ -0,0 +1,26 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#cross"
},
"elements": [
{ "from": [ 0.8, 0, 8 ],
"to": [ 15.2, 16, 8 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true },
"shade": false,
"faces": {
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#cross" },
"south": { "uv": [ 16, 0, 0, 16 ], "texture": "#cross" }
}
},
{ "from": [ 8, 0, 0.8 ],
"to": [ 8, 16, 15.2 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true },
"shade": false,
"faces": {
"west": { "uv": [ 16, 0, 0, 16 ], "texture": "#cross" },
"east": { "uv": [ 16, 0, 0, 16 ], "texture": "#cross" }
}
}
]
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:block/cave_grass_1"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "betterend:block/cave_moss"
}

View file

@ -0,0 +1,3 @@
{
"parent": "betterend:block/cave_moss_path"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB