updated isFeatureChunk
and generatePieces
Signatures
This commit is contained in:
parent
8531be7b94
commit
036d594012
9 changed files with 88 additions and 65 deletions
|
@ -1,5 +1,6 @@
|
||||||
package ru.betterend.mixin.common;
|
package ru.betterend.mixin.common;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -18,15 +19,15 @@ import ru.betterend.world.generator.GeneratorOptions;
|
||||||
@Mixin(EndCityFeature.class)
|
@Mixin(EndCityFeature.class)
|
||||||
public class EndCityFeatureMixin {
|
public class EndCityFeatureMixin {
|
||||||
@Inject(method = "isFeatureChunk", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "isFeatureChunk", at = @At("HEAD"), cancellable = true)
|
||||||
private void be_isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, WorldgenRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
private void be_isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, WorldgenRandom chunkRandom, ChunkPos pos, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration defaultFeatureConfig, LevelHeightAccessor levelHeightAccessor, CallbackInfoReturnable<Boolean> info) {
|
||||||
if (GeneratorOptions.useNewGenerator()) {
|
if (GeneratorOptions.useNewGenerator()) {
|
||||||
int chance = GeneratorOptions.getEndCityFailChance();
|
int chance = GeneratorOptions.getEndCityFailChance();
|
||||||
if (chance == 0) {
|
if (chance == 0) {
|
||||||
info.setReturnValue(getYPositionForFeature(i, j, chunkGenerator) >= 60);
|
info.setReturnValue(getYPositionForFeature(pos, chunkGenerator, levelHeightAccessor) >= 60);
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
else if (chunkRandom.nextInt(chance) == 0){
|
else if (chunkRandom.nextInt(chance) == 0){
|
||||||
info.setReturnValue(getYPositionForFeature(i, j, chunkGenerator) >= 60);
|
info.setReturnValue(getYPositionForFeature(pos, chunkGenerator, levelHeightAccessor) >= 60);
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -37,7 +38,7 @@ public class EndCityFeatureMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private static int getYPositionForFeature(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
|
private static int getYPositionForFeature(ChunkPos pos, ChunkGenerator chunkGenerator, LevelHeightAccessor levelHeightAccessor) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
@ -26,16 +27,16 @@ public class EternalPortalStructure extends FeatureBaseStructure {
|
||||||
private static final StructureTemplate STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID);
|
private static final StructureTemplate STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) {
|
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, ChunkPos pos, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig, LevelHeightAccessor levelHeightAccessor) {
|
||||||
long x = (long) chunkPos.x * (long) chunkPos.x;
|
long x = (long) chunkPos.x * (long) chunkPos.x;
|
||||||
long z = (long) chunkPos.z * (long) chunkPos.z;
|
long z = (long) chunkPos.z * (long) chunkPos.z;
|
||||||
if (x + z < 1024L) {
|
if (x + z < 1024L) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (chunkGenerator.getBaseHeight((chunkX << 4) | 8, (chunkZ << 4) | 8, Heightmap.Types.WORLD_SURFACE_WG) < 10) {
|
if (chunkGenerator.getBaseHeight(pos.getBlockX(8), pos.getBlockX(8), Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor) < 10) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.isFeatureChunk(chunkGenerator, biomeSource, worldSeed, chunkRandom, chunkX, chunkZ, biome, chunkPos, featureConfig);
|
return super.isFeatureChunk(chunkGenerator, biomeSource, worldSeed, chunkRandom, pos, biome, chunkPos, featureConfig, levelHeightAccessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,19 +45,21 @@ public class EternalPortalStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PortalStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class PortalStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public PortalStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public PortalStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos pos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, pos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX( MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z =chunkPos.getBlockZ( MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 4) {
|
if (y > 4) {
|
||||||
this.pieces.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), true, random));
|
this.pieces.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), true, random));
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
//bbox is calculated lazy on get
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.world.structures.features;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
@ -22,12 +23,12 @@ public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) {
|
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, ChunkPos pos, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig, LevelHeightAccessor levelHeightAccessor) {
|
||||||
return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 20;
|
return getGenerationHeight(pos, chunkGenerator, levelHeightAccessor) >= 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {
|
private static int getGenerationHeight(ChunkPos chunkPos, ChunkGenerator chunkGenerator, LevelHeightAccessor levelHeightAccessor) {
|
||||||
Random random = new Random((long) (chunkX + chunkZ * 10387313));
|
Random random = new Random((long) (chunkPos.x + chunkPos.z * 10387313));
|
||||||
Rotation blockRotation = Rotation.getRandom(random);
|
Rotation blockRotation = Rotation.getRandom(random);
|
||||||
int i = 5;
|
int i = 5;
|
||||||
int j = 5;
|
int j = 5;
|
||||||
|
@ -40,12 +41,12 @@ public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureC
|
||||||
j = -5;
|
j = -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
int k = (chunkX << 4) + 7;
|
int k = chunkPos.getBlockX(7);
|
||||||
int l = (chunkZ << 4) + 7;
|
int l = chunkPos.getBlockZ(7);
|
||||||
int m = chunkGenerator.getFirstOccupiedHeight(k, l, Heightmap.Types.WORLD_SURFACE_WG);
|
int m = chunkGenerator.getFirstOccupiedHeight(k, l, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
int n = chunkGenerator.getFirstOccupiedHeight(k, l + j, Heightmap.Types.WORLD_SURFACE_WG);
|
int n = chunkGenerator.getFirstOccupiedHeight(k, l + j, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
int o = chunkGenerator.getFirstOccupiedHeight(k + i, l, Heightmap.Types.WORLD_SURFACE_WG);
|
int o = chunkGenerator.getFirstOccupiedHeight(k + i, l, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
int p = chunkGenerator.getFirstOccupiedHeight(k + i, l + j, Heightmap.Types.WORLD_SURFACE_WG);
|
int p = chunkGenerator.getFirstOccupiedHeight(k + i, l + j, Heightmap.Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
return Math.min(Math.min(m, n), Math.min(o, p));
|
return Math.min(Math.min(m, n), Math.min(o, p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
@ -103,18 +105,19 @@ public class GiantIceStarStructure extends SDFStructureFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StarStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class StarStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public StarStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public StarStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos pos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, pos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z = chunkPos.getBlockZ( MHelper.randRange(4, 12, random));
|
||||||
BlockPos start = new BlockPos(x, MHelper.randRange(32, 128, random), z);
|
BlockPos start = new BlockPos(x, MHelper.randRange(32, 128, random), z);
|
||||||
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
||||||
this.pieces.add(piece);
|
this.pieces.add(piece);
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ru.betterend.world.structures.features;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
|
@ -20,22 +22,23 @@ public class MegaLakeSmallStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, chunkPos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX( MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 5) {
|
if (y > 5) {
|
||||||
float radius = MHelper.randRange(20, 40, random);
|
float radius = MHelper.randRange(20, 40, random);
|
||||||
float depth = MHelper.randRange(5, 10, random);
|
float depth = MHelper.randRange(5, 10, random);
|
||||||
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random, biome);
|
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random, biome);
|
||||||
this.pieces.add(piece);
|
this.pieces.add(piece);
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ru.betterend.world.structures.features;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
|
@ -20,22 +22,23 @@ public class MegaLakeStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, chunkPos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 5) {
|
if (y > 5) {
|
||||||
float radius = MHelper.randRange(32, 64, random);
|
float radius = MHelper.randRange(32, 64, random);
|
||||||
float depth = MHelper.randRange(7, 15, random);
|
float depth = MHelper.randRange(7, 15, random);
|
||||||
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random, biome);
|
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random, biome);
|
||||||
this.pieces.add(piece);
|
this.pieces.add(piece);
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ru.betterend.world.structures.features;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
|
@ -20,22 +22,23 @@ public class MountainStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, chunkPos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z =chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 5) {
|
if (y > 5) {
|
||||||
float radius = MHelper.randRange(50, 100, random);
|
float radius = MHelper.randRange(50, 100, random);
|
||||||
float height = radius * MHelper.randRange(0.8F, 1.2F, random);
|
float height = radius * MHelper.randRange(0.8F, 1.2F, random);
|
||||||
CrystalMountainPiece piece = new CrystalMountainPiece(new BlockPos(x, y, z), radius, height, random, biome);
|
CrystalMountainPiece piece = new CrystalMountainPiece(new BlockPos(x, y, z), radius, height, random, biome);
|
||||||
this.pieces.add(piece);
|
this.pieces.add(piece);
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ru.betterend.world.structures.features;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -25,15 +27,15 @@ public class PaintedMountainStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, chunkPos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 50) {
|
if (y > 50) {
|
||||||
float radius = MHelper.randRange(50, 100, random);
|
float radius = MHelper.randRange(50, 100, random);
|
||||||
float height = radius * MHelper.randRange(0.4F, 0.6F, random);
|
float height = radius * MHelper.randRange(0.4F, 0.6F, random);
|
||||||
|
@ -44,7 +46,8 @@ public class PaintedMountainStructure extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
this.pieces.add(new PaintedMountainPiece(new BlockPos(x, y, z), radius, height, random, biome, slises ));
|
this.pieces.add(new PaintedMountainPiece(new BlockPos(x, y, z), radius, height, random, biome, slises ));
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
|
@ -26,21 +28,22 @@ public abstract class SDFStructureFeature extends FeatureBaseStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
|
||||||
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, int chunkX, int chunkZ, BoundingBox box, int references, long seed) {
|
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
|
||||||
super(feature, chunkX, chunkZ, box, references, seed);
|
super(feature, chunkPos, references, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, NoneFeatureConfiguration config) {
|
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
|
||||||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
|
||||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
|
||||||
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG);
|
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
|
||||||
if (y > 5) {
|
if (y > 5) {
|
||||||
BlockPos start = new BlockPos(x, y, z);
|
BlockPos start = new BlockPos(x, y, z);
|
||||||
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt());
|
||||||
this.pieces.add(piece);
|
this.pieces.add(piece);
|
||||||
}
|
}
|
||||||
this.calculateBoundingBox();
|
|
||||||
|
//this.calculateBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue