Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd
This commit is contained in:
commit
abe21e49d2
13 changed files with 81 additions and 12 deletions
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
||||
import ru.betterend.registry.FeatureRegistry;
|
||||
|
||||
public class BlockMossyPythadendronSapling extends BlockFeatureSapling {
|
||||
public BlockMossyPythadendronSapling() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Feature<?> getFeature() {
|
||||
return FeatureRegistry.PYTHADENDRON_TREE.getFeature();
|
||||
}
|
||||
}
|
16
src/main/java/ru/betterend/blocks/basis/BlockLeaves.java
Normal file
16
src/main/java/ru/betterend/blocks/basis/BlockLeaves.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
|
||||
public class BlockLeaves extends LeavesBlock {
|
||||
public BlockLeaves(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color));
|
||||
}
|
||||
|
||||
public BlockLeaves(MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color).lightLevel(light));
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import ru.betterend.blocks.BlockGlowingMoss;
|
|||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
||||
import ru.betterend.blocks.BlockMossyPythadendronSapling;
|
||||
import ru.betterend.blocks.BlockOre;
|
||||
import ru.betterend.blocks.BlockPath;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
|
@ -29,6 +30,8 @@ import ru.betterend.blocks.EndStoneSmelter;
|
|||
import ru.betterend.blocks.EnderBlock;
|
||||
import ru.betterend.blocks.TerminiteBlock;
|
||||
import ru.betterend.blocks.basis.BlockGlowingFur;
|
||||
import ru.betterend.blocks.basis.BlockLeaves;
|
||||
import ru.betterend.blocks.basis.BlockSlab;
|
||||
import ru.betterend.blocks.basis.BlockVine;
|
||||
import ru.betterend.blocks.complex.StoneMaterial;
|
||||
import ru.betterend.blocks.complex.WoodenMaterial;
|
||||
|
@ -57,6 +60,9 @@ public class BlockRegistry {
|
|||
public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", new BlockMossyGlowshroomHymenophore());
|
||||
public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(MOSSY_GLOWSHROOM_SAPLING, 16));
|
||||
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
||||
|
||||
public static final Block PYTHADENDRON_SAPLING = registerBlock("pythadendron_sapling", new BlockMossyPythadendronSapling());
|
||||
public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new BlockLeaves(MaterialColor.MAGENTA));
|
||||
public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE);
|
||||
|
||||
// Small Plants //
|
||||
|
|
|
@ -13,13 +13,17 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.SplineHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFScale;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.operator.SDFUnion;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class PythadendronTreeFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
|
@ -28,12 +32,13 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (world.getBlockState(pos.down()).getBlock() != BlockRegistry.CHORUS_NYLIUM) return false;
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
float size = MHelper.randRange(10, 13, random);
|
||||
List<List<Vector3f>> splines = Lists.newArrayList();
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 4);
|
||||
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
|
||||
Vector3f last = spline.get(spline.size() - 1);
|
||||
branch(splines, last.getX(), last.getY(), last.getZ(), size * 0.6F, MHelper.randRange(0, MHelper.PI2, random), random, MHelper.floor(Math.log(size) * 1.5F));
|
||||
List<Vector3f> ends = Lists.newArrayList();
|
||||
branch(splines, ends, last.getX(), last.getY(), last.getZ(), size * 0.6F, MHelper.randRange(0, MHelper.PI2, random), random, MHelper.floor(Math.log(size) * 1.5F));
|
||||
|
||||
SDF function = SplineHelper.buildSDF(spline, 1.4F, 0.8F, (bpos) -> {
|
||||
return BlockRegistry.PYTHADENDRON.bark.getDefaultState();
|
||||
|
@ -41,21 +46,28 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
|
||||
for (List<Vector3f> sp: splines) {
|
||||
float width = 0.8F - (sp.get(0).getY() - size) / 40;
|
||||
if (size > 0F) {
|
||||
SDF funcSp = SplineHelper.buildSDF(sp, width, width, (bpos) -> {
|
||||
return BlockRegistry.PYTHADENDRON.bark.getDefaultState();
|
||||
});
|
||||
function = new SDFUnion().setSourceA(function).setSourceB(funcSp);
|
||||
}
|
||||
SDF funcSp = SplineHelper.buildSDF(sp, width, width, (bpos) -> {
|
||||
return BlockRegistry.PYTHADENDRON.bark.getDefaultState();
|
||||
});
|
||||
function = new SDFUnion().setSourceA(function).setSourceB(funcSp);
|
||||
}
|
||||
function = new SDFScale().setScale(MHelper.randRange(1F, 2F, random)).setSource(function);
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
for (Vector3f v: ends) {
|
||||
SDF sphere = new SDFSphere().setRadius(MHelper.randRange(2.5F, 3.5F, random)).setBlock(BlockRegistry.PYTHADENDRON_LEAVES);
|
||||
sphere = new SDFTranslate().setTranslate(v.getX(), v.getY(), v.getZ()).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2); }).setSource(sphere);
|
||||
function = new SDFUnion().setSourceA(function).setSourceB(sphere);
|
||||
}
|
||||
|
||||
function = new SDFScale().setScale(MHelper.randRange(1.6F, 2.0F, random)).setSource(function);
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.fillRecursive(world, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void branch(List<List<Vector3f>> splines, float x, float y, float z, float size, float angle, Random random, int depth) {
|
||||
private void branch(List<List<Vector3f>> splines, List<Vector3f> ends, float x, float y, float z, float size, float angle, Random random, int depth) {
|
||||
if (depth == 0) return;
|
||||
|
||||
float dx = (float) Math.cos(angle) * size * 0.3F;
|
||||
|
@ -78,8 +90,13 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
splines.add(spline);
|
||||
Vector3f pos2 = spline.get(spline.size() - 1);
|
||||
|
||||
branch(splines, pos1.getX(), pos1.getY(), pos1.getZ(), size * 0.8F, angle + (float) Math.PI * 0.5F, random, depth - 1);
|
||||
branch(splines, pos2.getX(), pos2.getY(), pos2.getZ(), size * 0.8F, angle + (float) Math.PI * 0.5F, random, depth - 1);
|
||||
if (depth == 1) {
|
||||
ends.add(pos1);
|
||||
ends.add(pos2);
|
||||
}
|
||||
|
||||
branch(splines, ends, pos1.getX(), pos1.getY(), pos1.getZ(), size * 0.8F, angle + (float) Math.PI * 0.5F, random, depth - 1);
|
||||
branch(splines, ends, pos2.getX(), pos2.getY(), pos2.getZ(), size * 0.8F, angle + (float) Math.PI * 0.5F, random, depth - 1);
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue