StructurePiece constructor and addAdditionalSaveData Signature

This commit is contained in:
Frank Bauer 2021-06-24 12:33:49 +02:00
parent 036d594012
commit 32f9bf288e
7 changed files with 34 additions and 26 deletions

View file

@ -2,11 +2,12 @@ package ru.betterend.world.structures.piece;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.levelgen.feature.StructurePieceType;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructurePiece;
public abstract class BasePiece extends StructurePiece {
protected BasePiece(StructurePieceType type, int i) {
super(type, i);
protected BasePiece(StructurePieceType type, int i, BoundingBox boundingBox) {
super(type, i, boundingBox);
}
protected BasePiece(StructurePieceType type, CompoundTag tag) {

View file

@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
@ -25,7 +26,7 @@ public class CavePiece extends BasePiece {
private float radius;
public CavePiece(BlockPos center, float radius, int id) {
super(EndStructures.CAVE_PIECE, id);
super(EndStructures.CAVE_PIECE, id, null);
this.center = center;
this.radius = radius;
this.noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
@ -39,12 +40,12 @@ public class CavePiece extends BasePiece {
@Override
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;
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();
double hr = radius * 0.75;
double nr = radius * 0.25;
@ -83,7 +84,7 @@ public class CavePiece extends BasePiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
tag.put("center", NbtUtils.writeBlockPos(center));
tag.putFloat("radius", radius);
}

View file

@ -8,9 +8,11 @@ import com.google.common.collect.Maps;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.SectionPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
@ -46,7 +48,7 @@ public class LakePiece extends BasePiece {
private ResourceLocation biomeID;
public LakePiece(BlockPos center, float radius, float depth, Random random, Biome biome) {
super(EndStructures.LAKE_PIECE, random.nextInt());
super(EndStructures.LAKE_PIECE, random.nextInt(), null);
this.center = center;
this.radius = radius;
this.depth = depth;
@ -63,7 +65,7 @@ public class LakePiece extends BasePiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
tag.put("center", NbtUtils.writeBlockPos(center));
tag.putFloat("radius", radius);
tag.putFloat("depth", depth);
@ -84,10 +86,10 @@ public class LakePiece extends BasePiece {
@Override
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;
int minY = this.boundingBox.minY();
int maxY = this.boundingBox.maxY();
int sx = SectionPos.sectionToBlockCoord(chunkPos.x);
int sz = SectionPos.sectionToBlockCoord(chunkPos.z);
MutableBlockPos mut = new MutableBlockPos();
ChunkAccess chunk = world.getChunk(chunkPos.x, chunkPos.z);
for (int x = 0; x < 16; x++) {
@ -144,8 +146,8 @@ public class LakePiece extends BasePiece {
}
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;
int minY = this.boundingBox.minY();
int maxY = this.boundingBox.maxY();
for (int x = 0; x < 16; x++) {
mut.setX(x);
for (int z = 0; z < 16; z++) {

View file

@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
@ -34,7 +35,7 @@ public abstract class MountainPiece extends BasePiece {
protected int seed2;
public MountainPiece(StructurePieceType type, BlockPos center, float radius, float height, Random random, Biome biome) {
super(type, random.nextInt());
super(type, random.nextInt(), null);
this.center = center;
this.radius = radius;
this.height = height;
@ -53,7 +54,7 @@ public abstract class MountainPiece extends BasePiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
tag.put("center", NbtUtils.writeBlockPos(center));
tag.putFloat("radius", radius);
tag.putFloat("height", height);

View file

@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
@ -30,7 +31,7 @@ public class NBTPiece extends BasePiece {
private boolean cover;
public NBTPiece(ResourceLocation structureID, StructureTemplate structure, BlockPos pos, int erosion, boolean cover, Random random) {
super(EndStructures.NBT_PIECE, random.nextInt());
super(EndStructures.NBT_PIECE, random.nextInt(), null);
this.structureID = structureID;
this.structure = structure;
this.rotation = Rotation.getRandom(random);
@ -47,7 +48,7 @@ public class NBTPiece extends BasePiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
tag.putString("structureID", structureID.toString());
tag.putInt("rotation", rotation.ordinal());
tag.putInt("mirror", mirror.ordinal());

View file

@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
@ -33,8 +34,8 @@ public class PaintedMountainPiece extends MountainPiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
super.addAdditionalSaveData(tag);
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
super.addAdditionalSaveData(serverLevel, tag);
ListTag slise = new ListTag();
for (BlockState state: slises) {
slise.add(NbtUtils.writeBlockState(state));

View file

@ -5,6 +5,7 @@ import java.util.function.Consumer;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
@ -18,7 +19,7 @@ public class VoxelPiece extends BasePiece {
private StructureWorld world;
public VoxelPiece(Consumer<StructureWorld> function, int id) {
super(EndStructures.VOXEL_PIECE, id);
super(EndStructures.VOXEL_PIECE, id, null);
world = new StructureWorld();
function.accept(world);
this.boundingBox = world.getBounds();
@ -30,7 +31,7 @@ public class VoxelPiece extends BasePiece {
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag compoundTag) {
tag.put("world", world.toBNT());
}