Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -1,8 +1,8 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.structure.StructurePiece;
|
||||
import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.world.level.levelgen.feature.StructurePieceType;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
|
||||
public abstract class BasePiece extends StructurePiece {
|
||||
protected BasePiece(StructurePieceType type, int i) {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
@ -23,7 +22,7 @@ public class CavePiece extends BasePiece {
|
|||
private OpenSimplexNoise noise;
|
||||
private BlockPos center;
|
||||
private float radius;
|
||||
|
||||
|
||||
public CavePiece(BlockPos center, float radius, int id) {
|
||||
super(EndStructures.CAVE_PIECE, id);
|
||||
this.center = center;
|
||||
|
@ -36,17 +35,16 @@ public class CavePiece extends BasePiece {
|
|||
super(EndStructures.CAVE_PIECE, tag);
|
||||
makeBoundingBox();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int x1 = MHelper.max(this.boundingBox.minX, blockBox.minX);
|
||||
int z1 = MHelper.max(this.boundingBox.minZ, blockBox.minZ);
|
||||
int x2 = MHelper.min(this.boundingBox.maxX, blockBox.maxX);
|
||||
int z2 = MHelper.min(this.boundingBox.maxZ, blockBox.maxZ);
|
||||
int y1 = this.boundingBox.minY;
|
||||
int y2 = this.boundingBox.maxY;
|
||||
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int x1 = MHelper.max(this.boundingBox.x0, blockBox.x0);
|
||||
int z1 = MHelper.max(this.boundingBox.z0, blockBox.z0);
|
||||
int x2 = MHelper.min(this.boundingBox.x1, blockBox.x1);
|
||||
int z2 = MHelper.min(this.boundingBox.z1, blockBox.z1);
|
||||
int y1 = this.boundingBox.y0;
|
||||
int y2 = this.boundingBox.y1;
|
||||
|
||||
double hr = radius * 0.75;
|
||||
double nr = radius * 0.25;
|
||||
MutableBlockPos pos = new MutableBlockPos();
|
||||
|
@ -67,10 +65,11 @@ public class CavePiece extends BasePiece {
|
|||
double r2 = r - 4.5;
|
||||
double dist = xsq + ysq + zsq;
|
||||
if (dist < r2 * r2) {
|
||||
if (world.getBlockState(pos).isIn(EndTags.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
if (world.getBlockState(pos).is(EndTags.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, CAVE_AIR);
|
||||
}
|
||||
} else if (dist < r * r) {
|
||||
}
|
||||
else if (dist < r * r) {
|
||||
if (world.getBlockState(pos).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, Blocks.END_STONE);
|
||||
}
|
||||
|
@ -78,23 +77,23 @@ public class CavePiece extends BasePiece {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
tag.put("center", NbtHelper.fromBlockPos(center));
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
tag.put("center", NbtUtils.writeBlockPos(center));
|
||||
tag.putFloat("radius", radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fromNbt(CompoundTag tag) {
|
||||
center = NbtHelper.toBlockPos(tag.getCompound("center"));
|
||||
center = NbtUtils.readBlockPos(tag.getCompound("center"));
|
||||
radius = tag.getFloat("radius");
|
||||
noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
}
|
||||
|
||||
|
||||
private void makeBoundingBox() {
|
||||
int minX = MHelper.floor(center.getX() - radius);
|
||||
int minY = MHelper.floor(center.getY() - radius);
|
||||
|
@ -102,6 +101,6 @@ public class CavePiece extends BasePiece {
|
|||
int maxX = MHelper.floor(center.getX() + radius + 1);
|
||||
int maxY = MHelper.floor(center.getY() + radius + 1);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 1);
|
||||
this.boundingBox = new BlockBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
this.boundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
|
@ -26,7 +25,7 @@ import ru.betterend.util.MHelper;
|
|||
|
||||
public class CrystalMountainPiece extends MountainPiece {
|
||||
private BlockState top;
|
||||
|
||||
|
||||
public CrystalMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome) {
|
||||
super(EndStructures.MOUNTAIN_PIECE, center, radius, height, random, biome);
|
||||
top = biome.getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
|
@ -43,14 +42,13 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int sx = chunkPos.getStartX();
|
||||
int sz = chunkPos.getStartZ();
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int sx = chunkPos.getMinBlockX();
|
||||
int sz = chunkPos.getMinBlockZ();
|
||||
MutableBlockPos pos = new MutableBlockPos();
|
||||
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE);
|
||||
Heightmap map2 = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
|
||||
ChunkAccess chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
Heightmap map = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE);
|
||||
Heightmap map2 = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE_WG);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int px = x + sx;
|
||||
int px2 = px - center.getX();
|
||||
|
@ -64,17 +62,16 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
if (dist < r2) {
|
||||
pos.setZ(z);
|
||||
dist = 1 - (float) Math.pow(dist / r2, 0.3);
|
||||
int minY = map.get(x, z);
|
||||
int minY = map.getFirstAvailable(x, z);
|
||||
if (minY < 10) {
|
||||
continue;
|
||||
}
|
||||
pos.setY(minY);
|
||||
while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56
|
||||
&& !chunk.getBlockState(pos.below()).is(Blocks.CAVE_AIR)) {
|
||||
while (!chunk.getBlockState(pos).is(EndTags.GEN_TERRAIN) && pos.getY() > 56 && !chunk.getBlockState(pos.below()).is(Blocks.CAVE_AIR)) {
|
||||
pos.setY(pos.getY() - 1);
|
||||
}
|
||||
minY = pos.getY();
|
||||
minY = Math.max(minY, map2.get(x, z));
|
||||
minY = Math.max(minY, map2.getFirstAvailable(x, z));
|
||||
if (minY > center.getY() - 8) {
|
||||
float maxY = dist * height * getHeightClamp(world, 12, px, pz);
|
||||
if (maxY > 0) {
|
||||
|
@ -83,30 +80,28 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
maxY += center.getY();
|
||||
int maxYI = (int) (maxY);
|
||||
int cover = maxYI - 1;
|
||||
boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(-0.4, 0.4, random)
|
||||
- (center.getY() + 14) * 0.1) > 0;
|
||||
boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(-0.4, 0.4, random) - (center.getY() + 14) * 0.1) > 0;
|
||||
for (int y = minY - 1; y < maxYI; y++) {
|
||||
pos.setY(y);
|
||||
chunk.setBlockAndUpdate(pos,
|
||||
needCover && y == cover ? top : Blocks.END_STONE.defaultBlockState(), false);
|
||||
chunk.setBlockState(pos, needCover && y == cover ? top : Blocks.END_STONE.defaultBlockState(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map = chunk.getHeightmap(Type.WORLD_SURFACE);
|
||||
|
||||
|
||||
map = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE);
|
||||
|
||||
// Big crystals
|
||||
int count = (map.get(8, 8) - (center.getY() + 24)) / 7;
|
||||
int count = (map.getFirstAvailable(8, 8) - (center.getY() + 24)) / 7;
|
||||
count = Mth.clamp(count, 0, 8);
|
||||
for (int i = 0; i < count; i++) {
|
||||
int radius = MHelper.randRange(2, 3, random);
|
||||
float fill = MHelper.randRange(0F, 1F, random);
|
||||
int x = MHelper.randRange(radius, 15 - radius, random);
|
||||
int z = MHelper.randRange(radius, 15 - radius, random);
|
||||
int y = map.get(x, z);
|
||||
int y = map.getFirstAvailable(x, z);
|
||||
if (y > 80) {
|
||||
pos.set(x, y, z);
|
||||
if (chunk.getBlockState(pos.below()).is(Blocks.END_STONE)) {
|
||||
|
@ -115,16 +110,16 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Small crystals
|
||||
count = (map.get(8, 8) - (center.getY() + 24)) / 2;
|
||||
count = (map.getFirstAvailable(8, 8) - (center.getY() + 24)) / 2;
|
||||
count = Mth.clamp(count, 4, 8);
|
||||
for (int i = 0; i < count; i++) {
|
||||
int radius = MHelper.randRange(1, 2, random);
|
||||
float fill = random.nextBoolean() ? 0 : 1;
|
||||
int x = MHelper.randRange(radius, 15 - radius, random);
|
||||
int z = MHelper.randRange(radius, 15 - radius, random);
|
||||
int y = map.get(x, z);
|
||||
int y = map.getFirstAvailable(x, z);
|
||||
if (y > 80) {
|
||||
pos.set(x, y, z);
|
||||
if (chunk.getBlockState(pos.below()).getBlock() == Blocks.END_STONE) {
|
||||
|
@ -133,15 +128,15 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void crystal(Chunk chunk, BlockPos pos, int radius, int height, float fill, Random random) {
|
||||
|
||||
private void crystal(ChunkAccess chunk, BlockPos pos, int radius, int height, float fill, Random random) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
int max = MHelper.floor(fill * radius + radius + 0.5F);
|
||||
height += pos.getY();
|
||||
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE);
|
||||
Heightmap map = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE);
|
||||
int coefX = MHelper.randRange(-1, 1, random);
|
||||
int coefZ = MHelper.randRange(-1, 1, random);
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
|
@ -153,14 +148,14 @@ public class CrystalMountainPiece extends MountainPiece {
|
|||
if (mut.getZ() >= 0 && mut.getZ() < 16) {
|
||||
int az = Math.abs(z);
|
||||
if (ax + az < max) {
|
||||
int minY = map.get(mut.getX(), mut.getZ()) - MHelper.randRange(3, 7, random);
|
||||
int minY = map.getFirstAvailable(mut.getX(), mut.getZ()) - MHelper.randRange(3, 7, random);
|
||||
if (pos.getY() - minY > 8) {
|
||||
minY = pos.getY() - 8;
|
||||
}
|
||||
int h = coefX * x + coefZ * z + height;
|
||||
for (int y = minY; y < h; y++) {
|
||||
mut.setY(y);
|
||||
chunk.setBlockAndUpdate(mut, EndBlocks.AURORA_CRYSTAL.defaultBlockState(), false);
|
||||
chunk.setBlockState(mut, EndBlocks.AURORA_CRYSTAL.defaultBlockState(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,25 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -42,9 +41,9 @@ public class LakePiece extends BasePiece {
|
|||
private float aspect;
|
||||
private float depth;
|
||||
private int seed;
|
||||
|
||||
|
||||
private ResourceLocation biomeID;
|
||||
|
||||
|
||||
public LakePiece(BlockPos center, float radius, float depth, Random random, Biome biome) {
|
||||
super(EndStructures.LAKE_PIECE, random.nextInt());
|
||||
this.center = center;
|
||||
|
@ -63,8 +62,8 @@ public class LakePiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
tag.put("center", NbtHelper.fromBlockPos(center));
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
tag.put("center", NbtUtils.writeBlockPos(center));
|
||||
tag.putFloat("radius", radius);
|
||||
tag.putFloat("depth", depth);
|
||||
tag.putInt("seed", seed);
|
||||
|
@ -73,7 +72,7 @@ public class LakePiece extends BasePiece {
|
|||
|
||||
@Override
|
||||
protected void fromNbt(CompoundTag tag) {
|
||||
center = NbtHelper.toBlockPos(tag.getCompound("center"));
|
||||
center = NbtUtils.readBlockPos(tag.getCompound("center"));
|
||||
radius = tag.getFloat("radius");
|
||||
depth = tag.getFloat("depth");
|
||||
seed = tag.getInt("seed");
|
||||
|
@ -83,14 +82,13 @@ public class LakePiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int minY = this.boundingBox.minY;
|
||||
int maxY = this.boundingBox.maxY;
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int minY = this.boundingBox.y0;
|
||||
int maxY = this.boundingBox.y1;
|
||||
int sx = chunkPos.x << 4;
|
||||
int sz = chunkPos.z << 4;
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
ChunkAccess chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
mut.setX(x);
|
||||
int wx = x | sx;
|
||||
|
@ -102,13 +100,12 @@ public class LakePiece extends BasePiece {
|
|||
double nz = wz * 0.1;
|
||||
int z2 = wz - center.getZ();
|
||||
float clamp = getHeightClamp(world, 8, wx, wz);
|
||||
if (clamp < 0.01)
|
||||
continue;
|
||||
|
||||
if (clamp < 0.01) continue;
|
||||
|
||||
double n = noise.eval(nx, nz) * 1.5 + 1.5;
|
||||
double x3 = MHelper.pow2(x2 + noise.eval(nx, nz, 100) * 10);
|
||||
double z3 = MHelper.pow2(z2 + noise.eval(nx, nz, -100) * 10);
|
||||
|
||||
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
mut.setY((int) (y + n));
|
||||
double y2 = MHelper.pow2((y - center.getY()) * aspect);
|
||||
|
@ -119,24 +116,23 @@ public class LakePiece extends BasePiece {
|
|||
double dist = x3 + y2 + z3;
|
||||
if (dist < r2) {
|
||||
BlockState state = chunk.getBlockState(mut);
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.isAir()) {
|
||||
state = mut.getY() < center.getY() ? WATER : AIR;
|
||||
chunk.setBlockAndUpdate(mut, state, false);
|
||||
if (state.is(EndTags.GEN_TERRAIN) || state.isAir()) {
|
||||
state = mut.getY() < center.getY() ? WATER : CAVE_AIR;
|
||||
chunk.setBlockState(mut, state, false);
|
||||
}
|
||||
} else if (dist <= r3 && mut.getY() < center.getY()) {
|
||||
}
|
||||
else if (dist <= r3 && mut.getY() < center.getY()) {
|
||||
BlockState state = chunk.getBlockState(mut);
|
||||
BlockPos worldPos = mut.add(sx, 0, sz);
|
||||
if (!state.isFullCube(world, worldPos) && !state.isSolidBlock(world, worldPos)) {
|
||||
state = chunk.getBlockState(mut.up());
|
||||
BlockPos worldPos = mut.offset(sx, 0, sz);
|
||||
if (!state.isCollisionShapeFullBlock(world, worldPos) && !state.isRedstoneConductor(world, worldPos)) {
|
||||
state = chunk.getBlockState(mut.above());
|
||||
if (state.isAir()) {
|
||||
state = random.nextBoolean() ? ENDSTONE
|
||||
: world.getBiome(worldPos).getGenerationSettings().getSurfaceBuilderConfig()
|
||||
.getTopMaterial();
|
||||
} else {
|
||||
state = state.getFluidState().isEmpty() ? ENDSTONE
|
||||
: EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
state = random.nextBoolean() ? ENDSTONE : world.getBiome(worldPos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
}
|
||||
chunk.setBlockAndUpdate(mut, state, false);
|
||||
else {
|
||||
state = state.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
}
|
||||
chunk.setBlockState(mut, state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,10 +141,10 @@ public class LakePiece extends BasePiece {
|
|||
fixWater(world, chunk, mut, random, sx, sz);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fixWater(WorldGenLevel world, Chunk chunk, MutableBlockPos mut, Random random, int sx, int sz) {
|
||||
int minY = this.boundingBox.minY;
|
||||
int maxY = this.boundingBox.maxY;
|
||||
|
||||
private void fixWater(WorldGenLevel world, ChunkAccess chunk, MutableBlockPos mut, Random random, int sx, int sz) {
|
||||
int minY = this.boundingBox.y0;
|
||||
int maxY = this.boundingBox.y1;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
mut.setX(x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
|
@ -160,78 +156,76 @@ public class LakePiece extends BasePiece {
|
|||
mut.setY(y - 1);
|
||||
if (chunk.getBlockState(mut).isAir()) {
|
||||
mut.setY(y + 1);
|
||||
|
||||
|
||||
BlockState bState = chunk.getBlockState(mut);
|
||||
if (bState.isAir()) {
|
||||
bState = random.nextBoolean() ? ENDSTONE
|
||||
: world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings()
|
||||
.getSurfaceBuilderConfig().getTopMaterial();
|
||||
} else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE
|
||||
: EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz)).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
}
|
||||
|
||||
else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
}
|
||||
|
||||
mut.setY(y);
|
||||
|
||||
|
||||
makeEndstonePillar(chunk, mut, bState);
|
||||
} else if (x > 1 && x < 15 && z > 1 && z < 15) {
|
||||
}
|
||||
else if (x > 1 && x < 15 && z > 1 && z < 15) {
|
||||
mut.setY(y);
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
BlockPos wPos = mut.add(dir.getOffsetX(), 0, dir.getOffsetZ());
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
BlockPos wPos = mut.offset(dir.getStepX(), 0, dir.getStepZ());
|
||||
if (chunk.getBlockState(wPos).isAir()) {
|
||||
mut.setY(y + 1);
|
||||
BlockState bState = chunk.getBlockState(mut);
|
||||
if (bState.isAir()) {
|
||||
bState = random.nextBoolean() ? ENDSTONE
|
||||
: world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings()
|
||||
.getSurfaceBuilderConfig().getTopMaterial();
|
||||
} else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE
|
||||
: EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.offset(sx, 0, sz)).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
}
|
||||
else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.defaultBlockState();
|
||||
}
|
||||
mut.setY(y);
|
||||
makeEndstonePillar(chunk, mut, bState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (chunk.getBlockState(mut.move(Direction.UP)).isAir()) {
|
||||
chunk.getFluidTickScheduler().schedule(mut.move(Direction.DOWN), state.getFluid(), 0);
|
||||
}
|
||||
else if (chunk.getBlockState(mut.move(Direction.UP)).isAir()) {
|
||||
chunk.getLiquidTicks().scheduleTick(mut.move(Direction.DOWN), state.getType(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeEndstonePillar(Chunk chunk, MutableBlockPos mut, BlockState terrain) {
|
||||
chunk.setBlockAndUpdate(mut, terrain, false);
|
||||
|
||||
private void makeEndstonePillar(ChunkAccess chunk, MutableBlockPos mut, BlockState terrain) {
|
||||
chunk.setBlockState(mut, terrain, false);
|
||||
mut.setY(mut.getY() - 1);
|
||||
while (!chunk.getFluidState(mut).isEmpty()) {
|
||||
chunk.setBlockAndUpdate(mut, ENDSTONE, false);
|
||||
chunk.setBlockState(mut, ENDSTONE, false);
|
||||
mut.setY(mut.getY() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getHeight(WorldGenLevel world, BlockPos pos) {
|
||||
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
|
||||
int h = heightmap.getOrDefault(p, Byte.MIN_VALUE);
|
||||
if (h > Byte.MIN_VALUE) {
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
|
||||
heightmap.put(p, (byte) 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
h = world.getHeight(Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
h = Mth.abs(h - center.getY());
|
||||
h = h < 8 ? 1 : 0;
|
||||
|
||||
|
||||
heightmap.put(p, (byte) h);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
private float getHeightClamp(WorldGenLevel world, int radius, int posX, int posZ) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
int r2 = radius * radius;
|
||||
|
@ -253,7 +247,7 @@ public class LakePiece extends BasePiece {
|
|||
height /= max;
|
||||
return Mth.clamp(height, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
private void makeBoundingBox() {
|
||||
int minX = MHelper.floor(center.getX() - radius - 8);
|
||||
int minY = MHelper.floor(center.getY() - depth - 8);
|
||||
|
@ -261,6 +255,6 @@ public class LakePiece extends BasePiece {
|
|||
int maxX = MHelper.floor(center.getX() + radius + 8);
|
||||
int maxY = MHelper.floor(center.getY() + depth);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 8);
|
||||
this.boundingBox = new BlockBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
this.boundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
|
@ -4,19 +4,18 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.feature.StructurePieceType;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
@ -32,9 +31,8 @@ public abstract class MountainPiece extends BasePiece {
|
|||
protected ResourceLocation biomeID;
|
||||
protected int seed1;
|
||||
protected int seed2;
|
||||
|
||||
public MountainPiece(StructurePieceType type, BlockPos center, float radius, float height, Random random,
|
||||
Biome biome) {
|
||||
|
||||
public MountainPiece(StructurePieceType type, BlockPos center, float radius, float height, Random random, Biome biome) {
|
||||
super(type, random.nextInt());
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
|
@ -54,8 +52,8 @@ public abstract class MountainPiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
tag.put("center", NbtHelper.fromBlockPos(center));
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
tag.put("center", NbtUtils.writeBlockPos(center));
|
||||
tag.putFloat("radius", radius);
|
||||
tag.putFloat("height", height);
|
||||
tag.putString("biome", biomeID.toString());
|
||||
|
@ -65,7 +63,7 @@ public abstract class MountainPiece extends BasePiece {
|
|||
|
||||
@Override
|
||||
protected void fromNbt(CompoundTag tag) {
|
||||
center = NbtHelper.toBlockPos(tag.getCompound("center"));
|
||||
center = NbtUtils.readBlockPos(tag.getCompound("center"));
|
||||
radius = tag.getFloat("radius");
|
||||
height = tag.getFloat("height");
|
||||
biomeID = new ResourceLocation(tag.getString("biome"));
|
||||
|
@ -75,14 +73,14 @@ public abstract class MountainPiece extends BasePiece {
|
|||
noise1 = new OpenSimplexNoise(seed1);
|
||||
noise2 = new OpenSimplexNoise(seed2);
|
||||
}
|
||||
|
||||
|
||||
private int getHeight(WorldGenLevel world, BlockPos pos) {
|
||||
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
|
||||
int h = heightmap.getOrDefault(p, Integer.MIN_VALUE);
|
||||
if (h > Integer.MIN_VALUE) {
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
|
||||
heightmap.put(p, -10);
|
||||
return -10;
|
||||
|
@ -94,20 +92,19 @@ public abstract class MountainPiece extends BasePiece {
|
|||
heightmap.put(p, h);
|
||||
return h;
|
||||
}
|
||||
|
||||
h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01)
|
||||
* noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8);
|
||||
|
||||
|
||||
h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8);
|
||||
|
||||
if (h < 0) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
heightmap.put(p, h);
|
||||
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
protected float getHeightClamp(WorldGenLevel world, int radius, int posX, int posZ) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
float height = 0;
|
||||
|
@ -128,12 +125,12 @@ public abstract class MountainPiece extends BasePiece {
|
|||
height /= max;
|
||||
return Mth.clamp(height / radius, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
private void makeBoundingBox() {
|
||||
int minX = MHelper.floor(center.getX() - radius);
|
||||
int minZ = MHelper.floor(center.getZ() - radius);
|
||||
int maxX = MHelper.floor(center.getX() + radius + 1);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 1);
|
||||
this.boundingBox = new BlockBox(minX, minZ, maxX, maxZ);
|
||||
this.boundingBox = new BoundingBox(minX, minZ, maxX, maxZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.StructureHelper;
|
||||
|
@ -23,19 +22,18 @@ import ru.betterend.util.StructureHelper;
|
|||
public class NBTPiece extends BasePiece {
|
||||
private ResourceLocation structureID;
|
||||
private Rotation rotation;
|
||||
private BlockMirror mirror;
|
||||
private Structure structure;
|
||||
private Mirror mirror;
|
||||
private StructureTemplate structure;
|
||||
private BlockPos pos;
|
||||
private int erosion;
|
||||
private boolean cover;
|
||||
|
||||
public NBTPiece(ResourceLocation structureID, Structure structure, BlockPos pos, int erosion, boolean cover,
|
||||
Random random) {
|
||||
|
||||
public NBTPiece(ResourceLocation structureID, StructureTemplate structure, BlockPos pos, int erosion, boolean cover, Random random) {
|
||||
super(EndStructures.NBT_PIECE, random.nextInt());
|
||||
this.structureID = structureID;
|
||||
this.structure = structure;
|
||||
this.rotation = Rotation.random(random);
|
||||
this.mirror = BlockMirror.values()[random.nextInt(3)];
|
||||
this.rotation = Rotation.getRandom(random);
|
||||
this.mirror = Mirror.values()[random.nextInt(3)];
|
||||
this.pos = StructureHelper.offsetPos(pos, structure, rotation, mirror);
|
||||
this.erosion = erosion;
|
||||
this.cover = cover;
|
||||
|
@ -48,12 +46,12 @@ public class NBTPiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
tag.putString("id", structureID.toString());
|
||||
tag.putInt("rotation", rotation.ordinal());
|
||||
tag.putInt("mirror", mirror.ordinal());
|
||||
tag.putInt("erosion", erosion);
|
||||
tag.put("pos", NbtHelper.fromBlockPos(pos));
|
||||
tag.put("pos", NbtUtils.writeBlockPos(pos));
|
||||
tag.putBoolean("cover", cover);
|
||||
}
|
||||
|
||||
|
@ -61,27 +59,25 @@ public class NBTPiece extends BasePiece {
|
|||
protected void fromNbt(CompoundTag tag) {
|
||||
structureID = new ResourceLocation(tag.getString("id"));
|
||||
rotation = Rotation.values()[tag.getInt("rotation")];
|
||||
mirror = BlockMirror.values()[tag.getInt("mirror")];
|
||||
mirror = Mirror.values()[tag.getInt("mirror")];
|
||||
erosion = tag.getInt("erosion");
|
||||
pos = NbtHelper.toBlockPos(tag.getCompound("pos"));
|
||||
pos = NbtUtils.readBlockPos(tag.getCompound("pos"));
|
||||
cover = tag.getBoolean("cover");
|
||||
structure = StructureHelper.readStructure(structureID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
BlockBox bounds = new BlockBox(blockBox);
|
||||
bounds.maxY = this.boundingBox.maxY;
|
||||
bounds.minY = this.boundingBox.minY;
|
||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror)
|
||||
.setBoundingBox(bounds);
|
||||
structure.place(world, pos, placementData, random);
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
BoundingBox bounds = new BoundingBox(blockBox);
|
||||
bounds.y1 = this.boundingBox.y1;
|
||||
bounds.y0 = this.boundingBox.y0;
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
||||
structure.placeInWorldChunk(world, pos, placementData, random);
|
||||
if (erosion > 0) {
|
||||
bounds.maxX = MHelper.min(bounds.maxX, boundingBox.maxX);
|
||||
bounds.minX = MHelper.max(bounds.minX, boundingBox.minX);
|
||||
bounds.maxZ = MHelper.min(bounds.maxZ, boundingBox.maxZ);
|
||||
bounds.minZ = MHelper.max(bounds.minZ, boundingBox.minZ);
|
||||
bounds.x1 = MHelper.min(bounds.x1, boundingBox.x1);
|
||||
bounds.x0 = MHelper.max(bounds.x0, boundingBox.x0);
|
||||
bounds.z1 = MHelper.min(bounds.z1, boundingBox.z1);
|
||||
bounds.z0 = MHelper.max(bounds.z0, boundingBox.z0);
|
||||
StructureHelper.erode(world, bounds, erosion, random);
|
||||
}
|
||||
if (cover) {
|
||||
|
@ -89,7 +85,7 @@ public class NBTPiece extends BasePiece {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeBoundingBox() {
|
||||
this.boundingBox = StructureHelper.getStructureBounds(pos, structure, rotation, mirror);
|
||||
}
|
||||
|
|
|
@ -1,31 +1,28 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class PaintedMountainPiece extends MountainPiece {
|
||||
private BlockState[] slises;
|
||||
|
||||
public PaintedMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome,
|
||||
BlockState[] slises) {
|
||||
public PaintedMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome, BlockState[] slises) {
|
||||
super(EndStructures.PAINTED_MOUNTAIN_PIECE, center, radius, height, random, biome);
|
||||
this.slises = slises;
|
||||
}
|
||||
|
@ -35,11 +32,11 @@ public class PaintedMountainPiece extends MountainPiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
super.toNbt(tag);
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
ListTag slise = new ListTag();
|
||||
for (BlockState state : slises) {
|
||||
slise.add(NbtHelper.fromBlockState(state));
|
||||
for (BlockState state: slises) {
|
||||
slise.add(NbtUtils.writeBlockState(state));
|
||||
}
|
||||
tag.put("slises", slise);
|
||||
}
|
||||
|
@ -50,19 +47,18 @@ public class PaintedMountainPiece extends MountainPiece {
|
|||
ListTag slise = tag.getList("slises", 10);
|
||||
slises = new BlockState[slise.size()];
|
||||
for (int i = 0; i < slises.length; i++) {
|
||||
slises[i] = NbtHelper.toBlockState(slise.getCompound(i));
|
||||
slises[i] = NbtUtils.readBlockState(slise.getCompound(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int sx = chunkPos.getStartX();
|
||||
int sz = chunkPos.getStartZ();
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int sx = chunkPos.getMinBlockX();
|
||||
int sz = chunkPos.getMinBlockZ();
|
||||
MutableBlockPos pos = new MutableBlockPos();
|
||||
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE);
|
||||
Heightmap map2 = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
|
||||
ChunkAccess chunk = world.getChunk(chunkPos.x, chunkPos.z);
|
||||
Heightmap map = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE);
|
||||
Heightmap map2 = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE_WG);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
int px = x + sx;
|
||||
int px2 = px - center.getX();
|
||||
|
@ -76,32 +72,31 @@ public class PaintedMountainPiece extends MountainPiece {
|
|||
if (dist < r2) {
|
||||
pos.setZ(z);
|
||||
dist = 1 - dist / r2;
|
||||
int minY = map.get(x, z);
|
||||
int minY = map.getFirstAvailable(x, z);
|
||||
pos.setY(minY - 1);
|
||||
while (chunk.getBlockState(pos).isAir() && pos.getY() > 50) {
|
||||
pos.setY(minY--);
|
||||
pos.setY(minY --);
|
||||
}
|
||||
minY = pos.getY();
|
||||
minY = Math.max(minY, map2.get(x, z));
|
||||
minY = Math.max(minY, map2.getFirstAvailable(x, z));
|
||||
if (minY > center.getY() - 8) {
|
||||
float maxY = dist * height * getHeightClamp(world, 10, px, pz);
|
||||
if (maxY > 0) {
|
||||
maxY *= (float) noise1.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
|
||||
maxY *= (float) noise1.eval(px * 0.1, pz * 0.1) * 0.1F + 0.9F;
|
||||
maxY += center.getY();
|
||||
float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5
|
||||
+ noise1.eval(px * 0.2, pz * 0.2) * 2 + 7);
|
||||
float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5 + noise1.eval(px * 0.2, pz * 0.2) * 2 + 7);
|
||||
for (int y = minY - 1; y < maxY; y++) {
|
||||
pos.setY(y);
|
||||
int index = MHelper.floor((y + offset) * 0.65F) % slises.length;
|
||||
chunk.setBlockAndUpdate(pos, slises[index], false);
|
||||
chunk.setBlockState(pos, slises[index], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,20 @@ package ru.betterend.world.structures.piece;
|
|||
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
import ru.betterend.world.structures.StructureWorld;
|
||||
|
||||
public class VoxelPiece extends BasePiece {
|
||||
private StructureWorld world;
|
||||
|
||||
|
||||
public VoxelPiece(Consumer<StructureWorld> function, int id) {
|
||||
super(EndStructures.VOXEL_PIECE, id);
|
||||
world = new StructureWorld();
|
||||
|
@ -30,7 +29,7 @@ public class VoxelPiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
protected void addAdditionalSaveData(CompoundTag tag) {
|
||||
tag.put("world", world.toBNT());
|
||||
}
|
||||
|
||||
|
@ -40,8 +39,7 @@ public class VoxelPiece extends BasePiece {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
this.world.placeChunk(world, chunkPos);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue