Capsacis tree enhancements

This commit is contained in:
paulevsGitch 2021-01-18 23:05:08 +03:00
parent 527ba2bbaa
commit 7e750411a0
40 changed files with 172 additions and 28 deletions

View file

@ -13,11 +13,16 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
public class CapsacisCapBlock extends BaseBlock { public class CapsacisCapBlock extends BaseBlock {
public static final IntProperty COLOR = IntProperty.of("color", 0, 7);
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public static final IntProperty COLOR = BlockProperties.COLOR;
public CapsacisCapBlock(MaterialColor color) { public CapsacisCapBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(color)); super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.MAGENTA));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR);
} }
@Override @Override
@ -27,9 +32,4 @@ public class CapsacisCapBlock extends BaseBlock {
double pz = ctx.getBlockPos().getZ() * 0.1; double pz = ctx.getBlockPos().getZ() * 0.1;
return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
} }
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR);
}
} }

View file

@ -84,7 +84,7 @@ public class EndBiomes {
public static final EndBiome BLOSSOMING_SPIRES = registerBiome(new BiomeBlossomingSpires(), BiomeType.LAND); public static final EndBiome BLOSSOMING_SPIRES = registerBiome(new BiomeBlossomingSpires(), BiomeType.LAND);
public static final EndBiome SULPHUR_SPRINGS = registerBiome(new BiomeSulphurSprings(), BiomeType.LAND); public static final EndBiome SULPHUR_SPRINGS = registerBiome(new BiomeSulphurSprings(), BiomeType.LAND);
public static final EndBiome UMBRELLA_JUNGLE = registerBiome(new BiomeUmbrellaJungle(), BiomeType.LAND); public static final EndBiome UMBRELLA_JUNGLE = registerBiome(new BiomeUmbrellaJungle(), BiomeType.LAND);
public static final EndBiome CAPSACIS_FOREST = registerBiome(new CapsacisForestBiome(), BiomeType.LAND); public static final EndBiome CAPSACIS_FOREST = registerSubBiome(new CapsacisForestBiome(), CHORUS_FOREST);
//public static final EndBiome HANGING_GARDENS = registerBiome(new HangingGardensBiome(), BiomeType.LAND); //public static final EndBiome HANGING_GARDENS = registerBiome(new HangingGardensBiome(), BiomeType.LAND);
// Better End Void // Better End Void

View file

@ -195,9 +195,7 @@ public class EndBlocks {
// Tree from original concept (+ modifications) // Tree from original concept (+ modifications)
public static final Block CAPSACIS_SAPLING = registerBlock("capsacis_sapling", new UmbrellaTreeSaplingBlock()); public static final Block CAPSACIS_SAPLING = registerBlock("capsacis_sapling", new UmbrellaTreeSaplingBlock());
public static final Block CAPSACIS_CAP_BLACK = registerBlock("capsacis_cap_black", new CapsacisCapBlock(MaterialColor.BLACK)); public static final Block CAPSACIS_CAP = registerBlock("capsacis_cap", new CapsacisCapBlock());
public static final Block CAPSACIS_CAP_WHITE = registerBlock("capsacis_cap_white", new CapsacisCapBlock(MaterialColor.WHITE));
public static final Block CAPSACIS_CAP_PURPLE = registerBlock("capsacis_cap_purple", new CapsacisCapBlock(MaterialColor.MAGENTA));
public static final WoodenMaterial CAPSACIS = new WoodenMaterial("capsacis", MaterialColor.PURPLE, MaterialColor.LIGHT_BLUE); public static final WoodenMaterial CAPSACIS = new WoodenMaterial("capsacis", MaterialColor.PURPLE, MaterialColor.LIGHT_BLUE);
// Small ecosystem tree // Small ecosystem tree

View file

@ -64,10 +64,7 @@ public class EndFeatures {
public static final EndFeature HELIX_TREE = new EndFeature("helix_tree", new HelixTreeFeature(), 2); public static final EndFeature HELIX_TREE = new EndFeature("helix_tree", new HelixTreeFeature(), 2);
public static final EndFeature UMBRELLA_TREE = new EndFeature("umbrella_tree", new UmbrellaTreeFeature(), 4); public static final EndFeature UMBRELLA_TREE = new EndFeature("umbrella_tree", new UmbrellaTreeFeature(), 4);
public static final EndFeature JELLYSHROOM = new EndFeature("jellyshroom", new JellyshroomFeature(), 3); public static final EndFeature JELLYSHROOM = new EndFeature("jellyshroom", new JellyshroomFeature(), 3);
public static final EndFeature CAPSACIS = new EndFeature("capsacis", new CapsacisTreeFeature((random) -> { public static final EndFeature CAPSACIS = new EndFeature("capsacis", new CapsacisTreeFeature(), 3);
int state = random.nextInt(3);
return state == 0 ? EndBlocks.CAPSACIS_CAP_BLACK.getDefaultState() : state == 1 ? EndBlocks.CAPSACIS_CAP_PURPLE.getDefaultState() : EndBlocks.CAPSACIS_CAP_WHITE.getDefaultState();
}), 1);
// Bushes // // Bushes //
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4); public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4);

View file

@ -8,13 +8,17 @@ import ru.betterend.registry.EndSounds;
public class CapsacisForestBiome extends EndBiome { public class CapsacisForestBiome extends EndBiome {
public CapsacisForestBiome() { public CapsacisForestBiome() {
super(new BiomeDefinition("capsacis_forest") super(new BiomeDefinition("capsacis_forest")
.setSurface(EndBlocks.SHADOW_GRASS, EndBlocks.CHORUS_NYLIUM) .setSurface(EndBlocks.CHORUS_NYLIUM)
.setMusic(EndSounds.MUSIC_FOREST) .setMusic(EndSounds.MUSIC_FOREST)
.setWaterAndFogColor(84, 61, 127) .setWaterAndFogColor(84, 61, 127)
.setFoliageColor(71, 45, 120) .setFoliageColor(71, 45, 120)
.setFogColor(78, 71, 92) .setFogColor(78, 71, 92)
.setFogDensity(1.5F) .setFogDensity(1.5F)
.addFeature(EndFeatures.CAPSACIS) .addFeature(EndFeatures.CAPSACIS)
.addFeature(EndFeatures.PURPLE_POLYPORE)
.addFeature(EndFeatures.TAIL_MOSS_WOOD)
.addFeature(EndFeatures.TAIL_MOSS)
.addFeature(EndFeatures.CHORUS_GRASS)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)); .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4));
} }
} }

View file

@ -9,15 +9,18 @@ import com.google.common.collect.Lists;
import net.minecraft.block.BlockState; 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.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;
import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags; import ru.betterend.registry.EndTags;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
import ru.betterend.util.SplineHelper; import ru.betterend.util.SplineHelper;
import ru.betterend.util.sdf.SDF; import ru.betterend.util.sdf.SDF;
import ru.betterend.util.sdf.operator.SDFFlatWave; import ru.betterend.util.sdf.operator.SDFFlatWave;
import ru.betterend.util.sdf.operator.SDFScale;
import ru.betterend.util.sdf.operator.SDFSmoothUnion; import ru.betterend.util.sdf.operator.SDFSmoothUnion;
import ru.betterend.util.sdf.operator.SDFTranslate; import ru.betterend.util.sdf.operator.SDFTranslate;
import ru.betterend.util.sdf.operator.SDFUnion; import ru.betterend.util.sdf.operator.SDFUnion;
@ -29,12 +32,6 @@ public class CapsacisTreeFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE; private static final Function<BlockState, Boolean> REPLACE;
private static final List<Vector3f> ROOT; private static final List<Vector3f> ROOT;
private final Function<Random, BlockState> capFunction;
public CapsacisTreeFeature(Function<Random, BlockState> capFunction) {
this.capFunction = capFunction;
}
@Override @Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
@ -49,30 +46,41 @@ public class CapsacisTreeFeature extends DefaultFeature {
BlockState woodState = EndBlocks.CAPSACIS.bark.getDefaultState(); BlockState woodState = EndBlocks.CAPSACIS.bark.getDefaultState();
BlockState logState = EndBlocks.CAPSACIS.log.getDefaultState(); BlockState logState = EndBlocks.CAPSACIS.log.getDefaultState();
BlockState capState = capFunction.apply(random); BlockState capState = EndBlocks.CAPSACIS_CAP.getDefaultState();
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F); SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
SDF sdf = SplineHelper.buildSDF(spline, 2.5F, 0.8F, (bpos) -> { SDF sdf = SplineHelper.buildSDF(spline, 2.5F, 0.8F, (bpos) -> {
return woodState; return woodState;
}); });
SDF cap = makeCap(height * 0.2F, height * 0.25F, random, capState); final float scale = config == null ? 1 : MHelper.randRange(1, 3, random);
final float offset = height * 0.2F;
final float radius = height * 0.25F;
final float heightScale = radius * 2 * scale;
final int count = MHelper.randRange(5, 7, random);
final float angle = random.nextFloat() * MHelper.PI2;
SDF cap = makeCap(offset, radius, count, angle, capState);
sdf = new SDFUnion().setSourceA(sdf).setSourceB(cap); sdf = new SDFUnion().setSourceA(sdf).setSourceB(cap);
sdf = new SDFScale().setScale(scale).setSource(sdf);
makeRoots(world, center, height * 0.4F, random, woodState); makeRoots(world, center, height * 0.4F, random, woodState);
sdf.addPostProcess((info) -> { sdf.addPostProcess((info) -> {
if (EndBlocks.CAPSACIS.isTreeLog(info.getStateUp()) && EndBlocks.CAPSACIS.isTreeLog(info.getStateDown())) { if (EndBlocks.CAPSACIS.isTreeLog(info.getStateUp()) && EndBlocks.CAPSACIS.isTreeLog(info.getStateDown())) {
return logState; return logState;
} }
else if (info.getState().equals(capState)) {
double off = Math.cos(Math.atan2(info.getPos().getX() - pos.getX(), info.getPos().getZ() - pos.getZ()) * count + angle) * 2;
int color = (int) ((info.getPos().getY() - pos.getY() - radius) / heightScale * 7 + off);
color = 7 - MathHelper.clamp(color, 0, 7);
return info.getState().with(BlockProperties.COLOR, color);
}
return info.getState(); return info.getState();
}).fillRecursive(world, center); }).fillRecursive(world, center);
return true; return true;
} }
private SDF makeCap(float offset, float radius, Random random, BlockState capState) { private SDF makeCap(float offset, float radius, int count, float angle, BlockState capState) {
float angle = random.nextFloat() * MHelper.PI2;
int count = MHelper.randRange(5, 7, random);
SDF cap = new SDFSphere().setRadius(radius).setBlock(capState); SDF cap = new SDFSphere().setRadius(radius).setBlock(capState);
SDF cone = new SDFCappedCone().setRadius1(radius).setRadius2(radius * 0.4F).setHeight(radius * 0.3F).setBlock(capState); SDF cone = new SDFCappedCone().setRadius1(radius).setRadius2(radius * 0.4F).setHeight(radius * 0.3F).setBlock(capState);
cone = new SDFTranslate().setTranslate(0, radius * 0.3F, 0).setSource(cone); cone = new SDFTranslate().setTranslate(0, radius * 0.3F, 0).setSource(cone);

View file

@ -0,0 +1,19 @@
{
"variants": {
"axis=x": [
{ "model": "betterend:block/capsacis_bark_1", "x": 90, "y": 90 },
{ "model": "betterend:block/capsacis_bark_2", "x": 90, "y": 90 },
{ "model": "betterend:block/capsacis_bark_3", "x": 90, "y": 90 }
],
"axis=y": [
{ "model": "betterend:block/capsacis_bark_1" },
{ "model": "betterend:block/capsacis_bark_2" },
{ "model": "betterend:block/capsacis_bark_3" }
],
"axis=z": [
{ "model": "betterend:block/capsacis_bark_1", "x": 90 },
{ "model": "betterend:block/capsacis_bark_2", "x": 90 },
{ "model": "betterend:block/capsacis_bark_3", "x": 90 }
]
}
}

View file

@ -0,0 +1,12 @@
{
"variants": {
"color=0": { "model": "betterend:block/capsacis_cap_0" },
"color=1": { "model": "betterend:block/capsacis_cap_1" },
"color=2": { "model": "betterend:block/capsacis_cap_2" },
"color=3": { "model": "betterend:block/capsacis_cap_3" },
"color=4": { "model": "betterend:block/capsacis_cap_4" },
"color=5": { "model": "betterend:block/capsacis_cap_5" },
"color=6": { "model": "betterend:block/capsacis_cap_6" },
"color=7": { "model": "betterend:block/capsacis_cap_7" }
}
}

View file

@ -0,0 +1,19 @@
{
"variants": {
"axis=x": [
{ "model": "betterend:block/capsacis_log_1", "x": 90, "y": 90 },
{ "model": "betterend:block/capsacis_log_2", "x": 90, "y": 90 },
{ "model": "betterend:block/capsacis_log_3", "x": 90, "y": 90 }
],
"axis=y": [
{ "model": "betterend:block/capsacis_log_1" },
{ "model": "betterend:block/capsacis_log_2" },
{ "model": "betterend:block/capsacis_log_3" }
],
"axis=z": [
{ "model": "betterend:block/capsacis_log_1", "x": 90 },
{ "model": "betterend:block/capsacis_log_2", "x": 90 },
{ "model": "betterend:block/capsacis_log_3", "x": 90 }
]
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_log_side"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_log_side_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_log_side_3"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_3"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_4"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_5"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_6"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/capsacis_cap_7"
}
}

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "betterend:block/capsacis_log_top",
"side": "betterend:block/capsacis_log_side"
}
}

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "betterend:block/capsacis_log_top",
"side": "betterend:block/capsacis_log_side_2"
}
}

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "betterend:block/capsacis_log_top",
"side": "betterend:block/capsacis_log_side_3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After