Fixes
This commit is contained in:
parent
178836965d
commit
20bb6379bf
22 changed files with 161 additions and 56 deletions
|
@ -17,6 +17,8 @@ import net.minecraft.world.chunk.Chunk;
|
|||
|
||||
public class StructureWorld {
|
||||
private Map<ChunkPos, Part> parts = Maps.newHashMap();
|
||||
private ChunkPos lastPos;
|
||||
private Part lastPart;
|
||||
private int minX = Integer.MAX_VALUE;
|
||||
private int minY = Integer.MAX_VALUE;
|
||||
private int minZ = Integer.MAX_VALUE;
|
||||
|
@ -46,6 +48,12 @@ public class StructureWorld {
|
|||
|
||||
public void setBlock(BlockPos pos, BlockState state) {
|
||||
ChunkPos cPos = new ChunkPos(pos);
|
||||
|
||||
if (cPos.equals(lastPos)) {
|
||||
lastPart.addBlock(pos, state);
|
||||
return;
|
||||
}
|
||||
|
||||
Part part = parts.get(cPos);
|
||||
if (part == null) {
|
||||
part = new Part();
|
||||
|
@ -59,6 +67,9 @@ public class StructureWorld {
|
|||
if (pos.getY() < minY) minY = pos.getY();
|
||||
if (pos.getY() > maxY) maxY = pos.getY();
|
||||
part.addBlock(pos, state);
|
||||
|
||||
lastPos = cPos;
|
||||
lastPart = part;
|
||||
}
|
||||
|
||||
public boolean placeChunk(StructureWorldAccess world, ChunkPos chunkPos) {
|
||||
|
|
|
@ -37,7 +37,10 @@ public abstract class SDFStructureFeature extends StructureFeatureBase {
|
|||
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
|
||||
if (y > 5) {
|
||||
BlockPos start = new BlockPos(x, y, z);
|
||||
long t = System.currentTimeMillis();
|
||||
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
||||
t = System.currentTimeMillis() - t;
|
||||
System.out.println("Structure " + t + " ms");
|
||||
this.children.add(piece);
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
|
|
|
@ -31,8 +31,6 @@ import ru.betterend.util.sdf.primitive.SDFSphere;
|
|||
public class StructureGiantMossyGlowshroom extends SDFStructureFeature {
|
||||
@Override
|
||||
protected SDF getSDF(BlockPos center, Random random) {
|
||||
System.out.println(center);
|
||||
|
||||
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);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package ru.betterend.world.structures.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import ru.betterend.noise.VoronoiNoise;
|
||||
import ru.betterend.util.MHelper;
|
||||
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.SDFSmoothUnion;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFCapedCone;
|
||||
|
||||
public class StructureMountain extends SDFStructureFeature {
|
||||
@Override
|
||||
protected SDF getSDF(BlockPos center, Random random) {
|
||||
SDFCapedCone cone1 = new SDFCapedCone().setHeight(20F).setRadius1(40F).setRadius2(0F);
|
||||
SDFCapedCone cone2 = new SDFCapedCone().setHeight(10F).setRadius1(0F).setRadius2(40F);
|
||||
cone1.setBlock(Blocks.END_STONE);
|
||||
cone2.setBlock(Blocks.END_STONE);
|
||||
SDF mountain = new SDFSmoothUnion().setRadius(15)
|
||||
.setSourceA(new SDFTranslate().setTranslate(0, 20, 1).setSource(cone1))
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -10, 1).setSource(cone2));
|
||||
mountain = new SDFScale().setScale(MHelper.randRange(1F, 2.5F, random)).setSource(mountain);
|
||||
VoronoiNoise noise = new VoronoiNoise(random.nextInt(), 20, 0.75);
|
||||
mountain = new SDFDisplacement().setFunction((pos) -> {
|
||||
return (float) noise.sample(pos.getX(), pos.getY(), pos.getZ()) * 15F;
|
||||
}).setSource(mountain);
|
||||
return mountain;
|
||||
}
|
||||
}
|
|
@ -22,13 +22,11 @@ public class VoxelPiece extends BasePiece {
|
|||
world = new StructureWorld();
|
||||
function.accept(world);
|
||||
this.boundingBox = world.getBounds();
|
||||
System.out.println(this.boundingBox);
|
||||
}
|
||||
|
||||
public VoxelPiece(StructureManager manager, CompoundTag tag) {
|
||||
super(StructureRegistry.VOXEL_PIECE, tag);
|
||||
this.boundingBox = world.getBounds();
|
||||
System.out.println(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue