Mushroom fixes
This commit is contained in:
parent
31e33ba2d3
commit
42ef270e2e
10 changed files with 181 additions and 17 deletions
|
@ -24,7 +24,6 @@ public class EndStructureFeature {
|
|||
this.structure = FabricStructureBuilder.create(id, structure)
|
||||
.step(step)
|
||||
.defaultConfig(spacing, separation, RANDOM.nextInt(8192))
|
||||
.adjustsSurface()
|
||||
.register();
|
||||
|
||||
this.featureConfigured = this.structure.configure(DefaultFeatureConfig.DEFAULT);
|
||||
|
|
|
@ -18,8 +18,10 @@ import net.minecraft.world.chunk.Chunk;
|
|||
public class StructureWorld {
|
||||
private Map<ChunkPos, Part> parts = Maps.newHashMap();
|
||||
private int minX = Integer.MAX_VALUE;
|
||||
private int minY = Integer.MAX_VALUE;
|
||||
private int minZ = Integer.MAX_VALUE;
|
||||
private int maxX = Integer.MIN_VALUE;
|
||||
private int maxY = Integer.MIN_VALUE;
|
||||
private int maxZ = Integer.MIN_VALUE;
|
||||
|
||||
public StructureWorld() {}
|
||||
|
@ -27,8 +29,11 @@ public class StructureWorld {
|
|||
public StructureWorld(CompoundTag tag) {
|
||||
minX = tag.getInt("minX");
|
||||
maxX = tag.getInt("maxX");
|
||||
minY = tag.getInt("minY");
|
||||
maxY = tag.getInt("maxY");
|
||||
minZ = tag.getInt("minZ");
|
||||
maxZ = tag.getInt("maxZ");
|
||||
|
||||
ListTag map = tag.getList("parts", 10);
|
||||
map.forEach((element) -> {
|
||||
CompoundTag compound = (CompoundTag) element;
|
||||
|
@ -51,6 +56,8 @@ public class StructureWorld {
|
|||
if (cPos.z < minZ) minZ = cPos.z;
|
||||
if (cPos.z > maxZ) maxZ = cPos.z;
|
||||
}
|
||||
if (pos.getY() < minY) minY = pos.getY();
|
||||
if (pos.getY() > maxY) maxY = pos.getY();
|
||||
part.addBlock(pos, state);
|
||||
}
|
||||
|
||||
|
@ -68,6 +75,8 @@ public class StructureWorld {
|
|||
CompoundTag tag = new CompoundTag();
|
||||
tag.putInt("minX", minX);
|
||||
tag.putInt("maxX", maxX);
|
||||
tag.putInt("minY", minY);
|
||||
tag.putInt("maxY", maxY);
|
||||
tag.putInt("minZ", minZ);
|
||||
tag.putInt("maxZ", maxZ);
|
||||
ListTag map = new ListTag();
|
||||
|
@ -79,7 +88,10 @@ public class StructureWorld {
|
|||
}
|
||||
|
||||
public BlockBox getBounds() {
|
||||
return new BlockBox(minX << 4, minZ << 4, (maxX << 4) | 15, (maxZ << 4) | 15);
|
||||
if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) {
|
||||
return BlockBox.empty();
|
||||
}
|
||||
return new BlockBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15);
|
||||
}
|
||||
|
||||
private static final class Part {
|
||||
|
@ -104,6 +116,7 @@ public class StructureWorld {
|
|||
|
||||
void placeChunk(Chunk chunk) {
|
||||
blocks.forEach((pos, state) -> {
|
||||
//if (pos.getY() > 10)
|
||||
chunk.setBlockState(pos, state, false);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,11 +16,8 @@ import ru.betterend.util.MHelper;
|
|||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.world.structures.piece.VoxelPiece;
|
||||
|
||||
public abstract class SDFStructureFeature extends StructureFeature<DefaultFeatureConfig> {
|
||||
public SDFStructureFeature() {
|
||||
super(DefaultFeatureConfig.CODEC);
|
||||
}
|
||||
|
||||
public abstract class SDFStructureFeature extends StructureFeatureBase {
|
||||
|
||||
protected abstract SDF getSDF(BlockPos pos, Random random);
|
||||
|
||||
@Override
|
||||
|
@ -38,10 +35,12 @@ public abstract class SDFStructureFeature extends StructureFeature<DefaultFeatur
|
|||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
||||
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
|
||||
BlockPos start = new BlockPos(x, y, z);
|
||||
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
||||
this.children.add(piece);
|
||||
this.boundingBox = piece.getBoundingBox();
|
||||
if (y > 5) {
|
||||
BlockPos start = new BlockPos(x, y, z);
|
||||
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
||||
this.children.add(piece);
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package ru.betterend.world.structures.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
public abstract class StructureFeatureBase extends StructureFeature<DefaultFeatureConfig> {
|
||||
public StructureFeatureBase() {
|
||||
super(DefaultFeatureConfig.CODEC);
|
||||
}
|
||||
|
||||
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig featureConfig) {
|
||||
return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 50;
|
||||
}
|
||||
|
||||
private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
|
||||
Random random = new Random((long) (chunkX + chunkZ * 10387313));
|
||||
BlockRotation blockRotation = BlockRotation.random(random);
|
||||
int i = 5;
|
||||
int j = 5;
|
||||
if (blockRotation == BlockRotation.CLOCKWISE_90) {
|
||||
i = -5;
|
||||
} else if (blockRotation == BlockRotation.CLOCKWISE_180) {
|
||||
i = -5;
|
||||
j = -5;
|
||||
} else if (blockRotation == BlockRotation.COUNTERCLOCKWISE_90) {
|
||||
j = -5;
|
||||
}
|
||||
|
||||
int k = (chunkX << 4) + 7;
|
||||
int l = (chunkZ << 4) + 7;
|
||||
int m = chunkGenerator.getHeightInGround(k, l, Heightmap.Type.WORLD_SURFACE_WG);
|
||||
int n = chunkGenerator.getHeightInGround(k, l + j, Heightmap.Type.WORLD_SURFACE_WG);
|
||||
int o = chunkGenerator.getHeightInGround(k + i, l, Heightmap.Type.WORLD_SURFACE_WG);
|
||||
int p = chunkGenerator.getHeightInGround(k + i, l + j, Heightmap.Type.WORLD_SURFACE_WG);
|
||||
return Math.min(Math.min(m, n), Math.min(o, p));
|
||||
}
|
||||
}
|
|
@ -3,8 +3,6 @@ package ru.betterend.world.structures.features;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||
|
@ -28,8 +26,6 @@ import ru.betterend.util.sdf.primitive.SDFPrimitive;
|
|||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class StructureGiantMossyGlowshroom extends SDFStructureFeature {
|
||||
private static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||
|
||||
@Override
|
||||
protected SDF getSDF(BlockPos center, Random random) {
|
||||
System.out.println(center);
|
||||
|
|
|
@ -22,10 +22,13 @@ 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