Structure fix
This commit is contained in:
parent
310369cbb3
commit
2d53cedb90
8 changed files with 35 additions and 83 deletions
|
@ -27,11 +27,11 @@ public class BlockRegistry {
|
|||
public static final Block END_MOSS = registerBlock("end_moss", new BlockTerrain(MaterialColor.CYAN));
|
||||
|
||||
// Wooden Materials //
|
||||
public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling());
|
||||
public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap());
|
||||
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 BlockMossyGlowshroomFur());
|
||||
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
||||
public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling());
|
||||
|
||||
// Ores //
|
||||
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3));
|
||||
|
|
|
@ -49,10 +49,11 @@ public class SplineHelper {
|
|||
for (int i = 1; i < count; i++) {
|
||||
Vector3f pos = spline.get(i);
|
||||
float delta = (float) (i - 1) / max;
|
||||
SDFLine line = new SDFLine(placerFunction)
|
||||
SDF line = new SDFLine()
|
||||
.setRadius(MathHelper.lerp(delta, radius1, radius2))
|
||||
.setStart(start.getX(), start.getY(), start.getZ())
|
||||
.setEnd(pos.getX(), pos.getY(), pos.getZ());
|
||||
.setEnd(pos.getX(), pos.getY(), pos.getZ())
|
||||
.setBlock(placerFunction);
|
||||
result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line);
|
||||
start = pos;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.betterend.util.sdf.primitive;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
|
@ -13,18 +8,6 @@ public class SDFCapedCone extends SDFPrimitive {
|
|||
private float radius2;
|
||||
private float height;
|
||||
|
||||
public SDFCapedCone(Function<BlockPos, BlockState> placerFunction) {
|
||||
super(placerFunction);
|
||||
}
|
||||
|
||||
public SDFCapedCone(BlockState state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
public SDFCapedCone(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
public SDFCapedCone setRadius1(float radius) {
|
||||
this.radius1 = radius;
|
||||
return this;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.betterend.util.sdf.primitive;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
|
@ -12,18 +7,6 @@ public class SDFCapsule extends SDFPrimitive {
|
|||
private float radius;
|
||||
private float height;
|
||||
|
||||
public SDFCapsule(Function<BlockPos, BlockState> placerFunction) {
|
||||
super(placerFunction);
|
||||
}
|
||||
|
||||
public SDFCapsule(BlockState state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
public SDFCapsule(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
public SDFCapsule setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.betterend.util.sdf.primitive;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
|
@ -17,18 +12,6 @@ public class SDFLine extends SDFPrimitive {
|
|||
private float y2;
|
||||
private float z2;
|
||||
|
||||
public SDFLine(Function<BlockPos, BlockState> placerFunction) {
|
||||
super(placerFunction);
|
||||
}
|
||||
|
||||
public SDFLine(BlockState state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
public SDFLine(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
public SDFLine setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
|
|
|
@ -8,22 +8,25 @@ import net.minecraft.util.math.BlockPos;
|
|||
import ru.betterend.util.sdf.SDF;
|
||||
|
||||
public abstract class SDFPrimitive extends SDF {
|
||||
protected final Function<BlockPos, BlockState> placerFunction;
|
||||
protected Function<BlockPos, BlockState> placerFunction;
|
||||
|
||||
public SDFPrimitive(Function<BlockPos, BlockState> placerFunction) {
|
||||
public SDFPrimitive setBlock(Function<BlockPos, BlockState> placerFunction) {
|
||||
this.placerFunction = placerFunction;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SDFPrimitive(BlockState state) {
|
||||
public SDFPrimitive setBlock(BlockState state) {
|
||||
this.placerFunction = (pos) -> {
|
||||
return state;
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public SDFPrimitive(Block block) {
|
||||
public SDFPrimitive setBlock(Block block) {
|
||||
this.placerFunction = (pos) -> {
|
||||
return block.getDefaultState();
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
|
|
|
@ -1,27 +1,10 @@
|
|||
package ru.betterend.util.sdf.primitive;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class SDFSphere extends SDFPrimitive {
|
||||
private float radius;
|
||||
|
||||
public SDFSphere(Function<BlockPos, BlockState> placerFunction) {
|
||||
super(placerFunction);
|
||||
}
|
||||
|
||||
public SDFSphere(BlockState state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
public SDFSphere(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
public SDFSphere setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
|
|
|
@ -33,6 +33,7 @@ import ru.betterend.util.sdf.operator.SDFSubtraction;
|
|||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.operator.SDFUnion;
|
||||
import ru.betterend.util.sdf.primitive.SDFCapedCone;
|
||||
import ru.betterend.util.sdf.primitive.SDFPrimitive;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class MossyGlowshroomFeature extends DefaultFeature {
|
||||
|
@ -41,7 +42,12 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
private static final Vector3f CENTER = new Vector3f();
|
||||
private static final SDFBinary FUNCTION;
|
||||
private static final SDFTranslate HEAD_POS;
|
||||
private static final SDFFlatWave ROOTS;
|
||||
private static final SDFFlatWave ROOTS_ROT;
|
||||
|
||||
private static final SDFPrimitive CONE1;
|
||||
private static final SDFPrimitive CONE2;
|
||||
private static final SDFPrimitive CONE_GLOW;
|
||||
private static final SDFPrimitive ROOTS;
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||
|
@ -53,6 +59,11 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
return false;
|
||||
}
|
||||
|
||||
CONE1.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_CAP);
|
||||
CONE2.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_CAP);
|
||||
CONE_GLOW.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE);
|
||||
ROOTS.setBlock(BlockRegistry.MOSSY_GLOWSHROOM.bark);
|
||||
|
||||
float height = MHelper.randRange(10F, 25F, random);
|
||||
int count = MHelper.floor(height / 4);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count);
|
||||
|
@ -63,7 +74,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
Vector3f pos = spline.get(spline.size() - 1);
|
||||
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
|
||||
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ROOTS.setAngle(random.nextFloat() * MHelper.PI2);
|
||||
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
|
||||
FUNCTION.setSourceA(sdf);
|
||||
Set<BlockPos> blocks = new SDFScale()
|
||||
.setScale(MHelper.randRange(0.75F, 1.1F, random))
|
||||
|
@ -101,19 +112,23 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
static {
|
||||
SDFCapedCone cone1 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP).setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
|
||||
SDFCapedCone cone2 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP).setHeight(3F).setRadius1(2.5F).setRadius2(13F);
|
||||
SDFCapedCone cone1 = new SDFCapedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
|
||||
SDFCapedCone cone2 = new SDFCapedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F);
|
||||
SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2);
|
||||
SDF posedCone3 = new SDFTranslate().setTranslate(0, 7F, 0).setSource(cone2);
|
||||
SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3);
|
||||
SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone);
|
||||
SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave);
|
||||
|
||||
CONE1 = cone1;
|
||||
CONE2 = cone2;
|
||||
|
||||
SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone);
|
||||
innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone);
|
||||
cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone);
|
||||
|
||||
SDF glowCone = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE).setHeight(3F).setRadius1(2F).setRadius2(12.5F);
|
||||
SDF glowCone = new SDFCapedCone().setHeight(3F).setRadius1(2F).setRadius2(12.5F);
|
||||
CONE_GLOW = (SDFPrimitive) glowCone;
|
||||
glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone);
|
||||
glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3);
|
||||
|
||||
|
@ -128,11 +143,12 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
|
||||
HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
|
||||
|
||||
SDF roots = new SDFSphere(BlockRegistry.MOSSY_GLOWSHROOM.bark).setRadius(4F);
|
||||
SDF roots = new SDFSphere().setRadius(4F);
|
||||
ROOTS = (SDFPrimitive) roots;
|
||||
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
|
||||
ROOTS = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
|
||||
ROOTS_ROT = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
|
||||
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS));
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
|
||||
|
||||
REPLACE = (state) -> {
|
||||
if (state.getBlock() != Blocks.END_STONE && state.isIn(BlockTagRegistry.END_GROUND)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue