Code style changes, entities fixes

This commit is contained in:
paulevsGitch 2021-07-08 00:21:47 +03:00
parent 9d604b2d25
commit 44962e18b6
377 changed files with 5038 additions and 4914 deletions

View file

@ -10,14 +10,14 @@ import ru.betterend.registry.EndFeatures;
public class EndBiome extends BCLBiome {
public EndBiome(BCLBiomeDef def) {
super(updateDef(def));
}
public EndBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance, boolean hasCaves) {
super(id, biome, fogDensity, genChance);
this.addCustomData("has_caves", hasCaves);
}
private static BCLBiomeDef updateDef(BCLBiomeDef def) {
def.loadConfigValues(Configs.BIOME_CONFIG);
EndFeatures.addDefaultFeatures(def);

View file

@ -13,17 +13,17 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome {
.setPlantsColor(108, 25, 46)
.setWaterAndFogColor(186, 77, 237)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F));
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
}
@Override
public float getFloorDensity() {
return 0.01F;
}
@Override
public float getCeilDensity() {
return 0.1F;

View file

@ -10,12 +10,12 @@ public class EmptyEndCaveBiome extends EndCaveBiome {
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
}
@Override
public float getFloorDensity() {
return 0.1F;
}
@Override
public float getCeilDensity() {
return 0.1F;

View file

@ -13,18 +13,18 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome {
.setPlantsColor(0, 131, 145)
.setWaterAndFogColor(31, 167, 212)
.setParticles(EndParticles.SMARAGDANT, 0.001F));
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
}
@Override
public float getFloorDensity() {
return 0.1F;
}
@Override
public float getCeilDensity() {
return 0.1F;

View file

@ -14,55 +14,53 @@ import ru.betterend.util.ShuffelingListExtended;
import ru.betterend.world.biome.EndBiome;
import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
import java.util.Random;
public class EndCaveBiome extends EndBiome {
final private ShufflingList<Feature<?>> floorFeatures = new ShufflingList<>();
final private ShufflingList<Feature<?>> ceilFeatures = new ShufflingList<>();
public EndCaveBiome(BCLBiomeDef definition) {
super(makeDef(definition));
}
private static BCLBiomeDef makeDef(BCLBiomeDef definition) {
BCLFeature feature = BCLFeature.makeChunkFeature(
BetterEnd.makeID(definition.getID().getPath() + "_cave_populator"),
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) BiomeAPI.getBiome(definition.getID()))
BetterEnd.makeID(definition.getID().getPath() + "_cave_populator"),
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) BiomeAPI.getBiome(definition.getID()))
);
definition.setCategory(BiomeCategory.NONE).addFeature(feature);
definition.setMusic(EndSounds.MUSIC_CAVES);
definition.setLoop(EndSounds.AMBIENT_CAVES);
return definition;
}
public void addFloorFeature(Feature<?> feature, int weight) {
floorFeatures.add(feature, weight);
}
public void addCeilFeature(Feature<?> feature, int weight) {
ceilFeatures.add(feature, weight);
}
public Feature<?> getFloorFeature() {
return ((ShuffelingListExtended<Feature<?>>)floorFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>)floorFeatures).getOne();
return ((ShuffelingListExtended<Feature<?>>) floorFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>) floorFeatures).getOne();
}
public Feature<?> getCeilFeature() {
return ((ShuffelingListExtended<Feature<?>>)ceilFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>)ceilFeatures).getOne();
return ((ShuffelingListExtended<Feature<?>>) ceilFeatures).isEmpty() ? null : ((ShuffelingListExtended<Feature<?>>) ceilFeatures).getOne();
}
public float getFloorDensity() {
return 0;
}
public float getCeilDensity() {
return 0;
}
public BlockState getCeil(BlockPos pos) {
return null;
}
public BlockState getWall(BlockPos pos) {
return null;
}

View file

@ -12,18 +12,18 @@ public class JadeCaveBiome extends EndCaveBiome {
private static final OpenSimplexNoise WALL_NOISE = new OpenSimplexNoise("jade_cave".hashCode());
private static final OpenSimplexNoise DEPTH_NOISE = new OpenSimplexNoise("depth_noise".hashCode());
private static final BlockState[] JADE = new BlockState[3];
public JadeCaveBiome() {
super(new BCLBiomeDef(BetterEnd.makeID("jade_cave"))
.setFogColor(118, 150, 112)
.setFogDensity(2.0F)
.setWaterAndFogColor(95, 223, 255)
.setFogColor(118, 150, 112)
.setFogDensity(2.0F)
.setWaterAndFogColor(95, 223, 255)
);
JADE[0] = EndBlocks.VIRID_JADESTONE.stone.defaultBlockState();
JADE[1] = EndBlocks.AZURE_JADESTONE.stone.defaultBlockState();
JADE[2] = EndBlocks.SANDY_JADESTONE.stone.defaultBlockState();
}
@Override
public BlockState getWall(BlockPos pos) {
double depth = DEPTH_NOISE.eval(pos.getX() * 0.02, pos.getZ() * 0.02) * 0.2 + 0.5;

View file

@ -18,29 +18,29 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
.setWaterAndFogColor(186, 77, 237)
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
.setSurface(EndBlocks.CAVE_MOSS));
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.CAVE_BUSH, 5);
this.addFloorFeature(EndFeatures.CAVE_GRASS, 40);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5);
this.addCeilFeature(EndFeatures.CAVE_BUSH, 1);
this.addCeilFeature(EndFeatures.CAVE_PUMPKIN, 1);
this.addCeilFeature(EndFeatures.RUBINEA, 3);
this.addCeilFeature(EndFeatures.MAGNULA, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10);
}
@Override
public float getFloorDensity() {
return 0.2F;
}
@Override
public float getCeilDensity() {
return 0.1F;
}
@Override
public BlockState getCeil(BlockPos pos) {
return EndBlocks.CAVE_MOSS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.TOP);

View file

@ -15,18 +15,18 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome {
.setWaterAndFogColor(31, 167, 212)
.setParticles(EndParticles.SMARAGDANT, 0.001F)
.setSurface(EndBlocks.CAVE_MOSS));
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
}
@Override
public float getFloorDensity() {
return 0.1F;
}
@Override
public float getCeilDensity() {
return 0.1F;

View file

@ -1,14 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
@ -38,7 +35,8 @@ public class BiomeIslandFeature extends DefaultFeature {
BlockState topMaterial = surfaceConfig.getTopMaterial();
if (BlocksHelper.isFluid(topMaterial)) {
topBlock = ((SurfaceBuilderBaseConfiguration) surfaceConfig).getUnderwaterMaterial();
} else {
}
else {
topBlock = topMaterial;
}
underBlock = surfaceConfig.getUnderMaterial();

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.bclib.util.BlocksHelper;
@ -9,9 +7,11 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
public BlueVineFeature() {
super(5);
}

View file

@ -1,10 +1,7 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -13,6 +10,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.blocks.EndBlockProperties;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class CavePumpkinFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -6,7 +6,7 @@ public class CharniaFeature extends UnderwaterPlantFeature {
public CharniaFeature(Block plant) {
super(plant, 6);
}
@Override
protected int getChance() {
return 3;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LevelReader;
@ -10,7 +8,6 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
@ -27,6 +24,8 @@ import ru.bclib.util.StructureHelper;
import ru.bclib.world.features.NBTStructureFeature;
import ru.betterend.util.BlockFixer;
import java.util.Random;
public class CrashedShipFeature extends NBTStructureFeature {
private static final StructureProcessor REPLACER;
private static final String STRUCTURE_PATH = "/data/minecraft/structures/end_city/ship.nbt";
@ -117,8 +116,8 @@ public class CrashedShipFeature extends NBTStructureFeature {
REPLACER = new StructureProcessor() {
@Override
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlaceSettings structurePlacementData) {
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlaceSettings structurePlacementData) {
BlockState state = structureBlockInfo2.state;
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
@ -10,17 +8,19 @@ import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import java.util.Random;
public class DoublePlantFeature extends ScatterFeature {
private final Block smallPlant;
private final Block largePlant;
private Block plant;
public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) {
super(radius);
this.smallPlant = smallPlant;
this.largePlant = largePlant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;

View file

@ -1,12 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.EndLilySeedBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLilyFeature extends UnderwaterPlantScatter {
public EndLilyFeature(int radius) {
super(radius);
@ -17,7 +17,7 @@ public class EndLilyFeature extends UnderwaterPlantScatter {
EndLilySeedBlock seed = (EndLilySeedBlock) EndBlocks.END_LILY_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,12 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.EndLotusSeedBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLotusFeature extends UnderwaterPlantScatter {
public EndLotusFeature(int radius) {
super(radius);
@ -17,7 +17,7 @@ public class EndLotusFeature extends UnderwaterPlantScatter {
EndLotusSeedBlock seed = (EndLotusSeedBlock) EndBlocks.END_LOTUS_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -13,6 +11,8 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.EndLotusLeafBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLotusLeafFeature extends ScatterFeature {
public EndLotusLeafFeature(int radius) {
super(radius);
@ -24,41 +24,41 @@ public class EndLotusLeafFeature extends ScatterFeature {
generateLeaf(world, blockPos);
}
}
@Override
protected int getChance() {
return 15;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurface(world, pos);
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
for (Direction move : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i ++) {
for (int i = 0; i < 4; i++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY());
int count = 0;
for (int x = -1; x < 2; x ++) {
for (int x = -1; x < 2; x++) {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z ++) {
for (int z = -1; z < 2; z++) {
p.setZ(pos.getZ() + z);
if (world.isEmptyBlock(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count ++;
count++;
}
}
return count == 9;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -13,6 +11,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class FilaluxFeature extends SkyScatterFeature {
public FilaluxFeature() {
super(10);
@ -24,7 +24,7 @@ public class FilaluxFeature extends SkyScatterFeature {
BlockState wings = EndBlocks.FILALUX_WINGS.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.FILALUX_LANTERN);
BlocksHelper.setWithoutUpdate(world, blockPos.above(), wings.setValue(BlockStateProperties.FACING, Direction.UP));
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, blockPos.relative(dir), wings.setValue(BlockStateProperties.FACING, dir));
}
int length = MHelper.randRange(1, 3, random);

View file

@ -1,11 +1,8 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -13,6 +10,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public abstract class FullHeightScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
@ -22,7 +21,7 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);

View file

@ -1,12 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class GlowPillarFeature extends ScatterFeature {
public GlowPillarFeature() {
super(9);
@ -22,7 +22,7 @@ public class GlowPillarFeature extends ScatterFeature {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 10;

View file

@ -1,12 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.HydraluxSaplingBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class HydraluxFeature extends UnderwaterPlantScatter {
public HydraluxFeature(int radius) {
super(radius);
@ -17,7 +17,7 @@ public class HydraluxFeature extends UnderwaterPlantScatter {
HydraluxSaplingBlock seed = (HydraluxSaplingBlock) EndBlocks.HYDRALUX_SAPLING;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -1,11 +1,8 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -13,6 +10,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public abstract class InvertedScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
@ -22,7 +21,7 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);

View file

@ -1,12 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LanceleafFeature extends ScatterFeature {
public LanceleafFeature() {
super(7);
@ -22,7 +22,7 @@ public class LanceleafFeature extends ScatterFeature {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 5;

View file

@ -1,8 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -10,9 +7,12 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import java.util.function.Function;
public class MengerSpongeFeature extends UnderwaterPlantScatter {
private static final Function<BlockState, Boolean> REPLACE;
public MengerSpongeFeature(int radius) {
super(radius);
}
@ -21,7 +21,7 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.MENGER_SPONGE_WET);
if (random.nextBoolean()) {
for (Direction dir: BlocksHelper.DIRECTIONS) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos pos = blockPos.relative(dir);
if (REPLACE.apply(world.getBlockState(pos))) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.MENGER_SPONGE_WET);
@ -29,7 +29,7 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter {
}
}
}
static {
REPLACE = (state) -> {
if (state.is(EndBlocks.END_LOTUS_STEM)) {

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.blocks.NeonCactusPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class NeonCactusFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -22,7 +21,7 @@ public class NeonCactusFeature extends DefaultFeature {
if (!ground.is(EndBlocks.ENDSTONE_DUST) && !ground.is(EndBlocks.END_MOSS)) {
return false;
}
NeonCactusPlantBlock cactus = ((NeonCactusPlantBlock) EndBlocks.NEON_CACTUS);
cactus.growPlant(world, pos, random);

View file

@ -1,11 +1,8 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -13,6 +10,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public abstract class ScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
@ -22,7 +21,7 @@ public abstract class ScatterFeature extends DefaultFeature {
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@ -33,7 +32,8 @@ public abstract class ScatterFeature extends DefaultFeature {
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
if (pos.getY() < 5) {
return false;
} else if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
}
else if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
return false;
}
return true;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -9,7 +7,6 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -18,6 +15,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class SilkMothNestFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -11,9 +9,11 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.util.BlocksHelper;
import java.util.Random;
public class SingleInvertedScatterFeature extends InvertedScatterFeature {
private final Block block;
public SingleInvertedScatterFeature(Block block, int radius) {
super(radius);
this.block = block;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
@ -11,39 +9,41 @@ import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import java.util.Random;
public class SinglePlantFeature extends ScatterFeature {
private final Block plant;
private final boolean rawHeightmap;
private final int chance;
public SinglePlantFeature(Block plant, int radius) {
this(plant, radius, true, 1);
}
public SinglePlantFeature(Block plant, int radius, int chance) {
this(plant, radius, true, chance);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap) {
this(plant, radius, rawHeightmap, 1);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap, int chance) {
super(radius);
this.plant = plant;
this.rawHeightmap = rawHeightmap;
this.chance = chance;
}
protected int getChance() {
return chance;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -9,11 +7,13 @@ import net.minecraft.world.level.WorldGenLevel;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import java.util.Random;
public abstract class SkyScatterFeature extends ScatterFeature {
public SkyScatterFeature(int radius) {
super(radius);
}
@Override
protected int getChance() {
return 10;
@ -24,29 +24,29 @@ public abstract class SkyScatterFeature extends ScatterFeature {
if (!world.isEmptyBlock(blockPos)) {
return false;
}
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (!world.isEmptyBlock(blockPos.relative(dir))) {
return false;
}
}
int maxD = getYOffset() + 2;
int maxV = getYOffset() - 2;
return BlocksHelper.upRay(world, blockPos, maxD) > maxV && BlocksHelper.downRay(world, blockPos, maxD) > maxV;
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return true;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return new BlockPos(pos.getX(), MHelper.randRange(32, 192, world.getRandom()), pos.getZ());
}
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
pos.setY(pos.getY() + MHelper.randRange(-getYOffset(), getYOffset(), world.getRandom()));
return true;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
@ -9,14 +7,16 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.bclib.util.BlocksHelper;
import java.util.Random;
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
private final Block plant;
public UnderwaterPlantFeature(Block plant, int radius) {
super(radius);
this.plant = plant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return super.canSpawn(world, blockPos) && plant.canSurvive(plant.defaultBlockState(), world, blockPos);

View file

@ -1,19 +1,19 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import java.util.Random;
public abstract class UnderwaterPlantScatter extends ScatterFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
public UnderwaterPlantScatter(int radius) {
super(radius);
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
POS.setX(pos.getX());
@ -21,32 +21,32 @@ public abstract class UnderwaterPlantScatter extends ScatterFeature {
POS.setY(0);
return getGround(world, POS).immutable();
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.getBlockState(blockPos).is(Blocks.WATER);
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return world.getBlockState(pos).is(Blocks.WATER);
}
@Override
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
return getGround(world, pos).getY() < 128;
}
@Override
protected int getYOffset() {
return -5;
}
@Override
protected int getChance() {
return 5;
}
private BlockPos getGround(WorldGenLevel world, MutableBlockPos pos) {
while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) {
pos.setY(pos.getY() + 1);

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
@ -11,11 +9,13 @@ import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.util.BlocksHelper;
import java.util.Random;
public class VineFeature extends InvertedScatterFeature {
private final Block vineBlock;
private final int maxLength;
private final boolean vine;
public VineFeature(Block vineBlock, int maxLength) {
super(6);
this.vineBlock = vineBlock;
@ -43,7 +43,7 @@ public class VineFeature extends InvertedScatterFeature {
BlocksHelper.setWithoutUpdate(world, blockPos.below(h), bottom);
}
}
private boolean canPlaceBlock(BlockState state, WorldGenLevel world, BlockPos blockPos) {
if (vine) {
return ((BaseVineBlock) vineBlock).canGenerate(state, world, blockPos);
@ -52,17 +52,17 @@ public class VineFeature extends InvertedScatterFeature {
return vineBlock.canSurvive(state, world, blockPos);
}
}
private BlockState getTopState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
}
private BlockState getMiggleState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
}
private BlockState getBottomState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -12,9 +10,11 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.blocks.BaseWallPlantBlock;
import ru.bclib.util.BlocksHelper;
import java.util.Random;
public class WallPlantFeature extends WallScatterFeature {
private final Block block;
public WallPlantFeature(Block block, int radius) {
super(radius);
this.block = block;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
@ -9,6 +7,8 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import java.util.Random;
public class WallPlantOnLogFeature extends WallPlantFeature {
public WallPlantOnLogFeature(Block block, int radius) {
super(block, radius);

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -14,6 +11,8 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public abstract class WallScatterFeature extends DefaultFeature {
private static final Direction[] DIR = BlocksHelper.makeHorizontal();
private final int radius;

View file

@ -1,15 +1,11 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -25,6 +21,9 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
import java.util.function.Function;
public class BushFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private final Block leaves;
@ -62,7 +61,8 @@ public class BushFeature extends DefaultFeature {
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
}
else {
return AIR;
}
}
@ -76,7 +76,8 @@ public class BushFeature extends DefaultFeature {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}
}

View file

@ -1,8 +1,5 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -10,7 +7,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -26,6 +22,9 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
import java.util.function.Function;
public class BushWithOuterFeature extends DefaultFeature {
private static final Direction[] DIRECTIONS = Direction.values();
private static final Function<BlockState, Boolean> REPLACE;
@ -66,7 +65,8 @@ public class BushWithOuterFeature extends DefaultFeature {
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
}
else {
return AIR;
}
}
@ -91,7 +91,8 @@ public class BushWithOuterFeature extends DefaultFeature {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}
}

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -18,6 +15,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LargeAmaranitaFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -18,6 +15,8 @@ import ru.betterend.blocks.EndBlockProperties.LumecornShape;
import ru.betterend.blocks.LumecornBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class Lumecorn extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -54,7 +53,8 @@ public class Lumecorn extends DefaultFeature {
if (random.nextBoolean()) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),

View file

@ -1,18 +1,12 @@
package ru.betterend.world.features.bushes;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -32,6 +26,10 @@ import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class TenaneaBushFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Direction[] DIRECTIONS = Direction.values();
@ -78,7 +76,8 @@ public class TenaneaBushFeature extends DefaultFeature {
}
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
}
else {
return AIR;
}
}
@ -112,7 +111,8 @@ public class TenaneaBushFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
}
else {
break;
}
}

View file

@ -1,12 +1,8 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -19,6 +15,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BigAuroraCrystalFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.FluidState;
@ -20,6 +17,8 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlockFixer;
import java.util.Random;
public class DesertLakeFeature extends DefaultFeature {
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);

View file

@ -1,14 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -23,6 +19,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class FallenPillarFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -21,6 +17,9 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
import java.util.List;
import java.util.Random;
public class FloatingSpireFeature extends SpireFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -58,7 +57,8 @@ public class FloatingSpireFeature extends SpireFeature {
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
}

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.function.Function;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -41,6 +37,9 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.util.BlockFixer;
import java.util.Random;
import java.util.function.Function;
public class GeyserFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE1;
protected static final Function<BlockState, Boolean> REPLACE2;

View file

@ -1,15 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.sdf.SDF;
@ -21,6 +15,10 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class IceStarFeature extends DefaultFeature {
private final float minSize;
private final float maxSize;
@ -53,7 +51,8 @@ public class IceStarFeature extends DefaultFeature {
if (angle > 0.01F && angle < 3.14F) {
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.YP, point));
rotated = new SDFRotation().setRotation(axis, angle).setSource(spike);
} else if (angle > 1) {
}
else if (angle > 1) {
rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(spike);
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
@ -83,9 +82,11 @@ public class IceStarFeature extends DefaultFeature {
+ random.nextFloat() * randScale;
if (distance < ancientRadius) {
return ancient;
} else if (distance < denseRadius) {
}
else if (distance < denseRadius) {
return dense;
} else if (distance < iceRadius) {
}
else if (distance < iceRadius) {
return ice;
}
return info.getState();

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -20,6 +17,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class ObsidianBoulderFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.sdf.SDF;
@ -17,6 +14,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
public class OreLayerFeature extends DefaultFeature {
private static final SDFSphere SPHERE;
private static final SDFCoordModify NOISE;

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
import ru.bclib.util.BlocksHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public class SingleBlockFeature extends DefaultFeature {
private final Block block;

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -16,6 +13,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class SmaragdantCrystalFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,11 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -29,6 +24,10 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class SpireFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE;
@ -63,7 +62,8 @@ public class SpireFeature extends DefaultFeature {
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
}

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
@ -9,7 +7,6 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -17,6 +14,8 @@ import ru.bclib.blocks.StalactiteBlock;
import ru.bclib.util.BlocksHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public class StalactiteFeature extends DefaultFeature {
private final boolean ceiling;
private final Block[] ground;

View file

@ -1,14 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.blocks.BlockProperties;
@ -18,6 +15,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class SulphurHillFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -80,7 +79,8 @@ public class SulphurHillFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, rock);
mut.move(Direction.DOWN);
}
} else if (d < r1 * r1) {
}
else if (d < r1 * r1) {
BlocksHelper.setWithoutUpdate(world, mut, brimstone);
mut.move(Direction.DOWN);
state = world.getBlockState(mut);

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -12,7 +8,6 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -27,6 +22,9 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlockFixer;
import java.util.Random;
import java.util.Set;
public class SulphuricCaveFeature extends DefaultFeature {
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
@ -104,14 +102,16 @@ public class SulphuricCaveFeature extends DefaultFeature {
if (isReplaceable(state)) {
BlocksHelper.setWithoutUpdate(world, mut, y < waterLevel ? WATER : CAVE_AIR);
}
} else if (dist < r2 * r2) {
}
else if (dist < r2 * r2) {
state = world.getBlockState(mut);
if (state.is(TagAPI.GEN_TERRAIN) || state.is(Blocks.AIR)) {
double v = noise.eval(x * 0.1, y * 0.1, z * 0.1)
+ noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5;
if (v > 0.4) {
brimstone.add(mut.immutable());
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, mut, rock);
}
}

View file

@ -71,7 +71,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
brimstone.add(POS.below(2));
}
}
} else {
}
else {
if (!isAbsoluteBorder(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
world.getLiquidTicks().scheduleTick(POS, Fluids.WATER, 0);
@ -82,14 +83,16 @@ public class SulphuricLakeFeature extends DefaultFeature {
brimstone.add(POS.below(3));
}
}
} else {
}
else {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
}
}
}
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
@ -117,7 +120,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
}
}
} else if (dist < r2) {
}
else if (dist < r2) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).is(TagAPI.GEN_TERRAIN)) {
brimstone.add(POS.immutable());

View file

@ -1,18 +1,12 @@
package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
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.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -22,6 +16,10 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.util.BlockFixer;
import ru.betterend.world.biome.cave.EndCaveBiome;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
public class CaveChunkPopulatorFeature extends DefaultFeature {
private Supplier<EndCaveBiome> supplier;
@ -50,7 +48,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions,
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
MutableBlockPos mut3 = new MutableBlockPos();
@ -108,7 +106,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random,
BlockState surfaceBlock) {
BlockState surfaceBlock) {
float density = biome.getFloorDensity();
floorPositions.forEach((pos) -> {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);

View file

@ -117,14 +117,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
protected void placeWalls(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> positions, Random random) {
Set<BlockPos> placed = Sets.newHashSet();
positions.forEach(pos -> {
if (random.nextInt(4) == 0 && hasOpenSide(pos, positions)) {
BlockState wallBlock = biome.getWall(pos);
if (wallBlock != null) {
for (Vec3i offset: SPHERE) {
for (Vec3i offset : SPHERE) {
BlockPos wallPos = pos.offset(offset);
if (!positions.contains(wallPos) && !placed.contains(wallPos) && world.getBlockState(wallPos).is(TagAPI.GEN_TERRAIN)) {
wallBlock = biome.getWall(wallPos);
@ -136,9 +136,9 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
private boolean hasOpenSide(BlockPos pos, Set<BlockPos> positions) {
for (Direction dir: BlocksHelper.DIRECTIONS) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (!positions.contains(pos.relative(dir))) {
return true;
}
@ -225,7 +225,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
protected boolean biomeMissingCaves(WorldGenLevel world, BlockPos pos) {
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
@ -239,7 +239,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
static {
List<Vec3i> prePos = Lists.newArrayList();
int radius = 5;
@ -256,6 +256,6 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
}
}
SPHERE = prePos.toArray(new Vec3i[] {});
SPHERE = prePos.toArray(new Vec3i[]{});
}
}

View file

@ -1,11 +1,6 @@
package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
@ -16,21 +11,25 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
import java.util.Set;
import java.util.stream.IntStream;
public class RoundCaveFeature extends EndCaveFeature {
@Override
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
int x1 = center.getX() - radius - 5;
int z1 = center.getZ() - radius - 5;
int x2 = center.getX() + radius + 5;
int z2 = center.getZ() + radius + 5;
int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
int dx = x2 - x1 + 1;
int dz = z2 - z1 + 1;
int count = dx * dz;
@ -54,12 +53,12 @@ public class RoundCaveFeature extends EndCaveFeature {
state = world.getBlockState(bpos);
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos);
}
bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() - 1);
@ -70,10 +69,10 @@ public class RoundCaveFeature extends EndCaveFeature {
}
});
blocks.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return blocks;
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()

View file

@ -35,24 +35,24 @@ public class TunelCaveFeature extends EndCaveFeature {
if ((long) cx * (long) cx + (long) cz + (long) cz < 256) {
return Sets.newHashSet();
}
int x1 = cx << 4;
int z1 = cz << 4;
int x2 = x1 + 16;
int z2 = z1 + 16;
Random rand = new Random(world.getSeed());
OpenSimplexNoise noiseH = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseV = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseD = new OpenSimplexNoise(rand.nextInt());
Set<BlockPos> positions = Sets.newConcurrentHashSet();
float a = hasCaves(world, new BlockPos(x1, 0, z1)) ? 1F : 0F;
float b = hasCaves(world, new BlockPos(x2, 0, z1)) ? 1F : 0F;
float c = hasCaves(world, new BlockPos(x1, 0, z2)) ? 1F : 0F;
float d = hasCaves(world, new BlockPos(x2, 0, z2)) ? 1F : 0F;
ChunkAccess chunk = world.getChunk(cx, cz);
IntStream.range(0, 256).parallel().forEach(index -> {
MutableBlockPos pos = new MutableBlockPos();
@ -84,17 +84,17 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
positions.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return positions;
}
private boolean noWaterNear(WorldGenLevel world, BlockPos pos) {
BlockPos above1 = pos.above();
BlockPos above2 = pos.above(2);
if (!world.getFluidState(above1).isEmpty() || !world.getFluidState(above2).isEmpty()) {
return false;
}
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (!world.getFluidState(above1.relative(dir)).isEmpty()) {
return false;
}
@ -104,7 +104,7 @@ public class TunelCaveFeature extends EndCaveFeature {
}
return true;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -117,12 +117,12 @@ public class TunelCaveFeature extends EndCaveFeature {
if (biomeMissingCaves(world, pos)) {
return false;
}
Set<BlockPos> caveBlocks = generate(world, pos, random);
if (caveBlocks.isEmpty()) {
return false;
}
Map<EndCaveBiome, Set<BlockPos>> floorSets = Maps.newHashMap();
Map<EndCaveBiome, Set<BlockPos>> ceilSets = Maps.newHashMap();
MutableBlockPos mut = new MutableBlockPos();
@ -157,11 +157,11 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
caveBlocks.removeAll(remove);
if (caveBlocks.isEmpty()) {
return true;
}
floorSets.forEach((biome, floorPositions) -> {
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
@ -180,7 +180,7 @@ public class TunelCaveFeature extends EndCaveFeature {
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
return null;
}
@Override
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
float density = biome.getFloorDensity() * 0.2F;
@ -213,14 +213,14 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
}
protected boolean hasCaves(WorldGenLevel world, BlockPos pos) {
return hasCavesInBiome(world, pos.offset(-8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(-8, 0, 8)) &&
hasCavesInBiome(world, pos.offset(8, 0, 8));
}
protected boolean hasCavesInBiome(WorldGenLevel world, BlockPos pos) {
Biome biome = world.getBiome(pos);
BCLBiome endBiome = BiomeAPI.getFromBiome(biome);

View file

@ -1,19 +1,13 @@
package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -33,6 +27,10 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class DragonTreeFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;

View file

@ -1,11 +1,6 @@
package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -14,7 +9,6 @@ import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -28,6 +22,10 @@ import ru.bclib.util.SplineHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class GiganticAmaranitaFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;
@ -130,7 +128,8 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
} else if (radius < 4) {
}
else if (radius < 4) {
pos = pos.offset(-1, 0, -1);
for (int i = -2; i < 2; i++) {
mut.set(pos).move(Direction.NORTH, 2).move(Direction.WEST, i);
@ -201,7 +200,8 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
} else {
}
else {
for (int i = -2; i < 3; i++) {
mut.set(pos).move(Direction.NORTH, 3).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
@ -316,7 +316,8 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
&& world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
} else {
}
else {
if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2)
&& world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);

View file

@ -1,18 +1,11 @@
package ru.betterend.world.features.trees;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.phys.AABB;
@ -31,6 +24,11 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.blocks.HelixTreeLeavesBlock;
import ru.betterend.registry.EndBlocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class HelixTreeFeature extends DefaultFeature {
private static final Function<PosInfo, BlockState> POST;
@ -126,7 +124,8 @@ public class HelixTreeFeature extends DefaultFeature {
if (ax > az) {
start.set(start.x(), start.y(), start.z() + az > 0 ? 1 : -1);
end.set(end.x(), end.y(), end.z() + az > 0 ? 1 : -1);
} else {
}
else {
start.set(start.x() + ax > 0 ? 1 : -1, start.y(), start.z());
end.set(end.x() + ax > 0 ? 1 : -1, end.y(), end.z());
}
@ -153,7 +152,7 @@ public class HelixTreeFeature extends DefaultFeature {
}
private void fillLine(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos,
int offset) {
int offset) {
float dx = end.x() - start.x();
float dy = end.y() - start.y();
float dz = end.z() - start.z();

View file

@ -1,17 +1,11 @@
package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -29,6 +23,10 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.blocks.JellyshroomCapBlock;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class JellyshroomFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final List<Vector3f> ROOT;
@ -67,7 +65,8 @@ public class JellyshroomFeature extends DefaultFeature {
&& EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) {
return EndBlocks.JELLYSHROOM.log.defaultBlockState();
}
} else if (info.getState().is(EndBlocks.JELLYSHROOM_CAP_PURPLE)) {
}
else if (info.getState().is(EndBlocks.JELLYSHROOM_CAP_PURPLE)) {
float dx = info.getPos().getX() - pos.getX() - last.x();
float dz = info.getPos().getZ() - pos.getZ() - last.z();
float distance = MHelper.length(dx, dz) / membraneRadius * 7F;

View file

@ -1,18 +1,12 @@
package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -30,6 +24,10 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class LacugroveFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;
@ -99,7 +97,8 @@ public class LacugroveFeature extends DefaultFeature {
|| state.is(TagAPI.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, mut,
y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
} else {
}
else {
break;
}
}

View file

@ -15,7 +15,11 @@ import ru.bclib.api.TagAPI;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.sdf.SDF;
import ru.bclib.sdf.operator.*;
import ru.bclib.sdf.operator.SDFDisplacement;
import ru.bclib.sdf.operator.SDFScale;
import ru.bclib.sdf.operator.SDFScale3D;
import ru.bclib.sdf.operator.SDFSubtraction;
import ru.bclib.sdf.operator.SDFTranslate;
import ru.bclib.sdf.primitive.SDFSphere;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
@ -68,7 +72,7 @@ public class LucerniaFeature extends DefaultFeature {
}
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise,
boolean natural) {
boolean natural) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
@ -160,7 +164,8 @@ public class LucerniaFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
}
else {
break;
}
}

View file

@ -10,7 +10,15 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf
import net.minecraft.world.level.material.Material;
import ru.bclib.api.TagAPI;
import ru.bclib.sdf.SDF;
import ru.bclib.sdf.operator.*;
import ru.bclib.sdf.operator.SDFBinary;
import ru.bclib.sdf.operator.SDFCoordModify;
import ru.bclib.sdf.operator.SDFFlatWave;
import ru.bclib.sdf.operator.SDFScale;
import ru.bclib.sdf.operator.SDFScale3D;
import ru.bclib.sdf.operator.SDFSmoothUnion;
import ru.bclib.sdf.operator.SDFSubtraction;
import ru.bclib.sdf.operator.SDFTranslate;
import ru.bclib.sdf.operator.SDFUnion;
import ru.bclib.sdf.primitive.SDFCappedCone;
import ru.bclib.sdf.primitive.SDFPrimitive;
import ru.bclib.sdf.primitive.SDFSphere;

View file

@ -65,7 +65,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
}
private void branch(float x, float y, float z, float size, float angle, Random random, int depth,
WorldGenLevel world, BlockPos pos) {
WorldGenLevel world, BlockPos pos) {
if (depth == 0)
return;

View file

@ -15,7 +15,11 @@ import ru.bclib.api.TagAPI;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.sdf.SDF;
import ru.bclib.sdf.operator.*;
import ru.bclib.sdf.operator.SDFDisplacement;
import ru.bclib.sdf.operator.SDFScale;
import ru.bclib.sdf.operator.SDFScale3D;
import ru.bclib.sdf.operator.SDFSubtraction;
import ru.bclib.sdf.operator.SDFTranslate;
import ru.bclib.sdf.primitive.SDFSphere;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
@ -156,7 +160,8 @@ public class TenaneaFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
}
else {
break;
}
}

View file

@ -13,7 +13,13 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf
import net.minecraft.world.level.material.Material;
import ru.bclib.api.TagAPI;
import ru.bclib.sdf.SDF;
import ru.bclib.sdf.operator.*;
import ru.bclib.sdf.operator.SDFFlatWave;
import ru.bclib.sdf.operator.SDFScale;
import ru.bclib.sdf.operator.SDFScale3D;
import ru.bclib.sdf.operator.SDFSmoothUnion;
import ru.bclib.sdf.operator.SDFSubtraction;
import ru.bclib.sdf.operator.SDFTranslate;
import ru.bclib.sdf.operator.SDFUnion;
import ru.bclib.sdf.primitive.SDFSphere;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
@ -106,7 +112,8 @@ public class UmbrellaTreeFeature extends DefaultFeature {
if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp())
&& EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) {
return EndBlocks.UMBRELLA_TREE.log.defaultBlockState();
} else if (info.getState().equals(membrane)) {
}
else if (info.getState().equals(membrane)) {
Center min = centers.get(0);
double d = Double.MAX_VALUE;
BlockPos bpos = info.getPos();

View file

@ -1,11 +1,8 @@
package ru.betterend.world.generator;
import java.util.List;
import com.google.common.collect.Lists;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryLookupCodec;
import net.minecraft.world.level.biome.Biome;
@ -24,6 +21,8 @@ import ru.betterend.registry.EndTags;
import ru.betterend.util.FeaturesHelper;
import ru.betterend.world.biome.EndBiome;
import java.util.List;
public class BetterEndBiomeSource extends BiomeSource {
public static final Codec<BetterEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
@ -43,14 +42,14 @@ public class BetterEndBiomeSource extends BiomeSource {
public BetterEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeLand(), EndBiomes.LAND_BIOMES);
this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeVoid(), EndBiomes.VOID_BIOMES);
this.centerBiome = biomeRegistry.getOrThrow(Biomes.THE_END);
this.barrens = biomeRegistry.getOrThrow(Biomes.END_BARRENS);
this.biomeRegistry = biomeRegistry;
this.seed = seed;
WorldgenRandom chunkRandom = new WorldgenRandom(seed);
chunkRandom.consumeCount(17292);
this.noise = new SimplexNoise(chunkRandom);
@ -59,7 +58,7 @@ public class BetterEndBiomeSource extends BiomeSource {
EndTags.addTerrainTags(biomeRegistry);
FeaturesHelper.addFeatures(biomeRegistry);
}
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
List<Biome> list = Lists.newArrayList();
biomeRegistry.forEach((biome) -> {
@ -76,7 +75,7 @@ public class BetterEndBiomeSource extends BiomeSource {
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
long dist = i + j;
if (hasVoid) {
if (dist <= 65536L) return this.centerBiome;
@ -87,12 +86,12 @@ public class BetterEndBiomeSource extends BiomeSource {
return this.centerBiome;
}
}
if (biomeX == 0 && biomeZ == 0) {
mapLand.clearCache();
mapVoid.clearCache();
}
BCLBiome endBiome = null;
if (GeneratorOptions.useNewGenerator()) {
if (TerrainGenerator.isLand(biomeX, biomeZ)) {
@ -107,22 +106,22 @@ public class BetterEndBiomeSource extends BiomeSource {
}
else {
float height = TheEndBiomeSource.getHeightValue(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1) + (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5;
if (height > -20F && height < -5F) {
return barrens;
}
endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2);
}
return BiomeAPI.getActualBiome(endBiome);
}
public Biome getLandBiome(int biomeX, int biomeY, int biomeZ) {
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
long i = (long) biomeX * (long) biomeX;
long j = (long) biomeZ * (long) biomeZ;
long dist = i + j;
if (hasVoid) {
if (dist <= 65536L) return this.centerBiome;

View file

@ -30,7 +30,7 @@ public class GeneratorOptions {
private static long islandDistBlock;
private static int islandDistChunk;
private static boolean directSpikeHeight;
public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
biomeSizeVoid = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeVoid", 256);
@ -51,9 +51,9 @@ public class GeneratorOptions {
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30, false);
changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false);
spawn = new BlockPos(
Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0)
Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65),
Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0)
);
replacePortal = Configs.GENERATOR_CONFIG.getBoolean("portal", "customEndPortal", true);
replacePillars = Configs.GENERATOR_CONFIG.getBoolean("spikes", "customObsidianSpikes", true);
@ -65,11 +65,11 @@ public class GeneratorOptions {
public static int getBiomeSizeLand() {
return Mth.clamp(biomeSizeLand, 1, 8192);
}
public static int getBiomeSizeVoid() {
return Mth.clamp(biomeSizeVoid, 1, 8192);
}
public static int getBiomeSizeCaves() {
return Mth.clamp(biomeSizeCaves, 1, 8192);
}
@ -77,15 +77,15 @@ public class GeneratorOptions {
public static boolean hasPortal() {
return hasPortal;
}
public static boolean hasPillars() {
return hasPillars;
}
public static boolean hasDragonFights() {
return hasDragonFights;
}
public static boolean swapOverworldToEnd() {
return swapOverworldToEnd;
}
@ -97,23 +97,23 @@ public class GeneratorOptions {
public static boolean removeChorusFromVanillaBiomes() {
return removeChorusFromVanillaBiomes;
}
public static boolean noRingVoid() {
return noRingVoid;
}
public static boolean useNewGenerator() {
return newGenerator;
}
public static boolean hasCentralIsland() {
return generateCentralIsland;
}
public static boolean generateObsidianPlatform() {
return generateObsidianPlatform;
}
public static int getEndCityFailChance() {
return endCityFailChance;
}
@ -133,11 +133,11 @@ public class GeneratorOptions {
public static void setPortalPos(BlockPos portal) {
GeneratorOptions.portal = portal;
}
public static boolean replacePortal() {
return replacePortal;
}
public static boolean replacePillars() {
return replacePillars;
}
@ -149,11 +149,11 @@ public class GeneratorOptions {
public static int getIslandDistChunk() {
return islandDistChunk;
}
public static void setDirectSpikeHeight() {
directSpikeHeight = true;
}
public static boolean isDirectSpikeHeight() {
boolean height = directSpikeHeight;
directSpikeHeight = false;

View file

@ -1,12 +1,6 @@
package ru.betterend.world.generator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.core.BlockPos;
import ru.bclib.sdf.SDF;
import ru.bclib.sdf.operator.SDFRadialNoiseMap;
@ -17,11 +11,16 @@ import ru.bclib.sdf.primitive.SDFCappedCone;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class IslandLayer {
private static final Random RANDOM = new Random();
private final SDFRadialNoiseMap noise;
private final SDF island;
private final List<BlockPos> positions = new ArrayList<BlockPos>(9);
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
private final OpenSimplexNoise density;
@ -29,33 +28,33 @@ public class IslandLayer {
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
private final LayerOptions options;
public IslandLayer(int seed, LayerOptions options) {
this.density = new OpenSimplexNoise(seed);
this.options = options;
this.seed = seed;
SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F);
SDF cone2 = makeCone(0.4F, 0.5F, 0.1F, -0.1F);
SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F);
SDF cone4 = makeCone(0.45F, 0, 0.02F, 0.03F);
SDF coneBottom = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2);
SDF coneTop = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4);
noise = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSeed(seed).setRadius(0.5F).setIntensity(0.2F).setSource(coneTop);
island = new SDFSmoothUnion().setRadius(0.01F).setSourceA(noise).setSourceB(coneBottom);
}
private int getSeed(int x, int z) {
int h = seed + x * 374761393 + z * 668265263;
h = (h ^ (h >> 13)) * 1274126177;
return h ^ (h >> 16);
}
public void updatePositions(double x, double z) {
int ix = MHelper.floor(x / options.distance);
int iz = MHelper.floor(z / options.distance);
if (lastX != ix || lastZ != iz) {
lastX = ix;
lastZ = iz;
@ -78,7 +77,7 @@ public class IslandLayer {
}
}
}
if (GeneratorOptions.hasCentralIsland() && Math.abs(ix) < GeneratorOptions.getIslandDistChunk() && Math.abs(iz) < GeneratorOptions.getIslandDistChunk()) {
int count = positions.size();
for (int n = 0; n < count; n++) {
@ -95,7 +94,7 @@ public class IslandLayer {
}
}
}
private SDF getIsland(BlockPos pos) {
SDF island = islands.get(pos);
if (island == null) {
@ -111,40 +110,40 @@ public class IslandLayer {
noise.setOffset(pos.getX(), pos.getZ());
return island;
}
private float getRelativeDistance(SDF sdf, BlockPos center, double px, double py, double pz) {
float x = (float) (px - center.getX()) / options.scale;
float y = (float) (py - center.getY()) / options.scale;
float z = (float) (pz - center.getZ()) / options.scale;
return sdf.getDistance(x, y, z);
}
private float calculateSDF(double x, double y, double z) {
float distance = 10;
for (BlockPos pos: positions) {
for (BlockPos pos : positions) {
SDF island = getIsland(pos);
float dist = getRelativeDistance(island, pos, x, y, z);
distance = MHelper.min(distance, dist);
}
return distance;
}
public float getDensity(double x, double y, double z) {
return -calculateSDF(x, y, z);
}
public float getDensity(double x, double y, double z, float height) {
noise.setIntensity(height);
noise.setRadius(0.5F / (1 + height));
return -calculateSDF(x, y, z);
}
public void clearCache() {
if (islands.size() > 128) {
islands.clear();
}
}
private static SDF makeCone(float radiusBottom, float radiusTop, float height, float minY) {
float hh = height * 0.5F;
SDF sdf = new SDFCappedCone().setHeight(hh).setRadius1(radiusBottom).setRadius2(radiusTop);

View file

@ -13,7 +13,7 @@ public class LayerOptions {
public final int maxY;
public final long centerDist;
public final boolean hasCentralIsland;
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation, boolean hasCentral) {
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
@ -25,23 +25,23 @@ public class LayerOptions {
this.centerDist = Mth.floor(1000 / this.distance);
this.hasCentralIsland = config.getBoolean(name, "hasCentralIsland", hasCentral);
}
private float clampDistance(float value) {
return Mth.clamp(value, 1, 8192);
}
private float clampScale(float value) {
return Mth.clamp(value, 0.1F, 1024);
}
private float clampCoverage(float value) {
return 0.9999F - Mth.clamp(value, 0, 1) * 2;
}
private int clampCenter(int value) {
return Mth.clamp(value, 0, 255);
}
private int clampVariation(int value) {
return Mth.clamp(value, 0, 255);
}

View file

@ -1,25 +1,24 @@
package ru.betterend.world.generator;
import java.awt.Point;
import java.util.List;
import java.util.Random;
import java.util.concurrent.locks.ReentrantLock;
import com.google.common.collect.Lists;
import net.minecraft.util.Mth;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.awt.Point;
import java.util.List;
import java.util.Random;
import java.util.concurrent.locks.ReentrantLock;
public class TerrainGenerator {
private static final ReentrantLock LOCKER = new ReentrantLock();
private static final double SCALE_XZ = 8.0;
private static final double SCALE_Y = 4.0;
private static final float[] COEF;
private static final Point[] OFFS;
private static IslandLayer largeIslands;
private static IslandLayer mediumIslands;
private static IslandLayer smallIslands;
@ -29,7 +28,7 @@ public class TerrainGenerator {
/*public static boolean canGenerate(int x, int z) {
return GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER;
}*/
public static void initNoise(long seed) {
Random random = new Random(seed);
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions);
@ -38,25 +37,25 @@ public class TerrainGenerator {
noise1 = new OpenSimplexNoise(random.nextInt());
noise2 = new OpenSimplexNoise(random.nextInt());
}
public static void fillTerrainDensity(double[] buffer, int x, int z, BiomeSource biomeSource) {
LOCKER.lock();
largeIslands.clearCache();
mediumIslands.clearCache();
smallIslands.clearCache();
double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(x * 0.2, z * 0.2) * 10 + noise1.eval(x * 0.4, z * 0.4) * 5;
double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(x * 0.2, z * 0.2) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5;
double px = (double) x * SCALE_XZ + distortion1;
double pz = (double) z * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
float height = getAverageDepth(biomeSource, x << 1, z << 1) * 0.5F;
for (int y = 0; y < buffer.length; y++) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz, height);
@ -69,10 +68,10 @@ public class TerrainGenerator {
}
buffer[y] = dist;
}
LOCKER.unlock();
}
private static float getAverageDepth(BiomeSource biomeSource, int x, int z) {
if (getBiome(biomeSource, x, z).getDepth() < 0.1F) {
return 0F;
@ -85,34 +84,35 @@ public class TerrainGenerator {
}
return depth;
}
private static Biome getBiome(BiomeSource biomeSource, int x, int z) {
if (biomeSource instanceof BetterEndBiomeSource) {
return ((BetterEndBiomeSource) biomeSource).getLandBiome(x, 0, z);
}
return biomeSource.getNoiseBiome(x, 0, z);
}
/**
* Check if this is land
*
* @param x - biome pos x
* @param z - biome pos z
*/
public static boolean isLand(int x, int z) {
LOCKER.lock();
double px = (x >> 1) + 0.5;
double pz = (z >> 1) + 0.5;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5;
px = px * SCALE_XZ + distortion1;
pz = pz * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
for (int y = 0; y < 32; y++) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz);
@ -128,31 +128,32 @@ public class TerrainGenerator {
return true;
}
}
LOCKER.unlock();
return false;
}
/**
* Get something like height
*
* @param x - block pos x
* @param z - block pos z
*/
public static int getHeight(int x, int z) {
LOCKER.lock();
double px = (double) x / 8.0;
double pz = (double) z / 8.0;
double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5;
double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5;
px = (double) x * SCALE_XZ + distortion1;
pz = (double) z * SCALE_XZ + distortion2;
largeIslands.updatePositions(px, pz);
mediumIslands.updatePositions(px, pz);
smallIslands.updatePositions(px, pz);
for (int y = 32; y >= 0; y--) {
double py = (double) y * SCALE_Y;
float dist = largeIslands.getDensity(px, py, pz);
@ -168,11 +169,11 @@ public class TerrainGenerator {
return Mth.floor(Mth.clamp(y + dist, y, y + 1) * SCALE_Y);
}
}
LOCKER.unlock();
return 0;
}
static {
float sum = 0;
List<Float> coef = Lists.newArrayList();
@ -187,7 +188,7 @@ public class TerrainGenerator {
}
}
}
OFFS = pos.toArray(new Point[] {});
OFFS = pos.toArray(new Point[]{});
COEF = new float[coef.size()];
for (int i = 0; i < COEF.length; i++) {
COEF[i] = coef.get(i) / sum;

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures;
import java.util.Random;
import net.fabricmc.fabric.api.structure.v1.FabricStructureBuilder;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
@ -11,23 +9,25 @@ import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.BetterEnd;
import java.util.Random;
public class EndStructureFeature {
private static final Random RANDOM = new Random(354);
private final StructureFeature<NoneFeatureConfiguration> structure;
private final ConfiguredStructureFeature<?, ?> featureConfigured;
private final GenerationStep.Decoration featureStep;
public EndStructureFeature(String name, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = step;
this.structure = FabricStructureBuilder.create(id, structure)
.step(step)
.defaultConfig(spacing, separation, RANDOM.nextInt(8192))
.register();
.step(step)
.defaultConfig(spacing, separation, RANDOM.nextInt(8192))
.register();
this.featureConfigured = this.structure.configured(NoneFeatureConfiguration.NONE);
BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured);
}

View file

@ -13,7 +13,6 @@ import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
@ -25,7 +24,7 @@ import ru.betterend.world.structures.piece.NBTPiece;
public class EternalPortalStructure extends FeatureBaseStructure {
private static final ResourceLocation STRUCTURE_ID = BetterEnd.makeID("portal/eternal_portal");
private static final StructureTemplate STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID);
@Override
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;
@ -38,12 +37,12 @@ public class EternalPortalStructure extends FeatureBaseStructure {
}
return super.isFeatureChunk(chunkGenerator, biomeSource, worldSeed, chunkRandom, pos, biome, chunkPos, featureConfig, levelHeightAccessor);
}
@Override
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return PortalStructureStart::new;
}
public static class PortalStructureStart extends StructureStart<NoneFeatureConfiguration> {
public PortalStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos pos, int references, long seed) {
super(feature, pos, references, seed);
@ -52,8 +51,8 @@ public class EternalPortalStructure extends FeatureBaseStructure {
@Override
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
int x = chunkPos.getBlockX( MHelper.randRange(4, 12, random));
int z =chunkPos.getBlockZ( MHelper.randRange(4, 12, random));
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
if (y > 4) {
this.pieces.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), true, random));

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.features;
import java.util.Random;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.biome.Biome;
@ -15,13 +13,15 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import java.util.Random;
public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureConfiguration> {
protected static final BlockState AIR = Blocks.AIR.defaultBlockState();
public FeatureBaseStructure() {
super(NoneFeatureConfiguration.CODEC);
}
@Override
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, ChunkPos pos, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig, LevelHeightAccessor levelHeightAccessor) {
return getGenerationHeight(pos, chunkGenerator, levelHeightAccessor) >= 20;
@ -34,10 +34,12 @@ public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureC
int j = 5;
if (blockRotation == Rotation.CLOCKWISE_90) {
i = -5;
} else if (blockRotation == Rotation.CLOCKWISE_180) {
}
else if (blockRotation == Rotation.CLOCKWISE_180) {
i = -5;
j = -5;
} else if (blockRotation == Rotation.COUNTERCLOCKWISE_90) {
}
else if (blockRotation == Rotation.COUNTERCLOCKWISE_90) {
j = -5;
}

View file

@ -1,11 +1,6 @@
package ru.betterend.world.structures.features;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.level.ChunkPos;
@ -15,7 +10,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.sdf.SDF;
@ -27,12 +21,16 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.world.structures.piece.VoxelPiece;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class GiantIceStarStructure extends SDFStructureFeature {
private final float minSize = 20;
private final float maxSize = 35;
private final int minCount = 25;
private final int maxCount = 40;
@Override
protected SDF getSDF(BlockPos pos, Random random) {
float size = MHelper.randRange(minSize, maxSize, random);
@ -41,7 +39,7 @@ public class GiantIceStarStructure extends SDFStructureFeature {
SDF sdf = null;
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW);
spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike);
for (Vector3f point: points) {
for (Vector3f point : points) {
SDF rotated = spike;
point = MHelper.normalize(point);
float angle = MHelper.angle(Vector3f.YP, point);
@ -54,18 +52,18 @@ public class GiantIceStarStructure extends SDFStructureFeature {
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
}
final float ancientRadius = size * 0.7F;
final float denseRadius = size * 0.9F;
final float iceRadius = size < 7 ? size * 5 : size * 1.3F;
final float randScale = size * 0.3F;
final BlockPos center = pos;
final BlockState ice = EndBlocks.EMERALD_ICE.defaultBlockState();
final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.defaultBlockState();
final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.defaultBlockState();
final SDF sdfCopy = sdf;
return sdf.addPostProcess((info) -> {
BlockPos bpos = info.getPos();
float px = bpos.getX() - center.getX();
@ -84,7 +82,7 @@ public class GiantIceStarStructure extends SDFStructureFeature {
return info.getState();
});
}
private List<Vector3f> getFibonacciPoints(int count) {
float max = count - 1;
List<Vector3f> result = new ArrayList<Vector3f>(count);
@ -98,12 +96,12 @@ public class GiantIceStarStructure extends SDFStructureFeature {
}
return result;
}
@Override
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return StarStructureStart::new;
}
public static class StarStructureStart extends StructureStart<NoneFeatureConfiguration> {
public StarStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos pos, int references, long seed) {
super(feature, pos, references, seed);
@ -112,9 +110,11 @@ public class GiantIceStarStructure extends SDFStructureFeature {
@Override
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
int z = chunkPos.getBlockZ( 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);
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.calculateBoundingBox();

View file

@ -1,10 +1,6 @@
package ru.betterend.world.structures.features;
import java.util.List;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import ru.bclib.sdf.SDF;
@ -29,6 +25,9 @@ import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
@Override
protected SDF getSDF(BlockPos center, Random random) {
@ -39,39 +38,39 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3);
SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone);
SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave);
SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone);
innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone);
cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone);
SDF glowCone = new SDFCappedCone().setHeight(3F).setRadius1(2F).setRadius2(12.5F);
SDFPrimitive priGlowCone = (SDFPrimitive) glowCone;
glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone);
glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3);
cones = new SDFUnion().setSourceA(cones).setSourceB(glowCone);
OpenSimplexNoise noise = new OpenSimplexNoise(1234);
cones = new SDFCoordModify().setFunction((pos) -> {
float dist = MHelper.length(pos.x(), pos.z());
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + center.getX(), pos.z() * 0.1 + center.getZ()) * dist * 0.3F - dist * 0.15F;
pos.set(pos.x(), y, pos.z());
}).setSource(cones);
SDFTranslate HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
SDF roots = new SDFSphere().setRadius(4F);
SDFPrimitive primRoots = (SDFPrimitive) roots;
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
SDFFlatWave rotRoots = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
SDFBinary function = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(rotRoots));
cone1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
cone2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
priGlowCone.setBlock(EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE);
primRoots.setBlock(EndBlocks.MOSSY_GLOWSHROOM.bark);
float height = MHelper.randRange(10F, 25F, random);
int count = MHelper.floor(height / 4);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count);
@ -81,11 +80,11 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
});
Vector3f pos = spline.get(spline.size() - 1);
float scale = MHelper.randRange(2F, 3.5F, random);
HEAD_POS.setTranslate(pos.x(), pos.y(), pos.z());
rotRoots.setAngle(random.nextFloat() * MHelper.PI2);
function.setSourceA(sdf);
return new SDFRound().setRadius(1.5F).setSource(new SDFScale()
.setScale(scale)
.setSource(function))
@ -105,17 +104,17 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState().setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState());
return info.getState();
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (info.getState(dir) == AIR) {
info.setBlockPos(info.getPos().relative(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.DOWN));
}

View file

@ -9,7 +9,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.util.MHelper;
@ -20,7 +19,7 @@ public class MegaLakeSmallStructure extends FeatureBaseStructure {
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return SDFStructureStart::new;
}
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
super(feature, chunkPos, references, seed);
@ -28,7 +27,7 @@ public class MegaLakeSmallStructure extends FeatureBaseStructure {
@Override
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
int x = chunkPos.getBlockX( MHelper.randRange(4, 12, random));
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
if (y > 5) {

View file

@ -9,7 +9,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.util.MHelper;
@ -20,7 +19,7 @@ public class MegaLakeStructure extends FeatureBaseStructure {
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return SDFStructureStart::new;
}
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
super(feature, chunkPos, references, seed);

View file

@ -9,7 +9,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.util.MHelper;
@ -20,7 +19,7 @@ public class MountainStructure extends FeatureBaseStructure {
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return SDFStructureStart::new;
}
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
super(feature, chunkPos, references, seed);
@ -29,7 +28,7 @@ public class MountainStructure extends FeatureBaseStructure {
@Override
public void generatePieces(RegistryAccess registryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, NoneFeatureConfiguration featureConfiguration, LevelHeightAccessor levelHeightAccessor) {
int x = chunkPos.getBlockX(MHelper.randRange(4, 12, random));
int z =chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
int z = chunkPos.getBlockZ(MHelper.randRange(4, 12, random));
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
if (y > 5) {
float radius = MHelper.randRange(50, 100, random);

View file

@ -11,7 +11,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.util.MHelper;
@ -20,12 +19,12 @@ import ru.betterend.world.structures.piece.PaintedMountainPiece;
public class PaintedMountainStructure extends FeatureBaseStructure {
private static final BlockState[] VARIANTS;
@Override
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return SDFStructureStart::new;
}
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
super(feature, chunkPos, references, seed);
@ -44,15 +43,15 @@ public class PaintedMountainStructure extends FeatureBaseStructure {
for (int i = 0; i < count; i++) {
slises[i] = VARIANTS[random.nextInt(VARIANTS.length)];
}
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();
}
}
static {
VARIANTS = new BlockState[] {
VARIANTS = new BlockState[]{
Blocks.END_STONE.defaultBlockState(),
EndBlocks.FLAVOLITE.stone.defaultBlockState(),
EndBlocks.VIOLECITE.stone.defaultBlockState(),

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.level.ChunkPos;
@ -11,22 +9,23 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import ru.bclib.sdf.SDF;
import ru.bclib.util.MHelper;
import ru.betterend.world.structures.piece.VoxelPiece;
import java.util.Random;
public abstract class SDFStructureFeature extends FeatureBaseStructure {
protected abstract SDF getSDF(BlockPos pos, Random random);
@Override
public StructureFeature.StructureStartFactory<NoneFeatureConfiguration> getStartFactory() {
return SDFStructureStart::new;
}
public static class SDFStructureStart extends StructureStart<NoneFeatureConfiguration> {
public SDFStructureStart(StructureFeature<NoneFeatureConfiguration> feature, ChunkPos chunkPos, int references, long seed) {
super(feature, chunkPos, references, seed);
@ -39,7 +38,9 @@ public abstract class SDFStructureFeature extends FeatureBaseStructure {
int y = chunkGenerator.getBaseHeight(x, z, Types.WORLD_SURFACE_WG, levelHeightAccessor);
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());
VoxelPiece piece = new VoxelPiece((world) -> {
((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start);
}, random.nextInt());
this.pieces.add(piece);
}

View file

@ -14,6 +14,6 @@ public abstract class BasePiece extends StructurePiece {
super(type, tag);
fromNbt(tag);
}
protected abstract void fromNbt(CompoundTag tag);
}

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.piece;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
@ -13,18 +11,19 @@ import net.minecraft.world.level.WorldGenLevel;
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.bclib.api.TagAPI;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndStructures;
import java.util.Random;
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, null);
this.center = center;
@ -37,7 +36,7 @@ public class CavePiece extends BasePiece {
super(EndStructures.CAVE_PIECE, tag);
makeBoundingBox();
}
@Override
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
int x1 = MHelper.max(this.boundingBox.minX(), blockBox.minX());
@ -46,7 +45,7 @@ public class CavePiece extends BasePiece {
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;
MutableBlockPos pos = new MutableBlockPos();
@ -79,7 +78,7 @@ public class CavePiece extends BasePiece {
}
}
}
return true;
}
@ -95,7 +94,7 @@ public class CavePiece extends BasePiece {
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);

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.piece;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
@ -18,16 +16,17 @@ 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.bclib.api.BiomeAPI;
import ru.bclib.api.TagAPI;
import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndStructures;
import java.util.Random;
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();
@ -92,9 +91,9 @@ public class CrystalMountainPiece extends MountainPiece {
}
}
}
map = chunk.getOrCreateHeightmapUnprimed(Types.WORLD_SURFACE);
// Big crystals
int count = (map.getFirstAvailable(8, 8) - (center.getY() + 24)) / 7;
count = Mth.clamp(count, 0, 8);
@ -112,7 +111,7 @@ public class CrystalMountainPiece extends MountainPiece {
}
}
}
// Small crystals
count = (map.getFirstAvailable(8, 8) - (center.getY() + 24)) / 2;
count = Mth.clamp(count, 4, 8);
@ -130,10 +129,10 @@ public class CrystalMountainPiece extends MountainPiece {
}
}
}
return true;
}
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);

View file

@ -1,10 +1,6 @@
package ru.betterend.world.structures.piece;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -24,7 +20,6 @@ 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.bclib.api.BiomeAPI;
import ru.bclib.api.TagAPI;
@ -34,6 +29,9 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndStructures;
import java.util.Map;
import java.util.Random;
public class LakePiece extends BasePiece {
private static final BlockState ENDSTONE = Blocks.END_STONE.defaultBlockState();
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
@ -44,9 +42,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(), null);
this.center = center;
@ -104,11 +102,11 @@ public class LakePiece extends BasePiece {
int z2 = wz - center.getZ();
float clamp = getHeightClamp(world, 8, wx, wz);
if (clamp < 0.01) continue;
double n = noise.eval(nx, nz) * 1.5 + 1.5;
double x3 = MHelper.sqr(x2 + noise.eval(nx, nz, 100) * 10);
double z3 = MHelper.sqr(z2 + noise.eval(nx, nz, -100) * 10);
for (int y = minY; y <= maxY; y++) {
mut.setY((int) (y + n));
double y2 = MHelper.sqr((y - center.getY()) * aspect);
@ -144,7 +142,7 @@ public class LakePiece extends BasePiece {
fixWater(world, chunk, mut, random, sx, sz);
return true;
}
private void fixWater(WorldGenLevel world, ChunkAccess chunk, MutableBlockPos mut, Random random, int sx, int sz) {
int minY = this.boundingBox.minY();
int maxY = this.boundingBox.maxY();
@ -159,7 +157,7 @@ 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.offset(sx, 0, sz)).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
@ -167,14 +165,14 @@ public class LakePiece extends BasePiece {
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) {
mut.setY(y);
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos wPos = mut.offset(dir.getStepX(), 0, dir.getStepZ());
if (chunk.getBlockState(wPos).isAir()) {
mut.setY(y + 1);
@ -199,7 +197,7 @@ public class LakePiece extends BasePiece {
}
}
}
private void makeEndstonePillar(ChunkAccess chunk, MutableBlockPos mut, BlockState terrain) {
chunk.setBlockState(mut, terrain, false);
mut.setY(mut.getY() - 1);
@ -208,27 +206,27 @@ public class LakePiece extends BasePiece {
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 (!BiomeAPI.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;
@ -250,7 +248,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);

View file

@ -1,10 +1,6 @@
package ru.betterend.world.structures.piece;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
@ -17,11 +13,13 @@ 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.bclib.api.BiomeAPI;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Map;
import java.util.Random;
public abstract class MountainPiece extends BasePiece {
protected Map<Integer, Integer> heightmap = Maps.newHashMap();
protected OpenSimplexNoise noise1;
@ -33,7 +31,7 @@ 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) {
super(type, random.nextInt(), null);
this.center = center;
@ -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 (!BiomeAPI.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
heightmap.put(p, -10);
return -10;
@ -94,19 +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);
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;
@ -127,7 +125,7 @@ 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 minY = MHelper.floor(center.getY() - radius);

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.piece;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag;
@ -15,13 +13,14 @@ 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.bclib.util.MHelper;
import ru.bclib.util.StructureHelper;
import ru.betterend.registry.EndStructures;
import java.util.Random;
public class NBTPiece extends BasePiece {
private ResourceLocation structureID;
private Rotation rotation;
@ -30,7 +29,7 @@ public class NBTPiece extends BasePiece {
private BlockPos pos;
private int erosion;
private boolean cover;
public NBTPiece(ResourceLocation structureID, StructureTemplate structure, BlockPos pos, int erosion, boolean cover, Random random) {
super(EndStructures.NBT_PIECE, random.nextInt(), null);
this.structureID = structureID;
@ -72,8 +71,8 @@ public class NBTPiece extends BasePiece {
@Override
public boolean postProcess(WorldGenLevel world, StructureFeatureManager arg, ChunkGenerator chunkGenerator, Random random, BoundingBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
BoundingBox bounds = BoundingBox.fromCorners(
new Vec3i(blockBox.minX(), this.boundingBox.minY(), blockBox.minZ()),
new Vec3i(blockBox.maxX(), this.boundingBox.maxX(), blockBox.maxZ())
new Vec3i(blockBox.minX(), this.boundingBox.minY(), blockBox.minZ()),
new Vec3i(blockBox.maxX(), this.boundingBox.maxX(), blockBox.maxZ())
);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
structure.placeInWorld(world, pos, pos, placementData, random, 2);
@ -90,7 +89,7 @@ public class NBTPiece extends BasePiece {
}
return true;
}
private void makeBoundingBox() {
this.boundingBox = StructureHelper.getStructureBounds(pos, structure, rotation, mirror);
}

View file

@ -1,7 +1,5 @@
package ru.betterend.world.structures.piece;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.nbt.CompoundTag;
@ -18,12 +16,14 @@ 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.bclib.util.MHelper;
import ru.betterend.registry.EndStructures;
import java.util.Random;
public class PaintedMountainPiece extends MountainPiece {
private 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;
@ -37,7 +37,7 @@ public class PaintedMountainPiece extends MountainPiece {
protected void addAdditionalSaveData(ServerLevel serverLevel, CompoundTag tag) {
super.addAdditionalSaveData(serverLevel, tag);
ListTag slise = new ListTag();
for (BlockState state: slises) {
for (BlockState state : slises) {
slise.add(NbtUtils.writeBlockState(state));
}
tag.put("slises", slise);
@ -77,7 +77,7 @@ public class PaintedMountainPiece extends MountainPiece {
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.getFirstAvailable(x, z));
@ -98,7 +98,7 @@ public class PaintedMountainPiece extends MountainPiece {
}
}
}
return true;
}
}

View file

@ -1,8 +1,5 @@
package ru.betterend.world.structures.piece;
import java.util.Random;
import java.util.function.Consumer;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
@ -11,13 +8,15 @@ import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
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.bclib.world.structures.StructureWorld;
import ru.betterend.registry.EndStructures;
import java.util.Random;
import java.util.function.Consumer;
public class VoxelPiece extends BasePiece {
private StructureWorld world;
public VoxelPiece(Consumer<StructureWorld> function, int id) {
super(EndStructures.VOXEL_PIECE, id, null);
world = new StructureWorld();

View file

@ -1,7 +1,5 @@
package ru.betterend.world.surface;
import java.util.Random;
import net.minecraft.core.Registry;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
@ -11,15 +9,17 @@ import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConf
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
public class SulphuricSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBaseConfiguration> {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(5123);
public SulphuricSurfaceBuilder() {
super(SurfaceBuilderBaseConfiguration.CODEC);
}
@Override
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, int seed, long n, SurfaceBuilderBaseConfiguration surfaceBlocks){
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, int seed, long n, SurfaceBuilderBaseConfiguration surfaceBlocks) {
double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(-0.1, 0.1, MHelper.RANDOM);
if (value < -0.6) {
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, n, SurfaceBuilders.DEFAULT_END_CONFIG);
@ -34,7 +34,7 @@ public class SulphuricSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBaseCo
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, n, SurfaceBuilders.BRIMSTONE_CONFIG);
}
}
public static SulphuricSurfaceBuilder register(String name) {
return Registry.register(Registry.SURFACE_BUILDER, name, new SulphuricSurfaceBuilder());
}

View file

@ -13,17 +13,18 @@ public class SurfaceBuilders {
public static final SurfaceBuilderBaseConfiguration FLAVOLITE_CONFIG = makeSimpleConfig(EndBlocks.FLAVOLITE.stone);
public static final SurfaceBuilderBaseConfiguration BRIMSTONE_CONFIG = makeSimpleConfig(EndBlocks.BRIMSTONE);
public static final SurfaceBuilderBaseConfiguration SULFURIC_ROCK_CONFIG = makeSimpleConfig(EndBlocks.SULPHURIC_ROCK.stone);
public static final SurfaceBuilder<SurfaceBuilderBaseConfiguration> SULPHURIC_SURFACE = register("sulphuric_surface", new SulphuricSurfaceBuilder());
private static SurfaceBuilder<SurfaceBuilderBaseConfiguration> register(String name, SurfaceBuilder<SurfaceBuilderBaseConfiguration> builder) {
return Registry.register(Registry.SURFACE_BUILDER, name, builder);
}
private static SurfaceBuilderBaseConfiguration makeSimpleConfig(Block block) {
BlockState state = block.defaultBlockState();
return new SurfaceBuilderBaseConfiguration(state, state, state);
}
public static void register() {}
public static void register() {
}
}