Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -2,10 +2,10 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -20,15 +20,16 @@ import ru.betterend.util.sdf.operator.SDFTranslate;
|
|||
import ru.betterend.util.sdf.primitive.SDFCappedCone;
|
||||
|
||||
public class BiomeIslandFeature extends DefaultFeature {
|
||||
private static final Mutable CENTER = new Mutable();
|
||||
private static final MutableBlockPos CENTER = new MutableBlockPos();
|
||||
private static final SDF ISLAND;
|
||||
|
||||
private static OpenSimplexNoise simplexNoise = new OpenSimplexNoise(412L);
|
||||
private static BlockState topBlock = Blocks.GRASS_BLOCK.getDefaultState();
|
||||
private static BlockState underBlock = Blocks.DIRT.getDefaultState();
|
||||
private static BlockState topBlock = Blocks.GRASS_BLOCK.defaultBlockState();
|
||||
private static BlockState underBlock = Blocks.DIRT.defaultBlockState();
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
SurfaceConfig surfaceConfig = biome.getGenerationSettings().getSurfaceConfig();
|
||||
BlockState topMaterial = surfaceConfig.getTopMaterial();
|
||||
|
@ -40,14 +41,16 @@ public class BiomeIslandFeature extends DefaultFeature {
|
|||
underBlock = surfaceConfig.getUnderMaterial();
|
||||
simplexNoise = new OpenSimplexNoise(world.getSeed());
|
||||
CENTER.set(pos);
|
||||
ISLAND.fillRecursive(world, pos.down());
|
||||
ISLAND.fillRecursive(world, pos.below());
|
||||
return true;
|
||||
}
|
||||
|
||||
private static SDF createSDFIsland() {
|
||||
SDF sdfCone = new SDFCappedCone().setRadius1(0).setRadius2(6).setHeight(4).setBlock(pos -> {
|
||||
if (pos.getY() > CENTER.getY()) return AIR;
|
||||
if (pos.getY() == CENTER.getY()) return topBlock;
|
||||
if (pos.getY() > CENTER.getY())
|
||||
return AIR;
|
||||
if (pos.getY() == CENTER.getY())
|
||||
return topBlock;
|
||||
return underBlock;
|
||||
});
|
||||
sdfCone = new SDFTranslate().setTranslate(0, -2, 0).setSource(sdfCone);
|
||||
|
@ -55,11 +58,12 @@ public class BiomeIslandFeature extends DefaultFeature {
|
|||
float deltaX = Math.abs(pos.getX());
|
||||
float deltaY = Math.abs(pos.getY());
|
||||
float deltaZ = Math.abs(pos.getZ());
|
||||
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F)) return 0.0f;
|
||||
return (float) simplexNoise.eval(CENTER.getX() + pos.getX(),
|
||||
CENTER.getY() + pos.getY(), CENTER.getZ() + pos.getZ());
|
||||
}).setSource(sdfCone).setReplaceFunction(state -> BlocksHelper.isFluid(state) ||
|
||||
state.getMaterial().isReplaceable());
|
||||
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F))
|
||||
return 0.0f;
|
||||
return (float) simplexNoise.eval(CENTER.getX() + pos.getX(), CENTER.getY() + pos.getY(),
|
||||
CENTER.getZ() + pos.getZ());
|
||||
}).setSource(sdfCone)
|
||||
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
|
||||
return sdfCone;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -11,14 +11,16 @@ import ru.betterend.util.MHelper;
|
|||
|
||||
public class BlueVineFeature extends ScatterFeature {
|
||||
private boolean small;
|
||||
|
||||
|
||||
public BlueVineFeature() {
|
||||
super(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess 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;
|
||||
public boolean canGenerate(StructureWorldAccess 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;
|
||||
small = d > 0.5F;
|
||||
return EndBlocks.BLUE_VINE_SEED.canPlaceAt(AIR, world, blockPos);
|
||||
}
|
||||
|
@ -26,9 +28,9 @@ public class BlueVineFeature extends ScatterFeature {
|
|||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
if (small) {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.getDefaultState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos,
|
||||
EndBlocks.BLUE_VINE_SEED.defaultBlockState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
|
||||
} else {
|
||||
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED);
|
||||
seed.growAdult(world, random, blockPos);
|
||||
}
|
||||
|
|
|
@ -2,21 +2,22 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class CavePlantFeature extends FullHeightScatterFeature {
|
||||
private final Block plant;
|
||||
|
||||
|
||||
public CavePlantFeature(Block plant, int radius) {
|
||||
super(radius);
|
||||
this.plant = plant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return plant.canPlaceAt(world.getBlockState(blockPos), world, blockPos);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -13,17 +13,21 @@ import ru.betterend.util.BlocksHelper;
|
|||
|
||||
public class CavePumpkinFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos) || !world.isAir(pos.down())) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos)
|
||||
|| !world.isAir(pos.below())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int age = random.nextInt(4);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.CAVE_PUMPKIN_SEED.getDefaultState().with(BlockProperties.AGE, age));
|
||||
BlocksHelper.setWithoutUpdate(world, pos,
|
||||
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().with(BlockProperties.AGE, age));
|
||||
if (age > 1) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState().with(BlockProperties.SMALL, age < 3));
|
||||
BlocksHelper.setWithoutUpdate(world, pos.below(),
|
||||
EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, age < 3));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class CharniaFeature extends UnderwaterPlantFeature {
|
||||
public CharniaFeature(Block plant) {
|
||||
super(plant, 6);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 3;
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.Structure.StructureBlockInfo;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
|
@ -12,10 +12,10 @@ import net.minecraft.structure.processor.BlockIgnoreStructureProcessor;
|
|||
import net.minecraft.structure.processor.StructureProcessor;
|
||||
import net.minecraft.structure.processor.StructureProcessorType;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -33,7 +33,8 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
@Override
|
||||
protected Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
if (structure == null) {
|
||||
structure = world.toServerWorld().getStructureManager().getStructureOrBlank(new Identifier("end_city/ship"));
|
||||
structure = world.toServerWorld().getStructureManager()
|
||||
.getStructureOrBlank(new ResourceLocation("end_city/ship"));
|
||||
if (structure == null) {
|
||||
structure = StructureHelper.readStructure(STRUCTURE_PATH);
|
||||
}
|
||||
|
@ -48,12 +49,12 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
if (x * x + z * z < 3600) {
|
||||
return false;
|
||||
}
|
||||
return pos.getY() > 5 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
||||
return pos.getY() > 5 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return BlockRotation.random(random);
|
||||
protected Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return Rotation.random(random);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,48 +73,53 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return TerrainMerge.NONE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
|
||||
center = getGround(world, center);
|
||||
BlockBox bounds = makeBox(center);
|
||||
|
||||
|
||||
if (!canSpawn(world, center, random)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Structure structure = getStructure(world, center, random);
|
||||
BlockRotation rotation = getRotation(world, center, random);
|
||||
Rotation rotation = getRotation(world, center, random);
|
||||
BlockMirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
|
||||
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror);
|
||||
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
||||
|
||||
|
||||
BlockBox structB = structure.calculateBoundingBox(placementData, center);
|
||||
bounds = StructureHelper.intersectBoxes(bounds, structB);
|
||||
|
||||
|
||||
addStructureData(placementData);
|
||||
structure.place(world, center, placementData.setBoundingBox(bounds), random);
|
||||
|
||||
|
||||
StructureHelper.erodeIntense(world, bounds, random);
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ), new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ));
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ),
|
||||
new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addStructureData(StructurePlacementData data) {
|
||||
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER).setIgnoreEntities(true);
|
||||
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER)
|
||||
.setIgnoreEntities(true);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACER = new StructureProcessor() {
|
||||
@Override
|
||||
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlacementData structurePlacementData) {
|
||||
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
|
||||
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
|
||||
StructurePlacementData structurePlacementData) {
|
||||
BlockState state = structureBlockInfo2.state;
|
||||
if (state.isOf(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
|
||||
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
|
||||
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);
|
||||
}
|
||||
return structureBlockInfo2;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -10,33 +10,33 @@ import net.minecraft.world.gen.feature.Feature;
|
|||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public abstract class DefaultFeature extends Feature<DefaultFeatureConfig> {
|
||||
protected static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||
protected static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||
|
||||
protected static final BlockState AIR = Blocks.AIR.defaultBlockState();
|
||||
protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
|
||||
|
||||
public DefaultFeature() {
|
||||
super(DefaultFeatureConfig.CODEC);
|
||||
}
|
||||
|
||||
|
||||
public static int getYOnSurface(StructureWorldAccess world, int x, int z) {
|
||||
return world.getTopY(Type.WORLD_SURFACE, x, z);
|
||||
}
|
||||
|
||||
|
||||
public static int getYOnSurfaceWG(StructureWorldAccess world, int x, int z) {
|
||||
return world.getTopY(Type.WORLD_SURFACE_WG, x, z);
|
||||
}
|
||||
|
||||
|
||||
public static BlockPos getPosOnSurface(StructureWorldAccess world, BlockPos pos) {
|
||||
return world.getTopPosition(Type.WORLD_SURFACE, pos);
|
||||
}
|
||||
|
||||
|
||||
public static BlockPos getPosOnSurfaceWG(StructureWorldAccess world, BlockPos pos) {
|
||||
return world.getTopPosition(Type.WORLD_SURFACE_WG, pos);
|
||||
}
|
||||
|
||||
|
||||
public static BlockPos getPosOnSurfaceRaycast(StructureWorldAccess world, BlockPos pos) {
|
||||
return getPosOnSurfaceRaycast(world, pos, 256);
|
||||
}
|
||||
|
||||
|
||||
public static BlockPos getPosOnSurfaceRaycast(StructureWorldAccess world, BlockPos pos, int dist) {
|
||||
int h = BlocksHelper.downRay(world, pos, dist);
|
||||
return pos.down(h);
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
@ -14,29 +14,30 @@ 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(StructureWorldAccess 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;
|
||||
public boolean canGenerate(StructureWorldAccess 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;
|
||||
plant = d < 0.5F ? largePlant : smallPlant;
|
||||
return plant.canPlaceAt(plant.getDefaultState(), world, blockPos);
|
||||
return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
if (plant instanceof DoublePlantBlock) {
|
||||
int rot = random.nextInt(4);
|
||||
BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.structure.rule.BlockMatchRuleTest;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.gen.CountConfig;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
|
||||
|
@ -26,99 +26,116 @@ public class EndFeature {
|
|||
private Feature<?> feature;
|
||||
private ConfiguredFeature<?, ?> featureConfigured;
|
||||
private GenerationStep.Feature featureStep;
|
||||
|
||||
protected EndFeature() {}
|
||||
|
||||
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Feature featureStep) {
|
||||
|
||||
protected EndFeature() {
|
||||
}
|
||||
|
||||
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature,
|
||||
GenerationStep.Feature featureStep) {
|
||||
this.featureStep = featureStep;
|
||||
this.feature = feature;
|
||||
this.featureConfigured = configuredFeature;
|
||||
}
|
||||
|
||||
public EndFeature(String name, Feature<DefaultFeatureConfig> feature, GenerationStep.Feature featureStep, ConfiguredFeature<?, ?> configuredFeature) {
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
|
||||
public EndFeature(String name, Feature<DefaultFeatureConfig> feature, GenerationStep.Feature featureStep,
|
||||
ConfiguredFeature<?, ?> configuredFeature) {
|
||||
ResourceLocation id = BetterEnd.makeID(name);
|
||||
this.featureStep = featureStep;
|
||||
this.feature = Registry.register(Registry.FEATURE, id, feature);
|
||||
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, configuredFeature);
|
||||
}
|
||||
|
||||
|
||||
public EndFeature(String name, Feature<DefaultFeatureConfig> feature) {
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
ResourceLocation id = BetterEnd.makeID(name);
|
||||
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
|
||||
this.feature = Registry.register(Registry.FEATURE, id, feature);
|
||||
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100))));
|
||||
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature
|
||||
.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100))));
|
||||
}
|
||||
|
||||
|
||||
public EndFeature(String name, Feature<DefaultFeatureConfig> feature, int density) {
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
ResourceLocation id = BetterEnd.makeID(name);
|
||||
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
|
||||
this.feature = Registry.register(Registry.FEATURE, id, feature);
|
||||
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configure(FeatureConfig.DEFAULT).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(density));
|
||||
this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id,
|
||||
feature.configure(FeatureConfig.DEFAULT).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP)
|
||||
.repeatRandomly(density));
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeRawGenFeature(String name, Feature<DefaultFeatureConfig> feature, int chance) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeLakeFeature(String name, Feature<DefaultFeatureConfig> feature, int chance) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance)));
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.LAKES, configured);
|
||||
}
|
||||
|
||||
public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY, int maxY) {
|
||||
|
||||
public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY,
|
||||
int maxY) {
|
||||
EndFeature newFeature = new EndFeature();
|
||||
OreFeatureConfig featureConfig = new OreFeatureConfig(new BlockMatchRuleTest(Blocks.END_STONE), blockOre.getDefaultState(), veinSize);
|
||||
OreFeatureConfig featureConfig = new OreFeatureConfig(new BlockMatchRuleTest(Blocks.END_STONE),
|
||||
blockOre.defaultBlockState(), veinSize);
|
||||
RangeDecoratorConfig rangeDecorator = new RangeDecoratorConfig(offset, minY, maxY);
|
||||
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configure(featureConfig)
|
||||
.decorate(Decorator.RANGE.configure(rangeDecorator))
|
||||
.spreadHorizontally()
|
||||
.repeat(veins);
|
||||
.decorate(Decorator.RANGE.configure(rangeDecorator)).spreadHorizontally().repeat(veins);
|
||||
newFeature.feature = Feature.ORE;
|
||||
newFeature.featureStep = GenerationStep.Feature.UNDERGROUND_ORES;
|
||||
newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name), oreFeature);
|
||||
|
||||
newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name),
|
||||
oreFeature);
|
||||
|
||||
return newFeature;
|
||||
}
|
||||
|
||||
public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY, int count) {
|
||||
|
||||
public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY,
|
||||
int count) {
|
||||
OreLayerFeature layer = new OreLayerFeature(state, radius, minY, maxY);
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeLayerFeature(String name, Block block, float radius, int minY, int maxY, int count) {
|
||||
OreLayerFeature layer = new OreLayerFeature(block.getDefaultState(), radius, minY, maxY);
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
OreLayerFeature layer = new OreLayerFeature(block.defaultBlockState(), radius, minY, maxY);
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
|
||||
}
|
||||
|
||||
public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY, int count) {
|
||||
OreLayerFeature layer = new OreLayerFeature(material.stone.getDefaultState(), radius, minY, maxY);
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
|
||||
public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY,
|
||||
int count) {
|
||||
OreLayerFeature layer = new OreLayerFeature(material.stone.defaultBlockState(), radius, minY, maxY);
|
||||
ConfiguredFeature<?, ?> configured = layer.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.COUNT.configure(new CountConfig(count)));
|
||||
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeChunkFeature(String name, Feature<DefaultFeatureConfig> feature) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(1)));
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.COUNT.configure(new CountConfig(1)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeChansedFeature(String name, Feature<DefaultFeatureConfig> feature, int chance) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.SURFACE_STRUCTURES, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeCountRawFeature(String name, Feature<DefaultFeatureConfig> feature, int chance) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(chance)));
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
|
||||
.decorate(Decorator.COUNT.configure(new CountConfig(chance)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
|
||||
public static EndFeature makeFeatureConfigured(String name, Feature<DefaultFeatureConfig> feature) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT);
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
|
||||
public Feature<?> getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.EndLilySeedBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -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;
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.EndLotusSeedBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -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;
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
import ru.betterend.blocks.EndLotusLeafBlock;
|
||||
|
@ -24,48 +24,51 @@ public class EndLotusLeafFeature extends ScatterFeature {
|
|||
generateLeaf(world, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||
return getPosOnSurface(world, pos);
|
||||
}
|
||||
|
||||
|
||||
private void generateLeaf(StructureWorldAccess world, BlockPos pos) {
|
||||
Mutable p = new Mutable();
|
||||
BlockState leaf = EndBlocks.END_LOTUS_LEAF.getDefaultState();
|
||||
MutableBlockPos p = new MutableBlockPos();
|
||||
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
|
||||
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
|
||||
for (Direction move: BlocksHelper.HORIZONTAL) {
|
||||
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
|
||||
for (Direction move : BlocksHelper.HORIZONTAL) {
|
||||
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf
|
||||
.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(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.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
|
||||
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2),
|
||||
leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean canGenerate(StructureWorldAccess world, BlockPos pos) {
|
||||
Mutable p = new Mutable();
|
||||
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.isAir(p) && world.getBlockState(p.down()).isOf(Blocks.WATER))
|
||||
count ++;
|
||||
if (world.isAir(p) && world.getBlockState(p.below()).is(Blocks.WATER))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return world.isAir(blockPos) && world.getBlockState(blockPos.down()).isOf(Blocks.WATER);
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return world.isAir(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
|
@ -20,11 +20,11 @@ public class FilaluxFeature extends SkyScatterFeature {
|
|||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
BlockState vine = EndBlocks.FILALUX.getDefaultState();
|
||||
BlockState wings = EndBlocks.FILALUX_WINGS.getDefaultState();
|
||||
BlockState vine = EndBlocks.FILALUX.defaultBlockState();
|
||||
BlockState wings = EndBlocks.FILALUX_WINGS.defaultBlockState();
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.FILALUX_LANTERN);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.up(), wings.with(Properties.FACING, Direction.UP));
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.offset(dir), wings.with(Properties.FACING, dir));
|
||||
}
|
||||
int length = MHelper.randRange(1, 3, random);
|
||||
|
|
|
@ -2,8 +2,8 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -12,24 +12,26 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.MHelper;
|
||||
|
||||
public abstract class FullHeightScatterFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public FullHeightScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius);
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, center.getX(), center.getZ());
|
||||
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
|
||||
for (int y = maxY; y > minY; y--) {
|
||||
POS.set(center.getX(), y, center.getZ());
|
||||
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.down()).isAir()) {
|
||||
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.below()).isAir()) {
|
||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -37,12 +39,13 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
|
|||
float theta = random.nextFloat() * MHelper.PI2;
|
||||
float x = pr * (float) Math.cos(theta);
|
||||
float z = pr * (float) Math.sin(theta);
|
||||
|
||||
|
||||
POS.set(center.getX() + x, y + 5, center.getZ() + z);
|
||||
int down = BlocksHelper.downRay(world, POS, 16);
|
||||
if (down > 10) continue;
|
||||
if (down > 10)
|
||||
continue;
|
||||
POS.setY(POS.getY() - down);
|
||||
|
||||
|
||||
if (canGenerate(world, random, center, POS, r)) {
|
||||
generate(world, random, POS);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -13,7 +13,8 @@ public class GlowPillarFeature extends ScatterFeature {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return EndBlocks.GLOWING_PILLAR_SEED.canPlaceAt(AIR, world, blockPos);
|
||||
}
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class GlowPillarFeature extends ScatterFeature {
|
|||
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
|
||||
seed.growAdult(world, random, blockPos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 10;
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.HydraluxSaplingBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -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;
|
||||
|
|
|
@ -2,8 +2,8 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -12,19 +12,21 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.MHelper;
|
||||
|
||||
public abstract class InvertedScatterFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public InvertedScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius);
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
|
||||
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
|
||||
for (int y = maxY; y > minY; y--) {
|
||||
|
@ -37,12 +39,13 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
|
|||
float theta = random.nextFloat() * MHelper.PI2;
|
||||
float x = pr * (float) Math.cos(theta);
|
||||
float z = pr * (float) Math.sin(theta);
|
||||
|
||||
|
||||
POS.set(center.getX() + x, center.getY() - 7, center.getZ() + z);
|
||||
int up = BlocksHelper.upRay(world, POS, 16);
|
||||
if (up > 14) continue;
|
||||
if (up > 14)
|
||||
continue;
|
||||
POS.setY(POS.getY() + up);
|
||||
|
||||
|
||||
if (canGenerate(world, random, center, POS, r)) {
|
||||
generate(world, random, POS);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -13,7 +13,8 @@ public class LanceleafFeature extends ScatterFeature {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return EndBlocks.LANCELEAF_SEED.canPlaceAt(AIR, world, blockPos);
|
||||
}
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class LanceleafFeature extends ScatterFeature {
|
|||
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
|
||||
seed.growAdult(world, random, blockPos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 5;
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Random;
|
|||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.StructureHelper;
|
||||
|
@ -15,11 +15,11 @@ import ru.betterend.util.StructureHelper;
|
|||
public class ListFeature extends NBTStructureFeature {
|
||||
private final List<StructureInfo> list;
|
||||
private StructureInfo selected;
|
||||
|
||||
|
||||
public ListFeature(List<StructureInfo> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
selected = list.get(random.nextInt(list.size()));
|
||||
|
@ -30,12 +30,12 @@ public class ListFeature extends NBTStructureFeature {
|
|||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
int cx = pos.getX() >> 4;
|
||||
int cz = pos.getZ() >> 4;
|
||||
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
||||
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return BlockRotation.random(random);
|
||||
protected Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return Rotation.random(random);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,23 +52,24 @@ public class ListFeature extends NBTStructureFeature {
|
|||
protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return selected.terrainMerge;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addStructureData(StructurePlacementData data) {}
|
||||
|
||||
protected void addStructureData(StructurePlacementData data) {
|
||||
}
|
||||
|
||||
public static final class StructureInfo {
|
||||
public final TerrainMerge terrainMerge;
|
||||
public final String structurePath;
|
||||
public final int offsetY;
|
||||
|
||||
|
||||
private Structure structure;
|
||||
|
||||
|
||||
public StructureInfo(String structurePath, int offsetY, TerrainMerge terrainMerge) {
|
||||
this.terrainMerge = terrainMerge;
|
||||
this.structurePath = structurePath;
|
||||
this.offsetY = offsetY;
|
||||
}
|
||||
|
||||
|
||||
public Structure getStructure() {
|
||||
if (structure == null) {
|
||||
structure = StructureHelper.readStructure(structurePath);
|
||||
|
|
|
@ -3,16 +3,16 @@ package ru.betterend.world.features;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
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(StructureWorldAccess 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.offset(dir);
|
||||
if (REPLACE.apply(world.getBlockState(pos))) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.MENGER_SPONGE_WET);
|
||||
|
@ -29,10 +29,10 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isOf(EndBlocks.END_LOTUS_STEM)) {
|
||||
if (state.is(EndBlocks.END_LOTUS_STEM)) {
|
||||
return false;
|
||||
}
|
||||
return !state.getFluidState().isEmpty() || state.getMaterial().isReplaceable();
|
||||
|
|
|
@ -4,19 +4,19 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -29,34 +29,33 @@ import ru.betterend.world.processors.DestructionStructureProcessor;
|
|||
|
||||
public abstract class NBTStructureFeature extends DefaultFeature {
|
||||
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
|
||||
|
||||
|
||||
protected abstract Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
|
||||
protected abstract boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
|
||||
protected abstract Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract BlockMirror getMirror(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
|
||||
protected abstract int getYOffset(Structure structure, StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
|
||||
protected abstract TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
|
||||
protected abstract void addStructureData(StructurePlacementData data);
|
||||
|
||||
|
||||
protected BlockPos getGround(StructureWorldAccess world, BlockPos center) {
|
||||
Biome biome = world.getBiome(center);
|
||||
Identifier id = EndBiomes.getBiomeID(biome);
|
||||
ResourceLocation id = EndBiomes.getBiomeID(biome);
|
||||
if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) {
|
||||
int y = getAverageY(world, center);
|
||||
return new BlockPos(center.getX(), y, center.getZ());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int y = getAverageYWG(world, center);
|
||||
return new BlockPos(center.getX(), y, center.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int getAverageY(StructureWorldAccess world, BlockPos center) {
|
||||
int y = getYOnSurface(world, center.getX(), center.getZ());
|
||||
y += getYOnSurface(world, center.getX() - 2, center.getZ() - 2);
|
||||
|
@ -65,7 +64,7 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
y += getYOnSurface(world, center.getX() + 2, center.getZ() + 2);
|
||||
return y / 5;
|
||||
}
|
||||
|
||||
|
||||
protected int getAverageYWG(StructureWorldAccess world, BlockPos center) {
|
||||
int y = getYOnSurfaceWG(world, center.getX(), center.getZ());
|
||||
y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() - 2);
|
||||
|
@ -74,49 +73,51 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() + 2);
|
||||
return y / 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
|
||||
center = getGround(world, center);
|
||||
|
||||
|
||||
if (!canSpawn(world, center, random)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int posY = center.getY() + 1;
|
||||
Structure structure = getStructure(world, center, random);
|
||||
BlockRotation rotation = getRotation(world, center, random);
|
||||
Rotation rotation = getRotation(world, center, random);
|
||||
BlockMirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
|
||||
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
|
||||
|
||||
BlockBox bounds = makeBox(center);
|
||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror)
|
||||
.setBoundingBox(bounds);
|
||||
addStructureData(placementData);
|
||||
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
||||
structure.place(world, center, placementData, random);
|
||||
|
||||
|
||||
TerrainMerge merge = getTerrainMerge(world, center, random);
|
||||
int x1 = center.getX();
|
||||
int z1 = center.getZ();
|
||||
int x2 = x1 + offset.getX();
|
||||
int z2 = z1 + offset.getZ();
|
||||
if (merge != TerrainMerge.NONE) {
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
|
||||
if (x2 < x1) {
|
||||
int a = x1;
|
||||
x1 = x2;
|
||||
x2 = a;
|
||||
}
|
||||
|
||||
|
||||
if (z2 < z1) {
|
||||
int a = z1;
|
||||
z1 = z2;
|
||||
z2 = a;
|
||||
}
|
||||
|
||||
|
||||
int surfMax = posY - 1;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
mut.setX(x);
|
||||
|
@ -130,22 +131,21 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
BlockState stateSt = world.getBlockState(mut);
|
||||
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
|
||||
.getSurfaceConfig();
|
||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
|
||||
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
|
||||
.getSurfaceConfig();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
|
@ -156,11 +156,12 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2));
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1),
|
||||
new BlockPos(x2, center.getY() + offset.getY(), z2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected BlockBox makeBox(BlockPos pos) {
|
||||
int sx = ((pos.getX() >> 4) << 4) - 16;
|
||||
int sz = ((pos.getZ() >> 4) << 4) - 16;
|
||||
|
@ -168,22 +169,22 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
int ez = sz + 47;
|
||||
return BlockBox.create(sx, 0, sz, ex, 255, ez);
|
||||
}
|
||||
|
||||
protected static Structure readStructure(Identifier resource) {
|
||||
|
||||
protected static Structure readStructure(ResourceLocation resource) {
|
||||
String ns = resource.getNamespace();
|
||||
String nm = resource.getPath();
|
||||
|
||||
try {
|
||||
InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
|
||||
InputStream inputstream = MinecraftServer.class
|
||||
.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
|
||||
return readStructureFromStream(inputstream);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static Structure readStructureFromStream(InputStream stream) throws IOException {
|
||||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
|
@ -192,20 +193,16 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
public static enum TerrainMerge {
|
||||
NONE,
|
||||
SURFACE,
|
||||
OBJECT;
|
||||
|
||||
NONE, SURFACE, OBJECT;
|
||||
|
||||
public static TerrainMerge getFromString(String type) {
|
||||
if (type.equals("surface")) {
|
||||
return SURFACE;
|
||||
}
|
||||
else if (type.equals("object")) {
|
||||
} else if (type.equals("object")) {
|
||||
return OBJECT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package ru.betterend.world.features;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -17,65 +17,61 @@ import ru.betterend.util.MHelper;
|
|||
|
||||
public class NeonCactusFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isOf(EndBlocks.ENDSTONE_DUST)) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int h = MHelper.randRange(5, 20, random);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
Direction hor = BlocksHelper.randomHorizontal(random);
|
||||
for (int i = 0; i < h; i++) {
|
||||
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
break;
|
||||
}
|
||||
int size = (h - i) >> 2;
|
||||
BlocksHelper.setWithUpdate(world, mut,
|
||||
EndBlocks.NEON_CACTUS.getDefaultState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size))
|
||||
.with(Properties.FACING, Direction.UP)
|
||||
);
|
||||
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, Direction.UP));
|
||||
if (i > 2 && i < (h - 1) && random.nextBoolean()) {
|
||||
int length = h - i - MHelper.randRange(1, 2, random);
|
||||
if (length > 0) {
|
||||
Direction dir2 = hor;
|
||||
hor = hor.rotateYClockwise();
|
||||
hor = hor.getClockWise();
|
||||
int bsize = i > ((h << 1) / 3) ? 0 : size > 1 ? 1 : size;
|
||||
branch(world, mut.offset(dir2), dir2, random, length, bsize);
|
||||
}
|
||||
}
|
||||
mut.move(Direction.UP);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void branch(StructureWorldAccess world, BlockPos pos, Direction dir, Random random, int length, int size) {
|
||||
int rotIndex = length >> 2;
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
Direction hor = BlocksHelper.randomHorizontal(random);
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
return;
|
||||
}
|
||||
BlocksHelper.setWithUpdate(world, mut,
|
||||
EndBlocks.NEON_CACTUS.getDefaultState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size))
|
||||
.with(Properties.FACING, dir)
|
||||
);
|
||||
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
|
||||
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, dir));
|
||||
if (i == rotIndex) {
|
||||
dir = Direction.UP;
|
||||
size --;
|
||||
size--;
|
||||
}
|
||||
if (i > 1 && i < (length - 1) && random.nextBoolean()) {
|
||||
Direction dir2 = dir == Direction.UP ? hor : Direction.UP;
|
||||
hor = hor.rotateYClockwise();
|
||||
branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random), size > 0 ? size - 1 : size);
|
||||
hor = hor.getClockWise();
|
||||
branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random),
|
||||
size > 0 ? size - 1 : size);
|
||||
}
|
||||
mut.move(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TripleShape getBySize(int size) {
|
||||
return size < 1 ? TripleShape.TOP : size == 1 ? TripleShape.MIDDLE : TripleShape.BOTTOM;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -12,32 +12,32 @@ import ru.betterend.util.BlocksHelper;
|
|||
import ru.betterend.util.MHelper;
|
||||
|
||||
public abstract class ScatterFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public ScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius);
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
|
||||
|
||||
|
||||
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||
return getPosOnSurfaceWG(world, pos);
|
||||
}
|
||||
|
||||
|
||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) {
|
||||
if (pos.getY() < 5) {
|
||||
return false;
|
||||
}
|
||||
else if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
} else if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) {
|
||||
int down = BlocksHelper.downRay(world, pos, 16);
|
||||
if (down > Math.abs(getYOffset() * 2)) {
|
||||
return false;
|
||||
|
@ -45,23 +45,24 @@ public abstract class ScatterFeature extends DefaultFeature {
|
|||
pos.setY(pos.getY() - down);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected int getYOffset() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
protected int getChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
center = getCenterGround(world, center);
|
||||
|
||||
|
||||
if (!canSpawn(world, center)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float r = MHelper.randRange(radius * 0.5F, radius, random);
|
||||
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -69,13 +70,14 @@ public abstract class ScatterFeature extends DefaultFeature {
|
|||
float theta = random.nextFloat() * MHelper.PI2;
|
||||
float x = pr * (float) Math.cos(theta);
|
||||
float z = pr * (float) Math.sin(theta);
|
||||
|
||||
|
||||
POS.set(center.getX() + x, center.getY() + getYOffset(), center.getZ() + z);
|
||||
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) && (getChance() < 2 || random.nextInt(getChance()) == 0)) {
|
||||
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r)
|
||||
&& (getChance() < 2 || random.nextInt(getChance()) == 0)) {
|
||||
generate(world, random, POS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -17,15 +17,15 @@ import ru.betterend.registry.EndBlocks;
|
|||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class SilkMothNestFeature extends DefaultFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
private boolean canGenerate(StructureWorldAccess world, BlockPos pos) {
|
||||
BlockState state = world.getBlockState(pos.up());
|
||||
if (state.isIn(BlockTags.LEAVES) || state.isIn(BlockTags.LOGS)) {
|
||||
state = world.getBlockState(pos);
|
||||
if ((state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.down())) {
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
if (world.getBlockState(pos.down().offset(dir)).getMaterial().blocksMovement()) {
|
||||
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.below())) {
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
if (world.getBlockState(pos.below().offset(dir)).getMaterial().blocksMovement()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -34,9 +34,10 @@ public class SilkMothNestFeature extends DefaultFeature {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
|
||||
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
|
||||
POS.set(center);
|
||||
|
@ -44,9 +45,11 @@ public class SilkMothNestFeature extends DefaultFeature {
|
|||
POS.setY(y);
|
||||
if (canGenerate(world, POS)) {
|
||||
Direction dir = BlocksHelper.randomHorizontal(random);
|
||||
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
|
||||
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
|
||||
.with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
|
||||
POS.setY(y - 1);
|
||||
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir));
|
||||
BlocksHelper.setWithoutUpdate(world, POS,
|
||||
EndBlocks.SILK_MOTH_NEST.defaultBlockState().with(Properties.HORIZONTAL_FACING, dir));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,29 +2,30 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.AttachedBlock;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class SingleInvertedScatterFeature extends InvertedScatterFeature {
|
||||
private final Block block;
|
||||
|
||||
|
||||
public SingleInvertedScatterFeature(Block block, int radius) {
|
||||
super(radius);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
if (!world.isAir(blockPos)) {
|
||||
return false;
|
||||
}
|
||||
BlockState state = block.getDefaultState();
|
||||
BlockState state = block.defaultBlockState();
|
||||
if (block instanceof AttachedBlock) {
|
||||
state = state.with(Properties.FACING, Direction.DOWN);
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ public class SingleInvertedScatterFeature extends InvertedScatterFeature {
|
|||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
BlockState state = block.getDefaultState();
|
||||
BlockState state = block.defaultBlockState();
|
||||
if (block instanceof AttachedBlock) {
|
||||
state = state.with(Properties.FACING, Direction.DOWN);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||
import ru.betterend.blocks.basis.EndCropBlock;
|
||||
|
@ -15,58 +15,56 @@ 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(StructureWorldAccess world, BlockPos pos) {
|
||||
return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return plant.canPlaceAt(plant.getDefaultState(), world, blockPos);
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
if (plant instanceof DoublePlantBlock) {
|
||||
int rot = random.nextInt(4);
|
||||
BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
|
||||
}
|
||||
else if (plant instanceof EndCropBlock) {
|
||||
BlockState state = plant.getDefaultState().with(EndCropBlock.AGE, 3);
|
||||
} else if (plant instanceof EndCropBlock) {
|
||||
BlockState state = plant.defaultBlockState().with(EndCropBlock.AGE, 3);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||
}
|
||||
else if (plant instanceof EndPlantWithAgeBlock) {
|
||||
} else if (plant instanceof EndPlantWithAgeBlock) {
|
||||
int age = random.nextInt(4);
|
||||
BlockState state = plant.getDefaultState().with(EndPlantWithAgeBlock.AGE, age);
|
||||
BlockState state = plant.defaultBlockState().with(EndPlantWithAgeBlock.AGE, age);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
@ -13,41 +13,42 @@ public abstract class SkyScatterFeature extends ScatterFeature {
|
|||
public SkyScatterFeature(int radius) {
|
||||
super(radius);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
if (!world.isAir(blockPos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
if (!world.isAir(blockPos.offset(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(StructureWorldAccess world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||
return new BlockPos(pos.getX(), MHelper.randRange(32, 192, world.getRandom()), pos.getZ());
|
||||
}
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) {
|
||||
pos.setY(pos.getY() + MHelper.randRange(-getYOffset(), getYOffset(), world.getRandom()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,35 +2,35 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
|
||||
private final Block plant;
|
||||
|
||||
|
||||
public UnderwaterPlantFeature(Block plant, int radius) {
|
||||
super(radius);
|
||||
this.plant = plant;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.getDefaultState(), world, blockPos);
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
|
||||
if (plant instanceof DoublePlantBlock) {
|
||||
int rot = random.nextInt(4);
|
||||
BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, state);
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
|
||||
public abstract class UnderwaterPlantScatter extends ScatterFeature {
|
||||
private static final Mutable POS = new Mutable();
|
||||
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
public UnderwaterPlantScatter(int radius) {
|
||||
super(radius);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) {
|
||||
POS.setX(pos.getX());
|
||||
|
@ -21,33 +21,34 @@ public abstract class UnderwaterPlantScatter extends ScatterFeature {
|
|||
POS.setY(0);
|
||||
return getGround(world, POS).toImmutable();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return world.getBlockState(blockPos).isOf(Blocks.WATER);
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
return world.getBlockState(blockPos).is(Blocks.WATER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) {
|
||||
return world.getBlockState(pos).isOf(Blocks.WATER);
|
||||
return world.getBlockState(pos).is(Blocks.WATER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) {
|
||||
protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) {
|
||||
return getGround(world, pos).getY() < 128;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getYOffset() {
|
||||
return -5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChance() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
private BlockPos getGround(StructureWorldAccess world, Mutable pos) {
|
||||
|
||||
private BlockPos getGround(StructureWorldAccess world, MutableBlockPos pos) {
|
||||
while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) {
|
||||
pos.setY(pos.getY() + 1);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
|
@ -15,7 +15,7 @@ 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;
|
||||
|
@ -24,7 +24,8 @@ public class VineFeature extends InvertedScatterFeature {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos,
|
||||
float radius) {
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
return state.getMaterial().isReplaceable() && canPlaceBlock(state, world, blockPos);
|
||||
}
|
||||
|
@ -43,28 +44,27 @@ public class VineFeature extends InvertedScatterFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), bottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean canPlaceBlock(BlockState state, StructureWorldAccess world, BlockPos blockPos) {
|
||||
if (vine) {
|
||||
return ((VineBlock) vineBlock).canGenerate(state, world, blockPos);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return vineBlock.canPlaceAt(state, world, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockState getTopState() {
|
||||
BlockState state = vineBlock.getDefaultState();
|
||||
BlockState state = vineBlock.defaultBlockState();
|
||||
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
|
||||
}
|
||||
|
||||
|
||||
private BlockState getMiggleState() {
|
||||
BlockState state = vineBlock.getDefaultState();
|
||||
BlockState state = vineBlock.defaultBlockState();
|
||||
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
|
||||
}
|
||||
|
||||
|
||||
private BlockState getBottomState() {
|
||||
BlockState state = vineBlock.getDefaultState();
|
||||
BlockState state = vineBlock.defaultBlockState();
|
||||
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.basis.AttachedBlock;
|
||||
import ru.betterend.blocks.basis.EndWallPlantBlock;
|
||||
|
@ -14,7 +14,7 @@ import ru.betterend.util.BlocksHelper;
|
|||
|
||||
public class WallPlantFeature extends WallScatterFeature {
|
||||
private final Block block;
|
||||
|
||||
|
||||
public WallPlantFeature(Block block, int radius) {
|
||||
super(radius);
|
||||
this.block = block;
|
||||
|
@ -23,23 +23,21 @@ public class WallPlantFeature extends WallScatterFeature {
|
|||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
|
||||
if (block instanceof EndWallPlantBlock) {
|
||||
BlockState state = block.getDefaultState().with(EndWallPlantBlock.FACING, dir);
|
||||
BlockState state = block.defaultBlockState().with(EndWallPlantBlock.FACING, dir);
|
||||
return block.canPlaceAt(state, world, pos);
|
||||
} else if (block instanceof AttachedBlock) {
|
||||
BlockState state = block.defaultBlockState().with(Properties.FACING, dir);
|
||||
return block.canPlaceAt(state, world, pos);
|
||||
}
|
||||
else if (block instanceof AttachedBlock) {
|
||||
BlockState state = block.getDefaultState().with(Properties.FACING, dir);
|
||||
return block.canPlaceAt(state, world, pos);
|
||||
}
|
||||
return block.canPlaceAt(block.getDefaultState(), world, pos);
|
||||
return block.canPlaceAt(block.defaultBlockState(), world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
|
||||
BlockState state = block.getDefaultState();
|
||||
BlockState state = block.defaultBlockState();
|
||||
if (block instanceof EndWallPlantBlock) {
|
||||
state = state.with(EndWallPlantBlock.FACING, dir);
|
||||
}
|
||||
else if (block instanceof AttachedBlock) {
|
||||
} else if (block instanceof AttachedBlock) {
|
||||
state = state.with(Properties.FACING, dir);
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
|
||||
public class WallPlantOnLogFeature extends WallPlantFeature {
|
||||
|
@ -16,7 +16,7 @@ public class WallPlantOnLogFeature extends WallPlantFeature {
|
|||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
|
||||
BlockPos blockPos = pos.offset(dir.getOpposite());
|
||||
BlockPos blockPos = pos.relative(dir.getOpposite());
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
return blockState.isIn(BlockTags.LOGS);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -15,25 +15,26 @@ import ru.betterend.util.MHelper;
|
|||
public abstract class WallScatterFeature extends DefaultFeature {
|
||||
private static final Direction[] DIR = BlocksHelper.makeHorizontal();
|
||||
private final int radius;
|
||||
|
||||
|
||||
public WallScatterFeature(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir);
|
||||
|
||||
|
||||
public abstract void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
|
||||
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
|
||||
if (maxY < 10 || maxY < minY) {
|
||||
return false;
|
||||
}
|
||||
int py = MHelper.randRange(minY, maxY, random);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
mut.setX(center.getX() + x);
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
|
@ -42,7 +43,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
|
|||
mut.setZ(center.getZ() + z);
|
||||
if (random.nextInt(4) == 0 && world.isAir(mut)) {
|
||||
shuffle(random);
|
||||
for (Direction dir: DIR) {
|
||||
for (Direction dir : DIR) {
|
||||
if (canGenerate(world, random, mut, dir)) {
|
||||
generate(world, random, mut, dir);
|
||||
break;
|
||||
|
@ -52,10 +53,10 @@ public abstract class WallScatterFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void shuffle(Random random) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int j = random.nextInt(4);
|
||||
|
|
|
@ -3,12 +3,12 @@ package ru.betterend.world.features.bushes;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -28,31 +28,38 @@ public class BushFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private final Block leaves;
|
||||
private final Block stem;
|
||||
|
||||
|
||||
public BushFeature(Block leaves, Block stem) {
|
||||
this.leaves = leaves;
|
||||
this.stem = stem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND) && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
|
||||
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
|
||||
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-2F, 2F, random);
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere)
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getPos().getManhattanDistance(pos);
|
||||
if (distance < 7) {
|
||||
return info.getState().with(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AIR;
|
||||
}
|
||||
}
|
||||
|
@ -60,21 +67,20 @@ public class BushFeature extends DefaultFeature {
|
|||
});
|
||||
sphere.fillRecursive(world, pos);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, stem);
|
||||
for (Direction d: Direction.values()) {
|
||||
BlockPos p = pos.offset(d);
|
||||
for (Direction d : Direction.values()) {
|
||||
BlockPos p = pos.relative(d);
|
||||
if (world.isAir(p)) {
|
||||
if (leaves instanceof LeavesBlock) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
|
|
@ -3,13 +3,13 @@ package ru.betterend.world.features.bushes;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -31,32 +31,39 @@ public class BushWithOuterFeature extends DefaultFeature {
|
|||
private final Block outer_leaves;
|
||||
private final Block leaves;
|
||||
private final Block stem;
|
||||
|
||||
|
||||
public BushWithOuterFeature(Block leaves, Block outer_leaves, Block stem) {
|
||||
this.outer_leaves = outer_leaves;
|
||||
this.leaves = leaves;
|
||||
this.stem = stem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND) && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
|
||||
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
|
||||
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-2F, 2F, random);
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere)
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getPos().getManhattanDistance(pos);
|
||||
if (distance < 7) {
|
||||
return info.getState().with(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AIR;
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +71,10 @@ public class BushWithOuterFeature extends DefaultFeature {
|
|||
}).addPostProcess((info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
MHelper.shuffle(DIRECTIONS, random);
|
||||
for (Direction dir: DIRECTIONS) {
|
||||
for (Direction dir : DIRECTIONS) {
|
||||
if (info.getState(dir).isAir()) {
|
||||
info.setBlockPos(info.getPos().offset(dir), outer_leaves.getDefaultState().with(Properties.FACING, dir));
|
||||
info.setBlockPos(info.getPos().offset(dir),
|
||||
outer_leaves.defaultBlockState().with(Properties.FACING, dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,21 +82,20 @@ public class BushWithOuterFeature extends DefaultFeature {
|
|||
});
|
||||
sphere.fillRecursive(world, pos);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, stem);
|
||||
for (Direction d: Direction.values()) {
|
||||
BlockPos p = pos.offset(d);
|
||||
for (Direction d : Direction.values()) {
|
||||
BlockPos p = pos.relative(d);
|
||||
if (world.isAir(p)) {
|
||||
if (leaves instanceof LeavesBlock) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features.bushes;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -19,10 +19,12 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class LargeAmaranitaFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
int height = MHelper.randRange(2, 3, random);
|
||||
for (int i = 1; i < height; i++) {
|
||||
mut.setY(mut.getY() + 1);
|
||||
|
@ -31,14 +33,16 @@ public class LargeAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
mut.set(pos);
|
||||
|
||||
BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.getDefaultState();
|
||||
|
||||
BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.defaultBlockState();
|
||||
BlocksHelper.setWithUpdate(world, mut, state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
||||
if (height > 2) {
|
||||
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
||||
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
|
||||
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
||||
}
|
||||
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
||||
|
||||
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
|
||||
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features.bushes;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -19,11 +19,13 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class Lumecorn extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
int height = MHelper.randRange(4, 7, random);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
for (int i = 1; i < height; i++) {
|
||||
mut.move(Direction.UP);
|
||||
if (!world.isAir(mut)) {
|
||||
|
@ -31,24 +33,30 @@ public class Lumecorn extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
mut.set(pos);
|
||||
BlockState topMiddle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP_MIDDLE);
|
||||
BlockState middle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_MIDDLE);
|
||||
BlockState bottom = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_BOTTOM);
|
||||
BlockState top = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
|
||||
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
|
||||
LumecornShape.LIGHT_TOP_MIDDLE);
|
||||
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
|
||||
LumecornShape.LIGHT_MIDDLE);
|
||||
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
|
||||
LumecornShape.LIGHT_BOTTOM);
|
||||
BlockState top = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
|
||||
if (height == 4) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
BlocksHelper.setWithoutUpdate(world, mut,
|
||||
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle);
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top);
|
||||
return true;
|
||||
}
|
||||
if (random.nextBoolean()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
|
||||
height --;
|
||||
BlocksHelper.setWithoutUpdate(world, mut,
|
||||
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut,
|
||||
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
|
||||
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
|
||||
height--;
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
|
||||
for (int i = 4; i < height; i++) {
|
||||
|
|
|
@ -6,12 +6,12 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -34,21 +34,29 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
public class TenaneaBushFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Direction[] DIRECTIONS = Direction.values();
|
||||
|
||||
public TenaneaBushFeature() {}
|
||||
|
||||
|
||||
public TenaneaBushFeature() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
BlockState leaves = EndBlocks.TENANEA_LEAVES.getDefaultState();
|
||||
BlockState leaves = EndBlocks.TENANEA_LEAVES.defaultBlockState();
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves);
|
||||
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-2F, 2F, random);
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere)
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sphere.addPostProcess((info) -> {
|
||||
|
@ -56,52 +64,54 @@ public class TenaneaBushFeature extends DefaultFeature {
|
|||
int distance = info.getPos().getManhattanDistance(pos);
|
||||
if (distance < 7) {
|
||||
if (random.nextInt(4) == 0 && info.getStateDown().isAir()) {
|
||||
BlockPos d = info.getPos().down();
|
||||
BlockPos d = info.getPos().below();
|
||||
support.add(d);
|
||||
}
|
||||
|
||||
|
||||
MHelper.shuffle(DIRECTIONS, random);
|
||||
for (Direction d: DIRECTIONS) {
|
||||
for (Direction d : DIRECTIONS) {
|
||||
if (info.getState(d).isAir()) {
|
||||
info.setBlockPos(info.getPos().offset(d), EndBlocks.TENANEA_OUTER_LEAVES.getDefaultState().with(FurBlock.FACING, d));
|
||||
info.setBlockPos(info.getPos().offset(d),
|
||||
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().with(FurBlock.FACING, d));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return info.getState().with(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AIR;
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
sphere.fillRecursive(world, pos);
|
||||
BlockState stem = EndBlocks.TENANEA.bark.getDefaultState();
|
||||
BlockState stem = EndBlocks.TENANEA.bark.defaultBlockState();
|
||||
BlocksHelper.setWithoutUpdate(world, pos, stem);
|
||||
for (Direction d: Direction.values()) {
|
||||
BlockPos p = pos.offset(d);
|
||||
for (Direction d : Direction.values()) {
|
||||
BlockPos p = pos.relative(d);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.with(LeavesBlock.DISTANCE, 1));
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
BlockState top = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.BOTTOM);
|
||||
support.forEach((bpos) -> {
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
if (state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) {
|
||||
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
|
||||
int count = MHelper.randRange(3, 8, random);
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut.up()).isOf(EndBlocks.TENANEA_LEAVES)) {
|
||||
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
for (int i = 1; i < count; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
if (world.isAir(mut.down())) {
|
||||
if (world.isAir(mut.below())) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, middle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -109,10 +119,10 @@ public class TenaneaBushFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -19,30 +19,30 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class BigAuroraCrystalFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
int maxY = pos.getY() + BlocksHelper.upRay(world, pos, 16);
|
||||
int minY = pos.getY() - BlocksHelper.downRay(world, pos, 16);
|
||||
|
||||
|
||||
if (maxY - minY < 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int y = MHelper.randRange(minY, maxY, random);
|
||||
pos = new BlockPos(pos.getX(), y, pos.getZ());
|
||||
|
||||
|
||||
int height = MHelper.randRange(5, 25, random);
|
||||
SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random)).setBlock(EndBlocks.AURORA_CRYSTAL);
|
||||
SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random))
|
||||
.setBlock(EndBlocks.AURORA_CRYSTAL);
|
||||
Vector3f vec = MHelper.randomHorizontal(random);
|
||||
prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism);
|
||||
prism.setReplaceFunction((bState) -> {
|
||||
return bState.getMaterial().isReplaceable()
|
||||
|| bState.isIn(EndTags.GEN_TERRAIN)
|
||||
|| bState.getMaterial().equals(Material.PLANT)
|
||||
|| bState.getMaterial().equals(Material.LEAVES);
|
||||
return bState.getMaterial().isReplaceable() || bState.isIn(EndTags.GEN_TERRAIN)
|
||||
|| bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
|
||||
});
|
||||
prism.fillRecursive(world, pos);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -19,46 +19,52 @@ import ru.betterend.util.MHelper;
|
|||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class EndLakeFeature extends DefaultFeature {
|
||||
private static final BlockState END_STONE = Blocks.END_STONE.getDefaultState();
|
||||
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
|
||||
private static final Mutable POS = new Mutable();
|
||||
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
double radius = MHelper.randRange(10.0, 20.0, random);
|
||||
double depth = radius * 0.5 * MHelper.randRange(0.8, 1.2, random);
|
||||
int dist = MHelper.floor(radius);
|
||||
int dist2 = MHelper.floor(radius * 1.5);
|
||||
int bott = MHelper.floor(depth);
|
||||
blockPos = getPosOnSurfaceWG(world, blockPos);
|
||||
if (blockPos.getY() < 10) return false;
|
||||
|
||||
if (blockPos.getY() < 10)
|
||||
return false;
|
||||
|
||||
int waterLevel = blockPos.getY();
|
||||
|
||||
|
||||
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).up(10), 20);
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
|
||||
return false;
|
||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||
|
||||
|
||||
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).up(10), 20);
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
|
||||
return false;
|
||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||
|
||||
|
||||
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).up(10), 20);
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
|
||||
return false;
|
||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||
|
||||
|
||||
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).up(10), 20);
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
|
||||
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
|
||||
return false;
|
||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||
BlockState state;
|
||||
|
||||
|
||||
int minX = blockPos.getX() - dist2;
|
||||
int maxX = blockPos.getX() + dist2;
|
||||
int minZ = blockPos.getZ() - dist2;
|
||||
int maxZ = blockPos.getZ() + dist2;
|
||||
int maskMinX = minX - 1;
|
||||
int maskMinZ = minZ - 1;
|
||||
|
||||
|
||||
boolean[][] mask = new boolean[maxX - minX + 3][maxZ - minZ + 3];
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
POS.setX(x);
|
||||
|
@ -84,7 +90,7 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
POS.setX(x);
|
||||
int x2 = x - blockPos.getX();
|
||||
|
@ -104,7 +110,8 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
size *= 0.8;
|
||||
add = 5;
|
||||
}
|
||||
double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) - 1.0 / size;
|
||||
double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75))
|
||||
- 1.0 / size;
|
||||
if (r > 0) {
|
||||
r *= r;
|
||||
if (x2 + z2 <= r) {
|
||||
|
@ -112,26 +119,28 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
if (state.isIn(EndTags.GEN_TERRAIN)) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, AIR);
|
||||
}
|
||||
pos = POS.down();
|
||||
pos = POS.below();
|
||||
if (world.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||
state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig()
|
||||
.getTopMaterial();
|
||||
if (y > waterLevel + 1)
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
else if (y > waterLevel)
|
||||
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state
|
||||
: EndBlocks.ENDSTONE_DUST.defaultBlockState());
|
||||
else
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos,
|
||||
EndBlocks.ENDSTONE_DUST.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double aspect = ((double) radius / (double) depth);
|
||||
|
||||
for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) {
|
||||
|
@ -160,12 +169,13 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
|
||||
BlocksHelper.setWithoutUpdate(world, POS, state);
|
||||
}
|
||||
pos = POS.down();
|
||||
pos = POS.below();
|
||||
if (world.getBlockState(pos).getBlock().isIn(EndTags.GEN_TERRAIN)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
|
||||
}
|
||||
pos = POS.up();
|
||||
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
||||
while (canReplace(state = world.getBlockState(pos)) && !state.isAir()
|
||||
&& state.getFluidState().isEmpty()) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
||||
pos = pos.up();
|
||||
}
|
||||
|
@ -174,30 +184,29 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
else if (y < waterLevel && y2 + x2 + z2 <= rb) {
|
||||
if (world.isAir(POS.up())) {
|
||||
state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE);
|
||||
BlocksHelper.setWithoutUpdate(world, POS,
|
||||
random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
|
||||
BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE);
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.ENDSTONE_DUST.defaultBlockState());
|
||||
BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE);
|
||||
}
|
||||
//}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
|
||||
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2),
|
||||
new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean canReplace(BlockState state) {
|
||||
return state.getMaterial().isReplaceable()
|
||||
|| state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.isOf(EndBlocks.ENDSTONE_DUST)
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.UNDERWATER_PLANT)
|
||||
|| state.getMaterial().equals(Material.UNUSED_PLANT);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -23,15 +23,18 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class FallenPillarFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world,
|
||||
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float height = MHelper.randRange(20F, 40F, random);
|
||||
float radius = MHelper.randRange(2F, 4F, random);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F)
|
||||
.setBlock(Blocks.OBSIDIAN);
|
||||
pillar = new SDFTranslate().setTranslate(0, radius * 0.5F - 2, 0).setSource(pillar);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
pillar = new SDFDisplacement().setFunction((vec) -> {
|
||||
|
@ -40,17 +43,18 @@ public class FallenPillarFeature extends DefaultFeature {
|
|||
Vector3f vec = MHelper.randomHorizontal(random);
|
||||
float angle = (float) random.nextGaussian() * 0.05F + (float) Math.PI;
|
||||
pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState();
|
||||
pillar.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -21,14 +21,16 @@ import ru.betterend.util.sdf.primitive.SDFSphere;
|
|||
|
||||
public class FloatingSpireFeature extends SpireFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
int minY = getYOnSurface(world, pos.getX(), pos.getZ());
|
||||
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) : MHelper.randRange(64, 192, random);
|
||||
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32)
|
||||
: MHelper.randRange(64, 192, random);
|
||||
pos = new BlockPos(pos.getX(), y, pos.getZ());
|
||||
|
||||
|
||||
SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE);
|
||||
int count = MHelper.randRange(3, 5, random);
|
||||
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float rMin = (i * 1.3F) + 2.5F;
|
||||
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
|
||||
|
@ -37,10 +39,11 @@ public class FloatingSpireFeature extends SpireFeature {
|
|||
float rMin = (i * 1.3F) + 2.5F;
|
||||
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
|
||||
}
|
||||
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
sdf = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F
|
||||
+ Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
}).setSource(sdf);
|
||||
final BlockPos center = pos;
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
|
@ -50,20 +53,19 @@ public class FloatingSpireFeature extends SpireFeature {
|
|||
support.add(info.getPos().up());
|
||||
}
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
else if (info.getState(Direction.UP, 3).isAir()) {
|
||||
} else if (info.getState(Direction.UP, 3).isAir()) {
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getUnderMaterial();
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
sdf.fillRecursive(world, center);
|
||||
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
if (EndBiomes.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
|
||||
EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,15 @@ package ru.betterend.world.features.terrain;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.HorizontalFacingBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.HorizontalFacingBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -43,23 +43,24 @@ public class GeyserFeature extends DefaultFeature {
|
|||
protected static final Function<BlockState, Boolean> REPLACE2;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurfaceWG(world, pos);
|
||||
|
||||
|
||||
if (pos.getY() < 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable bpos = new Mutable().set(pos);
|
||||
|
||||
MutableBlockPos bpos = new MutableBlockPos().set(pos);
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
state = world.getBlockState(bpos);
|
||||
}
|
||||
|
||||
|
||||
if (pos.getY() - bpos.getY() < 25) {
|
||||
return false;
|
||||
}
|
||||
|
@ -67,18 +68,21 @@ public class GeyserFeature extends DefaultFeature {
|
|||
int halfHeight = MHelper.randRange(10, 20, random);
|
||||
float radius1 = halfHeight * 0.5F;
|
||||
float radius2 = halfHeight * 0.1F + 0.5F;
|
||||
SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
|
||||
SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2)
|
||||
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
|
||||
sdf = new SDFTranslate().setTranslate(0, halfHeight - 3, 0).setSource(sdf);
|
||||
|
||||
int count = halfHeight;
|
||||
for (int i = 0; i < count; i++) {
|
||||
int py = i << 1;
|
||||
float delta = (float) i / (float) (count - 1);
|
||||
float radius = MathHelper.lerp(delta, radius1, radius2) * 1.3F;
|
||||
float radius = Mth.lerp(delta, radius1, radius2) * 1.3F;
|
||||
|
||||
SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
|
||||
SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius)
|
||||
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
|
||||
|
||||
SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.BRIMSTONE);
|
||||
SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius)
|
||||
.setBlock(EndBlocks.BRIMSTONE);
|
||||
brimstone = new SDFTranslate().setTranslate(0, 2F, 0).setSource(brimstone);
|
||||
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(brimstone);
|
||||
bowl = new SDFUnion().setSourceA(brimstone).setSourceB(bowl);
|
||||
|
@ -156,7 +160,7 @@ public class GeyserFeature extends DefaultFeature {
|
|||
}).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
|
||||
|
||||
BlocksHelper.setWithoutUpdate(world, pos, WATER);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY();
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, WATER);
|
||||
|
@ -167,7 +171,8 @@ public class GeyserFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
for (int i = 0; i < 150; i++) {
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5));
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10,
|
||||
MHelper.floor(random.nextGaussian() * 4 + 0.5));
|
||||
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
|
||||
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
|
||||
if (dist >= 0) {
|
||||
|
@ -176,24 +181,26 @@ public class GeyserFeature extends DefaultFeature {
|
|||
mut.setY(mut.getY() - 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
for (int j = 0; j <= dist; j++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||
MHelper.shuffle(HORIZONTAL, random);
|
||||
for (Direction dir : HORIZONTAL) {
|
||||
BlockPos p = mut.offset(dir);
|
||||
if (random.nextBoolean() && world.getBlockState(p).isOf(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.getDefaultState().with(HorizontalFacingBlock.FACING, dir));
|
||||
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
|
||||
.with(HorizontalFacingBlock.FACING, dir));
|
||||
}
|
||||
}
|
||||
mut.setY(mut.getY() + 1);
|
||||
}
|
||||
state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
|
||||
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
|
||||
distRaw < 2);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
while (state.isOf(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState());
|
||||
while (state.is(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
|
@ -202,12 +209,13 @@ public class GeyserFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10,
|
||||
MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
|
||||
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
|
||||
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
|
||||
if (dist >= 0) {
|
||||
state = world.getBlockState(mut);
|
||||
while (state.isOf(Blocks.WATER)) {
|
||||
while (state.is(Blocks.WATER)) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
|
@ -216,12 +224,13 @@ public class GeyserFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||
mut.setY(mut.getY() + 1);
|
||||
}
|
||||
state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
|
||||
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
|
||||
distRaw < 2);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
while (state.isOf(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState());
|
||||
while (state.is(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
|
@ -232,20 +241,21 @@ public class GeyserFeature extends DefaultFeature {
|
|||
EndFeatures.SULPHURIC_LAKE.getFeature().generate(world, chunkGenerator, random, pos, null);
|
||||
|
||||
double distance = radius1 * 1.7;
|
||||
BlockPos start = pos.add(-distance, -halfHeight - 15 - distance, -distance);
|
||||
BlockPos end = pos.add(distance, -halfHeight - 5 + distance, distance);
|
||||
BlockPos start = pos.offset(-distance, -halfHeight - 15 - distance, -distance);
|
||||
BlockPos end = pos.offset(distance, -halfHeight - 5 + distance, distance);
|
||||
BlocksHelper.fixBlocks(world, start, end);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE1 = (state) -> {
|
||||
return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN));
|
||||
};
|
||||
|
||||
|
||||
REPLACE2 = (state) -> {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(EndBlocks.HYDROTHERMAL_VENT) || state.isOf(EndBlocks.SULPHUR_CRYSTAL)) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|
||||
|| state.is(EndBlocks.SULPHUR_CRYSTAL)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
@ -253,9 +263,10 @@ public class GeyserFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return state.isOf(Blocks.WATER) || state.isOf(Blocks.CAVE_AIR) || state.isOf(EndBlocks.SULPHURIC_ROCK.stone) || state.isOf(EndBlocks.BRIMSTONE);
|
||||
return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone)
|
||||
|| state.is(EndBlocks.BRIMSTONE);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -24,64 +24,64 @@ public class IceStarFeature extends DefaultFeature {
|
|||
private final float maxSize;
|
||||
private final int minCount;
|
||||
private final int maxCount;
|
||||
|
||||
|
||||
public IceStarFeature(float minSize, float maxSize, int minCount, int maxCount) {
|
||||
this.minSize = minSize;
|
||||
this.maxSize = maxSize;
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
float size = MHelper.randRange(minSize, maxSize, random);
|
||||
int count = MHelper.randRange(minCount, maxCount, random);
|
||||
List<Vector3f> points = getFibonacciPoints(count);
|
||||
SDF sdf = null;
|
||||
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW);
|
||||
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.POSITIVE_Y, point);
|
||||
if (angle > 0.01F && angle < 3.14F) {
|
||||
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.POSITIVE_Y, point));
|
||||
rotated = new SDFRotation().setRotation(axis, angle).setSource(spike);
|
||||
}
|
||||
else if (angle > 1) {
|
||||
} else if (angle > 1) {
|
||||
rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(spike);
|
||||
}
|
||||
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
|
||||
}
|
||||
|
||||
|
||||
int x1 = (pos.getX() >> 4) << 4;
|
||||
int z1 = (pos.getZ() >> 4) << 4;
|
||||
pos = new BlockPos(x1 + random.nextInt(16), MHelper.randRange(32, 128, random), z1 + random.nextInt(16));
|
||||
|
||||
|
||||
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.getDefaultState();
|
||||
final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.getDefaultState();
|
||||
final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.getDefaultState();
|
||||
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;
|
||||
|
||||
|
||||
sdf.addPostProcess((info) -> {
|
||||
BlockPos bpos = info.getPos();
|
||||
float px = bpos.getX() - center.getX();
|
||||
float py = bpos.getY() - center.getY();
|
||||
float pz = bpos.getZ() - center.getZ();
|
||||
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale;
|
||||
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F
|
||||
+ 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();
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -21,26 +21,29 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class ObsidianBoulderFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world,
|
||||
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = MHelper.randRange(1, 5, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos p = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
|
||||
BlockPos p = getPosOnSurface(world,
|
||||
new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
|
||||
makeBoulder(world, p, random);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeBoulder(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float radius = MHelper.randRange(1F, 5F, random);
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.OBSIDIAN);
|
||||
float sx = MHelper.randRange(0.7F, 1.3F, random);
|
||||
|
@ -51,15 +54,16 @@ public class ObsidianBoulderFeature extends DefaultFeature {
|
|||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F);
|
||||
}).setSource(sphere);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -25,15 +25,18 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class ObsidianPillarBasementFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world,
|
||||
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float height = MHelper.randRange(10F, 35F, random);
|
||||
float radius = MHelper.randRange(2F, 5F, random);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F)
|
||||
.setBlock(Blocks.OBSIDIAN);
|
||||
pillar = new SDFTranslate().setTranslate(0, height * 0.5F - 3, 0).setSource(pillar);
|
||||
SDF cut = new SDFFlatland().setBlock(Blocks.OBSIDIAN);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
|
@ -48,17 +51,18 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
|
|||
vec = MHelper.randomHorizontal(random);
|
||||
angle = random.nextFloat() * 0.2F;
|
||||
pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState();
|
||||
pillar.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -20,32 +20,33 @@ public class OreLayerFeature extends DefaultFeature {
|
|||
private static final SDFSphere SPHERE;
|
||||
private static final SDFCoordModify NOISE;
|
||||
private static final SDF FUNCTION;
|
||||
|
||||
|
||||
private final BlockState state;
|
||||
private final float radius;
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
private OpenSimplexNoise noise;
|
||||
|
||||
|
||||
public OreLayerFeature(BlockState state, float radius, int minY, int maxY) {
|
||||
this.state = state;
|
||||
this.radius = radius;
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
float radius = this.radius * 0.5F;
|
||||
int r = MHelper.floor(radius + 1);
|
||||
int posX = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getX();
|
||||
int posZ = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getZ();
|
||||
int posY = MHelper.randRange(minY, maxY, random);
|
||||
|
||||
|
||||
if (noise == null) {
|
||||
noise = new OpenSimplexNoise(world.getSeed());
|
||||
}
|
||||
|
||||
|
||||
SPHERE.setRadius(radius).setBlock(state);
|
||||
NOISE.setFunction((vec) -> {
|
||||
double x = (vec.getX() + pos.getX()) * 0.1;
|
||||
|
@ -56,18 +57,18 @@ public class OreLayerFeature extends DefaultFeature {
|
|||
FUNCTION.fillRecursive(world, new BlockPos(posX, posY, posZ));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
SPHERE = new SDFSphere();
|
||||
NOISE = new SDFCoordModify();
|
||||
|
||||
|
||||
SDF body = SPHERE;
|
||||
body = new SDFScale3D().setScale(1, 0.2F, 1).setSource(body);
|
||||
body = NOISE.setSource(body);
|
||||
body.setReplaceFunction((state) -> {
|
||||
return state.isOf(Blocks.END_STONE);
|
||||
return state.is(Blocks.END_STONE);
|
||||
});
|
||||
|
||||
|
||||
FUNCTION = body;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -15,24 +15,25 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SingleBlockFeature extends DefaultFeature {
|
||||
private final Block block;
|
||||
|
||||
|
||||
public SingleBlockFeature(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN)) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState state = block.getDefaultState();
|
||||
|
||||
BlockState state = block.defaultBlockState();
|
||||
if (block.getStateManager().getProperty("waterlogged") != null) {
|
||||
boolean waterlogged = !world.getFluidState(pos).isEmpty();
|
||||
state = state.with(Properties.WATERLOGGED, waterlogged);
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -17,25 +17,28 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SmaragdantCrystalFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN)) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
int count = MHelper.randRange(15, 30, random);
|
||||
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.getDefaultState();
|
||||
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.getDefaultState();
|
||||
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState();
|
||||
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState();
|
||||
for (int i = 0; i < count; i++) {
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(3);
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5,
|
||||
MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()))
|
||||
+ random.nextInt(3);
|
||||
if (dist > 0) {
|
||||
BlockState state = world.getBlockState(mut);
|
||||
for (int n = 0; n < 10 && state.isAir(); n++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(crystal.getBlock())) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(crystal.getBlock())) {
|
||||
for (int j = 0; j <= dist; j++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, crystal);
|
||||
mut.setY(mut.getY() + 1);
|
||||
|
@ -45,7 +48,7 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -29,14 +29,16 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SpireFeature extends DefaultFeature {
|
||||
protected static final Function<BlockState, Boolean> REPLACE;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurfaceWG(world, pos);
|
||||
if (pos.getY() < 10 || !world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN) || !world.getBlockState(pos.down(6)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (pos.getY() < 10 || !world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN)
|
||||
|| !world.getBlockState(pos.down(6)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE);
|
||||
int count = MHelper.randRange(3, 7, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -45,7 +47,8 @@ public class SpireFeature extends DefaultFeature {
|
|||
}
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
sdf = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F
|
||||
+ Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
}).setSource(sdf);
|
||||
final BlockPos center = pos;
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
|
@ -55,13 +58,12 @@ public class SpireFeature extends DefaultFeature {
|
|||
support.add(info.getPos().up());
|
||||
}
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
else if (info.getState(Direction.UP, 3).isAir()) {
|
||||
} else if (info.getState(Direction.UP, 3).isAir()) {
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getUnderMaterial();
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, center);
|
||||
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
if (EndBiomes.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
|
||||
EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null);
|
||||
|
@ -70,13 +72,14 @@ public class SpireFeature extends DefaultFeature {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected SDF addSegment(SDF sdf, float radius, Random random) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.END_STONE);
|
||||
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0).setSource(sdf);
|
||||
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0)
|
||||
.setSource(sdf);
|
||||
return new SDFSmoothUnion().setRadius(radius * 0.5F).setSourceA(sphere).setSourceB(offseted);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
|
|
@ -2,12 +2,12 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -20,24 +20,25 @@ public class StalactiteFeature extends DefaultFeature {
|
|||
private final boolean ceiling;
|
||||
private final Block[] ground;
|
||||
private final Block block;
|
||||
|
||||
|
||||
public StalactiteFeature(boolean ceiling, Block block, Block... ground) {
|
||||
this.ceiling = ceiling;
|
||||
this.ground = ground;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.down()).getBlock())) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.below()).getBlock())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||
int height = random.nextInt(16);
|
||||
int dir = ceiling ? -1 : 1;
|
||||
boolean stalagnate = false;
|
||||
|
||||
|
||||
for (int i = 1; i <= height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
|
@ -47,21 +48,23 @@ public class StalactiteFeature extends DefaultFeature {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!stalagnate && height > 7) {
|
||||
height = random.nextInt(8);
|
||||
}
|
||||
|
||||
|
||||
float center = height * 0.5F;
|
||||
for (int i = 0; i < height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
int size = stalagnate ? MathHelper.clamp((int) (MathHelper.abs(i - center) + 1), 1, 7) : height - i - 1;
|
||||
int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1;
|
||||
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
||||
BlockState base = block.getDefaultState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED, waterlogged);
|
||||
BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) : base.with(StalactiteBlock.IS_FLOOR, dir > 0);
|
||||
BlockState base = block.defaultBlockState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED,
|
||||
waterlogged);
|
||||
BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center)
|
||||
: base.with(StalactiteBlock.IS_FLOOR, dir > 0);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -19,12 +19,13 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SulphurHillFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurfaceWG(world, pos);
|
||||
if (pos.getY() < 57 || pos.getY() > 70) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = MHelper.randRange(5, 13, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -38,14 +39,14 @@ public class SulphurHillFeature extends DefaultFeature {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeCircle(StructureWorldAccess world, BlockPos pos, OpenSimplexNoise noise, Random random) {
|
||||
int radius = MHelper.randRange(5, 9, random);
|
||||
int min = -radius - 3;
|
||||
int max = radius + 4;
|
||||
Mutable mut = new Mutable();
|
||||
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.getDefaultState();
|
||||
BlockState brimstone = EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true);
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState();
|
||||
BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
|
||||
for (int x = min; x < max; x++) {
|
||||
int x2 = x * x;
|
||||
int px = pos.getX() + x;
|
||||
|
@ -60,7 +61,7 @@ public class SulphurHillFeature extends DefaultFeature {
|
|||
int d = x2 + z2;
|
||||
mut.setY(pos.getY());
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (state.getMaterial().isReplaceable() || state.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
if (state.getMaterial().isReplaceable() || state.is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
if (d < r2 * r2) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.WATER);
|
||||
mut.move(Direction.DOWN);
|
||||
|
@ -76,8 +77,7 @@ 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);
|
||||
|
|
|
@ -5,13 +5,13 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.HorizontalFacingBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.HorizontalFacingBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -26,20 +26,21 @@ import ru.betterend.util.MHelper;
|
|||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class SulphuricCaveFeature extends DefaultFeature {
|
||||
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.getDefaultState();
|
||||
private static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
|
||||
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
|
||||
private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
int radius = MHelper.randRange(10, 30, random);
|
||||
|
||||
|
||||
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
Mutable bpos = new Mutable();
|
||||
MutableBlockPos bpos = new MutableBlockPos();
|
||||
bpos.setX(pos.getX());
|
||||
bpos.setZ(pos.getZ());
|
||||
bpos.setY(top - 1);
|
||||
|
||||
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
|
@ -49,34 +50,34 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
|||
return false;
|
||||
}
|
||||
top = (int) (bpos.getY() - (radius * 1.3F + 5));
|
||||
|
||||
|
||||
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
state = world.getBlockState(bpos);
|
||||
}
|
||||
int bottom = (int) (bpos.getY() + radius * 1.3F + 5);
|
||||
|
||||
|
||||
if (top <= bottom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
|
||||
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
|
||||
|
||||
|
||||
int x1 = pos.getX() - radius - 5;
|
||||
int z1 = pos.getZ() - radius - 5;
|
||||
int x2 = pos.getX() + radius + 5;
|
||||
int z2 = pos.getZ() + radius + 5;
|
||||
int y1 = MHelper.floor(pos.getY() - (radius + 5) / 1.6);
|
||||
int y2 = MHelper.floor(pos.getY() + (radius + 5) / 1.6);
|
||||
|
||||
|
||||
double hr = radius * 0.75;
|
||||
double nr = radius * 0.25;
|
||||
|
||||
|
||||
Set<BlockPos> brimstone = Sets.newHashSet();
|
||||
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.getDefaultState();
|
||||
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState();
|
||||
int waterLevel = pos.getY() + MHelper.randRange(MHelper.floor(radius * 0.8), radius, random);
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xsq = x - pos.getX();
|
||||
|
@ -99,15 +100,14 @@ 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.isIn(EndTags.GEN_TERRAIN) || state.isOf(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 (state.isIn(EndTags.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.toImmutable());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, rock);
|
||||
}
|
||||
}
|
||||
|
@ -118,26 +118,30 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
|||
brimstone.forEach((blockPos) -> {
|
||||
placeBrimstone(world, blockPos, random);
|
||||
});
|
||||
|
||||
|
||||
if (random.nextInt(4) == 0) {
|
||||
int count = MHelper.randRange(5, 20, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0,
|
||||
MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()))
|
||||
+ random.nextInt(2);
|
||||
if (dist > 0) {
|
||||
state = world.getBlockState(mut);
|
||||
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN)
|
||||
&& !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
for (int j = 0; j <= dist; j++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||
MHelper.shuffle(HORIZONTAL, random);
|
||||
for (Direction dir: HORIZONTAL) {
|
||||
for (Direction dir : HORIZONTAL) {
|
||||
BlockPos p = mut.offset(dir);
|
||||
if (random.nextBoolean() && world.getBlockState(p).isOf(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.getDefaultState().with(HorizontalFacingBlock.FACING, dir));
|
||||
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
|
||||
.with(HorizontalFacingBlock.FACING, dir));
|
||||
}
|
||||
}
|
||||
mut.setY(mut.getY() + 1);
|
||||
|
@ -145,9 +149,10 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT);
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
while (state.isOf(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState());
|
||||
world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
|
||||
while (state.is(Blocks.WATER)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
|
||||
world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN,
|
||||
MHelper.randRange(8, 32, random));
|
||||
mut.setY(mut.getY() + 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
|
@ -155,47 +160,42 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isReplaceable(BlockState state) {
|
||||
return state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.isOf(EndBlocks.HYDROTHERMAL_VENT)
|
||||
|| state.isOf(EndBlocks.VENT_BUBBLE_COLUMN)
|
||||
|| state.isOf(EndBlocks.SULPHUR_CRYSTAL)
|
||||
|| state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.UNDERWATER_PLANT)
|
||||
|| state.getMaterial().equals(Material.LEAVES);
|
||||
return state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|
||||
|| state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL)
|
||||
|| state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.UNDERWATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
|
||||
}
|
||||
|
||||
|
||||
private void placeBrimstone(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
BlockState state = getBrimstone(world, pos);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
if (state.get(BlockProperties.ACTIVE)) {
|
||||
if (state.getValue(BlockProperties.ACTIVE)) {
|
||||
makeShards(world, pos, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockState getBrimstone(StructureWorldAccess world, BlockPos pos) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
if (world.getBlockState(pos.offset(dir)).isOf(Blocks.WATER)) {
|
||||
return EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true);
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
|
||||
return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
|
||||
}
|
||||
}
|
||||
return EndBlocks.BRIMSTONE.getDefaultState();
|
||||
return EndBlocks.BRIMSTONE.defaultBlockState();
|
||||
}
|
||||
|
||||
|
||||
private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
BlockPos side;
|
||||
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) {
|
||||
BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState()
|
||||
.with(SulphurCrystalBlock.WATERLOGGED, true)
|
||||
.with(SulphurCrystalBlock.FACING, dir)
|
||||
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
|
||||
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
|
||||
.with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir)
|
||||
.with(SulphurCrystalBlock.AGE, random.nextInt(3));
|
||||
BlocksHelper.setWithoutUpdate(world, side, state);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -25,24 +25,25 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SulphuricLakeFeature extends DefaultFeature {
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
|
||||
private static final Mutable POS = new Mutable();
|
||||
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
blockPos = getPosOnSurfaceWG(world, blockPos);
|
||||
|
||||
|
||||
if (blockPos.getY() < 57) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
double radius = MHelper.randRange(10.0, 20.0, random);
|
||||
int dist2 = MHelper.floor(radius * 1.5);
|
||||
|
||||
|
||||
int minX = blockPos.getX() - dist2;
|
||||
int maxX = blockPos.getX() + dist2;
|
||||
int minZ = blockPos.getZ() - dist2;
|
||||
int maxZ = blockPos.getZ() + dist2;
|
||||
|
||||
|
||||
Set<BlockPos> brimstone = Sets.newHashSet();
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
POS.setX(x);
|
||||
|
@ -64,36 +65,33 @@ public class SulphuricLakeFeature extends DefaultFeature {
|
|||
if (random.nextInt(8) > 0) {
|
||||
brimstone.add(POS.toImmutable());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down());
|
||||
brimstone.add(POS.below());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!isAbsoluteBorder(world, POS)) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
|
||||
world.getFluidTickScheduler().schedule(POS, Fluids.WATER, 0);
|
||||
brimstone.add(POS.down());
|
||||
brimstone.add(POS.below());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down(2));
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
brimstone.add(POS.toImmutable());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down());
|
||||
brimstone.add(POS.below());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
|
||||
brimstone.remove(POS);
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
BlockPos offseted = POS.offset(dir);
|
||||
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
|
||||
brimstone.add(offseted);
|
||||
|
@ -102,14 +100,14 @@ public class SulphuricLakeFeature extends DefaultFeature {
|
|||
if (isDeepWater(world, POS)) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS.move(Direction.DOWN), Blocks.WATER);
|
||||
brimstone.remove(POS);
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||
BlockPos offseted = POS.offset(dir);
|
||||
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
|
||||
brimstone.add(offseted);
|
||||
}
|
||||
}
|
||||
}
|
||||
brimstone.add(POS.down());
|
||||
brimstone.add(POS.below());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down(2));
|
||||
if (random.nextBoolean()) {
|
||||
|
@ -118,13 +116,12 @@ public class SulphuricLakeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dist < r2) {
|
||||
} else if (dist < r2) {
|
||||
POS.setY(getYOnSurface(world, x, z) - 1);
|
||||
if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) {
|
||||
brimstone.add(POS.toImmutable());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down());
|
||||
brimstone.add(POS.below());
|
||||
if (random.nextBoolean()) {
|
||||
brimstone.add(POS.down(2));
|
||||
}
|
||||
|
@ -133,37 +130,37 @@ public class SulphuricLakeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
brimstone.forEach((bpos) -> {
|
||||
placeBrimstone(world, bpos, random);
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isBorder(StructureWorldAccess world, BlockPos pos) {
|
||||
int y = pos.getY() + 1;
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isAbsoluteBorder(StructureWorldAccess world, BlockPos pos) {
|
||||
int y = pos.getY() - 2;
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isDeepWater(StructureWorldAccess world, BlockPos pos) {
|
||||
int y = pos.getY() + 1;
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y
|
||||
|| getYOnSurface(world, pos.getX() + dir.getOffsetX() * 2, pos.getZ() + dir.getOffsetZ() * 2) < y
|
||||
|| getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) {
|
||||
|
@ -172,31 +169,30 @@ public class SulphuricLakeFeature extends DefaultFeature {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void placeBrimstone(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
BlockState state = getBrimstone(world, pos);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
if (state.get(BlockProperties.ACTIVE)) {
|
||||
if (state.getValue(BlockProperties.ACTIVE)) {
|
||||
makeShards(world, pos, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockState getBrimstone(StructureWorldAccess world, BlockPos pos) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
if (world.getBlockState(pos.offset(dir)).isOf(Blocks.WATER)) {
|
||||
return EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true);
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
|
||||
return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
|
||||
}
|
||||
}
|
||||
return EndBlocks.BRIMSTONE.getDefaultState();
|
||||
return EndBlocks.BRIMSTONE.defaultBlockState();
|
||||
}
|
||||
|
||||
|
||||
private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
BlockPos side;
|
||||
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) {
|
||||
BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState()
|
||||
.with(SulphurCrystalBlock.WATERLOGGED, true)
|
||||
.with(SulphurCrystalBlock.FACING, dir)
|
||||
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
|
||||
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
|
||||
.with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir)
|
||||
.with(SulphurCrystalBlock.AGE, random.nextInt(3));
|
||||
BlocksHelper.setWithoutUpdate(world, side, state);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -17,25 +17,30 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class SurfaceVentFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world,
|
||||
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
int count = MHelper.randRange(15, 30, random);
|
||||
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.WATERLOGGED, false);
|
||||
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.WATERLOGGED,
|
||||
false);
|
||||
for (int i = 0; i < count; i++) {
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(2 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
|
||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5,
|
||||
MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||
int dist = MHelper.floor(2 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()))
|
||||
+ random.nextInt(2);
|
||||
if (dist > 0) {
|
||||
BlockState state = world.getBlockState(mut);
|
||||
for (int n = 0; n < 10 && state.isAir(); n++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
state = world.getBlockState(mut);
|
||||
}
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
for (int j = 0; j <= dist; j++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||
mut.setY(mut.getY() + 1);
|
||||
|
@ -44,7 +49,7 @@ public class SurfaceVentFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -22,19 +22,20 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class CaveChunkPopulatorFeature extends DefaultFeature {
|
||||
private Supplier<EndCaveBiome> supplier;
|
||||
|
||||
|
||||
public CaveChunkPopulatorFeature(Supplier<EndCaveBiome> biome) {
|
||||
this.supplier = biome;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
Set<BlockPos> floorPositions = Sets.newHashSet();
|
||||
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
||||
int sx = (pos.getX() >> 4) << 4;
|
||||
int sz = (pos.getZ() >> 4) << 4;
|
||||
Mutable min = new Mutable().set(pos);
|
||||
Mutable max = new Mutable().set(pos);
|
||||
MutableBlockPos min = new MutableBlockPos().set(pos);
|
||||
MutableBlockPos max = new MutableBlockPos().set(pos);
|
||||
fillSets(sx, sz, world.getChunk(pos), floorPositions, ceilPositions, min, max);
|
||||
EndCaveBiome biome = supplier.get();
|
||||
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
|
@ -43,11 +44,12 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
BlocksHelper.fixBlocks(world, min, max);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void fillSets(int sx, int sz, Chunk chunk, Set<BlockPos> floorPositions, Set<BlockPos> ceilPositions, Mutable min, Mutable max) {
|
||||
Mutable mut = new Mutable();
|
||||
Mutable mut2 = new Mutable();
|
||||
Mutable mut3 = new Mutable();
|
||||
|
||||
protected void fillSets(int sx, int sz, Chunk chunk, Set<BlockPos> floorPositions, Set<BlockPos> ceilPositions,
|
||||
MutableBlockPos min, MutableBlockPos max) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
MutableBlockPos mut2 = new MutableBlockPos();
|
||||
MutableBlockPos mut3 = new MutableBlockPos();
|
||||
for (int x = 0; x < 16; x++) {
|
||||
mut.setX(x);
|
||||
mut2.setX(x);
|
||||
|
@ -59,13 +61,12 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
mut.setY(y);
|
||||
BlockState top = chunk.getBlockState(mut);
|
||||
BlockState bottom = chunk.getBlockState(mut2);
|
||||
if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.isOf(Blocks.STONE))) {
|
||||
if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) {
|
||||
mut3.set(mut2).move(sx, 0, sz);
|
||||
floorPositions.add(mut3.toImmutable());
|
||||
updateMin(mut3, min);
|
||||
updateMax(mut3, max);
|
||||
}
|
||||
else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN)|| top.isOf(Blocks.STONE))) {
|
||||
} else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) {
|
||||
mut3.set(mut).move(sx, 0, sz);
|
||||
ceilPositions.add(mut3.toImmutable());
|
||||
updateMin(mut3, min);
|
||||
|
@ -76,8 +77,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMin(BlockPos pos, Mutable min) {
|
||||
|
||||
private void updateMin(BlockPos pos, MutableBlockPos min) {
|
||||
if (pos.getX() < min.getX()) {
|
||||
min.setX(pos.getX());
|
||||
}
|
||||
|
@ -88,8 +89,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
min.setZ(pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMax(BlockPos pos, Mutable max) {
|
||||
|
||||
private void updateMax(BlockPos pos, MutableBlockPos max) {
|
||||
if (pos.getX() > max.getX()) {
|
||||
max.setX(pos.getX());
|
||||
}
|
||||
|
@ -100,8 +101,9 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
max.setZ(pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
|
||||
|
||||
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions,
|
||||
Random random, BlockState surfaceBlock) {
|
||||
float density = biome.getFloorDensity();
|
||||
floorPositions.forEach((pos) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
|
@ -113,8 +115,9 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions,
|
||||
Random random) {
|
||||
float density = biome.getCeilDensity();
|
||||
ceilPositions.forEach((pos) -> {
|
||||
BlockState ceilBlock = biome.getCeil(pos);
|
||||
|
@ -124,7 +127,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
|
|||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.down(), null);
|
||||
feature.generate(world, null, random, pos.below(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
@ -27,27 +27,29 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
public abstract class EndCaveFeature extends DefaultFeature {
|
||||
protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.getDefaultState();
|
||||
protected static final BlockState END_STONE = Blocks.END_STONE.getDefaultState();
|
||||
protected static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||
|
||||
protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
|
||||
protected static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
|
||||
protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!(GeneratorOptions.useNewGenerator() && GeneratorOptions.noRingVoid()) || pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) {
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!(GeneratorOptions.useNewGenerator() && GeneratorOptions.noRingVoid())
|
||||
|| pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (biomeMissingCaves(world, pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int radius = MHelper.randRange(10, 30, random);
|
||||
BlockPos center = findPos(world, pos, radius, random);
|
||||
|
||||
|
||||
if (center == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
EndCaveBiome biome = EndBiomes.getCaveBiome(random);
|
||||
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
||||
if (!caveBlocks.isEmpty()) {
|
||||
|
@ -55,7 +57,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
setBiomes(world, biome, caveBlocks);
|
||||
Set<BlockPos> floorPositions = Sets.newHashSet();
|
||||
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
||||
Mutable mut = new Mutable();
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
|
@ -75,13 +77,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
}
|
||||
fixBlocks(world, caveBlocks);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected abstract Set<BlockPos> generate(StructureWorldAccess world, BlockPos center, int radius, Random random);
|
||||
|
||||
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
|
||||
|
||||
protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> floorPositions,
|
||||
Random random, BlockState surfaceBlock) {
|
||||
float density = biome.getFloorDensity();
|
||||
floorPositions.forEach((pos) -> {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
|
||||
|
@ -93,8 +96,9 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions,
|
||||
Random random) {
|
||||
float density = biome.getCeilDensity();
|
||||
ceilPositions.forEach((pos) -> {
|
||||
BlockState ceilBlock = biome.getCeil(pos);
|
||||
|
@ -104,30 +108,30 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
if (density > 0 && random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.down(), null);
|
||||
feature.generate(world, null, random, pos.below(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
||||
blocks.forEach((pos) -> setBiome(world, pos, biome));
|
||||
}
|
||||
|
||||
|
||||
private void setBiome(StructureWorldAccess world, BlockPos pos, EndCaveBiome biome) {
|
||||
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomeArray();
|
||||
if (array != null) {
|
||||
array.setBiome(biome.getActualBiome(), pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockPos findPos(StructureWorldAccess world, BlockPos pos, int radius, Random random) {
|
||||
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
Mutable bpos = new Mutable();
|
||||
MutableBlockPos bpos = new MutableBlockPos();
|
||||
bpos.setX(pos.getX());
|
||||
bpos.setZ(pos.getZ());
|
||||
bpos.setY(top - 1);
|
||||
|
||||
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
|
@ -137,24 +141,24 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
return null;
|
||||
}
|
||||
top = (int) (bpos.getY() - (radius * 1.3F + 5));
|
||||
|
||||
|
||||
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
|
||||
bpos.setY(bpos.getY() - 1);
|
||||
state = world.getBlockState(bpos);
|
||||
}
|
||||
int bottom = (int) (bpos.getY() + radius * 1.3F + 5);
|
||||
|
||||
|
||||
if (top <= bottom) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
|
||||
}
|
||||
|
||||
|
||||
private void fixBlocks(StructureWorldAccess world, Set<BlockPos> caveBlocks) {
|
||||
BlockPos pos = caveBlocks.iterator().next();
|
||||
Mutable start = new Mutable().set(pos);
|
||||
Mutable end = new Mutable().set(pos);
|
||||
MutableBlockPos start = new MutableBlockPos().set(pos);
|
||||
MutableBlockPos end = new MutableBlockPos().set(pos);
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
if (bpos.getX() < start.getX()) {
|
||||
start.setX(bpos.getX());
|
||||
|
@ -162,14 +166,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
if (bpos.getX() > end.getX()) {
|
||||
end.setX(bpos.getX());
|
||||
}
|
||||
|
||||
|
||||
if (bpos.getY() < start.getY()) {
|
||||
start.setY(bpos.getY());
|
||||
}
|
||||
if (bpos.getY() > end.getY()) {
|
||||
end.setY(bpos.getY());
|
||||
}
|
||||
|
||||
|
||||
if (bpos.getZ() < start.getZ()) {
|
||||
start.setZ(bpos.getZ());
|
||||
}
|
||||
|
@ -179,20 +183,20 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
});
|
||||
BlocksHelper.fixBlocks(world, start.add(-5, -5, -5), end.add(5, 5, 5));
|
||||
}
|
||||
|
||||
|
||||
protected boolean isWaterNear(StructureWorldAccess world, BlockPos pos) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
if (!world.getFluidState(pos.offset(dir, 5)).isEmpty()) {
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (!world.getFluidState(pos.relative(dir, 5)).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected boolean biomeMissingCaves(StructureWorldAccess world, BlockPos pos) {
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int z = -2; z < 3; z++) {
|
||||
Biome biome = world.getBiome(pos.add(x << 4, 0, z << 4));
|
||||
Biome biome = world.getBiome(pos.offset(x << 4, 0, z << 4));
|
||||
EndBiome endBiome = EndBiomes.getFromBiome(biome);
|
||||
if (!endBiome.hasCaves()) {
|
||||
return true;
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
@ -19,19 +19,19 @@ public class RoundCaveFeature extends EndCaveFeature {
|
|||
@Override
|
||||
protected Set<BlockPos> generate(StructureWorldAccess 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;
|
||||
|
||||
|
||||
BlockState state;
|
||||
Mutable bpos = new Mutable();
|
||||
MutableBlockPos bpos = new MutableBlockPos();
|
||||
Set<BlockPos> blocks = Sets.newHashSet();
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xsq = x - center.getX();
|
||||
|
@ -53,13 +53,13 @@ public class RoundCaveFeature extends EndCaveFeature {
|
|||
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
|
||||
blocks.add(bpos.toImmutable());
|
||||
|
||||
|
||||
while (state.getMaterial().equals(Material.LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
|
||||
bpos.setY(bpos.getY() + 1);
|
||||
state = world.getBlockState(bpos);
|
||||
}
|
||||
|
||||
|
||||
bpos.setY(y - 1);
|
||||
while (state.getMaterial().equals(Material.LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
|
||||
|
@ -71,14 +71,12 @@ public class RoundCaveFeature extends EndCaveFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
private boolean isReplaceable(BlockState state) {
|
||||
return state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.LEAVES);
|
||||
return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
@ -19,36 +19,35 @@ import ru.betterend.util.sdf.SDF;
|
|||
|
||||
public class TunelCaveFeature extends EndCaveFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
|
||||
|
||||
@Override
|
||||
protected Set<BlockPos> generate(StructureWorldAccess world, BlockPos center, int radius, Random random) {
|
||||
//OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
// OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534,
|
||||
// center.getX(), center.getZ()));
|
||||
float rad = radius * 0.15F;
|
||||
int min = MathHelper.ceil(rad) - 15;
|
||||
int max = 31 - MathHelper.floor(rad);
|
||||
int min = Mth.ceil(rad) - 15;
|
||||
int max = 31 - Mth.floor(rad);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, 0, 0, radius / 3);
|
||||
spline = SplineHelper.smoothSpline(spline, 5);
|
||||
SplineHelper.offsetParts(spline, random, 5, radius * 0.4F, 5);
|
||||
for (Vector3f vec: spline) {
|
||||
float x = MathHelper.clamp(vec.getX(), min, max);
|
||||
float y = MathHelper.clamp(vec.getY(), -radius, radius);
|
||||
float z = MathHelper.clamp(vec.getZ(), min, max);
|
||||
for (Vector3f vec : spline) {
|
||||
float x = Mth.clamp(vec.getX(), min, max);
|
||||
float y = Mth.clamp(vec.getY(), -radius, radius);
|
||||
float z = Mth.clamp(vec.getZ(), min, max);
|
||||
vec.set(x, y, z);
|
||||
}
|
||||
SDF sdf = SplineHelper.buildSDF(spline, rad, rad, (vec) -> Blocks.AIR.getDefaultState());
|
||||
SDF sdf = SplineHelper.buildSDF(spline, rad, rad, (vec) -> Blocks.AIR.defaultBlockState());
|
||||
Set<BlockPos> positions = sdf.setReplaceFunction(REPLACE).getPositions(world, center);
|
||||
for (BlockPos p: positions) {
|
||||
for (BlockPos p : positions) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, CAVE_AIR);
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
return state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.LEAVES);
|
||||
return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -40,99 +40,108 @@ public class DragonTreeFeature extends DefaultFeature {
|
|||
private static final List<Vector3f> SIDE1;
|
||||
private static final List<Vector3f> SIDE2;
|
||||
private static final List<Vector3f> ROOT;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float size = MHelper.randRange(10, 25, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
|
||||
|
||||
Vector3f last = SplineHelper.getPos(spline, 3.5F);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
float radius = size * MHelper.randRange(0.5F, 0.7F, random);
|
||||
makeCap(world, pos.add(last.getX(), last.getY(), last.getZ()), radius, random, noise);
|
||||
|
||||
makeCap(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random, noise);
|
||||
|
||||
last = spline.get(0);
|
||||
makeRoots(world, pos.add(last.getX(), last.getY(), last.getZ()), radius, random);
|
||||
|
||||
makeRoots(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random);
|
||||
|
||||
radius = MHelper.randRange(1.2F, 2.3F, random);
|
||||
SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> {
|
||||
return EndBlocks.DRAGON_TREE.bark.getDefaultState();
|
||||
return EndBlocks.DRAGON_TREE.bark.defaultBlockState();
|
||||
});
|
||||
|
||||
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.addPostProcess(POST);
|
||||
function.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeCap(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||
|
||||
private void makeCap(StructureWorldAccess world, BlockPos pos, float radius, Random random,
|
||||
OpenSimplexNoise noise) {
|
||||
int count = (int) radius;
|
||||
int offset = (int) (BRANCH.get(BRANCH.size() - 1).getY() * radius);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
|
||||
|
||||
branch = SplineHelper.copySpline(SIDE1);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
|
||||
|
||||
branch = SplineHelper.copySpline(SIDE2);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
|
||||
}
|
||||
leavesBall(world, pos.up(offset), radius * 1.15F + 2, random, noise);
|
||||
}
|
||||
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random) {
|
||||
int count = (int) (radius * 1.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE);
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.DRAGON_TREE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6));
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random,
|
||||
OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius)
|
||||
.setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
|
||||
SDF sub = new SDFScale().setScale(5).setSource(sphere);
|
||||
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
|
||||
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
Mutable mut = new Mutable();
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return random.nextFloat() * 3F - 1.5F;
|
||||
}).setSource(sphere);
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (random.nextInt(5) == 0) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockState state = info.getState(dir, 2);
|
||||
if (state.isAir()) {
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
info.setState(EndBlocks.DRAGON_TREE.bark.getDefaultState());
|
||||
info.setState(EndBlocks.DRAGON_TREE.bark.defaultBlockState());
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
mut.setX(x + info.getPos().getX());
|
||||
|
@ -146,7 +155,7 @@ public class DragonTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -159,16 +168,16 @@ public class DragonTreeFeature extends DefaultFeature {
|
|||
return info.getState();
|
||||
});
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
|
||||
|
||||
|
||||
if (radius > 5) {
|
||||
int count = (int) (radius * 2.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
|
||||
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1,
|
||||
random.nextGaussian() * 1);
|
||||
boolean place = true;
|
||||
for (Direction d: Direction.values()) {
|
||||
for (Direction d : Direction.values()) {
|
||||
BlockState state = world.getBlockState(p.offset(d));
|
||||
if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.isOf(EndBlocks.DRAGON_TREE_LEAVES)) {
|
||||
if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.is(EndBlocks.DRAGON_TREE_LEAVES)) {
|
||||
place = false;
|
||||
break;
|
||||
}
|
||||
|
@ -178,10 +187,10 @@ public class DragonTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.DRAGON_TREE.bark);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
@ -195,45 +204,36 @@ public class DragonTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.DRAGON_TREE.isTreeLog(state);
|
||||
};
|
||||
|
||||
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp()) && EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.DRAGON_TREE.log.getDefaultState();
|
||||
if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp())
|
||||
&& EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.DRAGON_TREE.log.defaultBlockState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0),
|
||||
new Vector3f(0.1F, 0.3F, 0),
|
||||
new Vector3f(0.4F, 0.6F, 0),
|
||||
new Vector3f(0.8F, 0.8F, 0),
|
||||
new Vector3f(1, 1, 0));
|
||||
SIDE1 = Lists.newArrayList(new Vector3f(0.4F, 0.6F, 0),
|
||||
new Vector3f(0.8F, 0.8F, 0),
|
||||
new Vector3f(1, 1, 0));
|
||||
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.1F, 0.3F, 0), new Vector3f(0.4F, 0.6F, 0),
|
||||
new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0));
|
||||
SIDE1 = Lists.newArrayList(new Vector3f(0.4F, 0.6F, 0), new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0));
|
||||
SIDE2 = SplineHelper.copySpline(SIDE1);
|
||||
|
||||
|
||||
Vector3f offset1 = new Vector3f(-0.4F, -0.6F, 0);
|
||||
Vector3f offset2 = new Vector3f(0.4F, 0.6F, 0);
|
||||
|
||||
|
||||
SplineHelper.offset(SIDE1, offset1);
|
||||
SplineHelper.offset(SIDE2, offset1);
|
||||
SplineHelper.rotateSpline(SIDE1, 0.5F);
|
||||
SplineHelper.rotateSpline(SIDE2, -0.5F);
|
||||
SplineHelper.offset(SIDE1, offset2);
|
||||
SplineHelper.offset(SIDE2, offset2);
|
||||
|
||||
ROOT = Lists.newArrayList(
|
||||
new Vector3f(0F, 1F, 0),
|
||||
new Vector3f(0.1F, 0.7F, 0),
|
||||
new Vector3f(0.3F, 0.3F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.2F, 0)
|
||||
);
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.7F, 0), new Vector3f(0.3F, 0.3F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.2F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Direction.Axis;
|
||||
import net.minecraft.util.math.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -30,43 +30,46 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float size = MHelper.randRange(5, 10, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 5);
|
||||
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
|
||||
float radius = size * 0.17F;//MHelper.randRange(0.8F, 1.2F, random);
|
||||
|
||||
float radius = size * 0.17F;// MHelper.randRange(0.8F, 1.2F, random);
|
||||
SDF function = SplineHelper.buildSDF(spline, radius, 0.2F, (bpos) -> {
|
||||
return EndBlocks.AMARANITA_STEM.getDefaultState();
|
||||
return EndBlocks.AMARANITA_STEM.defaultBlockState();
|
||||
});
|
||||
|
||||
|
||||
Vector3f capPos = spline.get(spline.size() - 1);
|
||||
makeHead(world, pos.add(capPos.getX() + 0.5F, capPos.getY() + 1.5F ,capPos.getZ() + 0.5F), MathHelper.floor(size / 1.6F));
|
||||
|
||||
makeHead(world, pos.offset(capPos.getX() + 0.5F, capPos.getY() + 1.5F, capPos.getZ() + 0.5F),
|
||||
Mth.floor(size / 1.6F));
|
||||
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.addPostProcess(POST);
|
||||
function.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
List<Vector3f> copy = SplineHelper.copySpline(spline);
|
||||
SplineHelper.offsetParts(copy, random, 0.2F, 0, 0.2F);
|
||||
SplineHelper.fillSplineForce(copy, world, EndBlocks.AMARANITA_HYPHAE.getDefaultState(), pos, REPLACE);
|
||||
SplineHelper.fillSplineForce(copy, world, EndBlocks.AMARANITA_HYPHAE.defaultBlockState(), pos, REPLACE);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeHead(StructureWorldAccess world, BlockPos pos, int radius) {
|
||||
Mutable mut = new Mutable();
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
if (radius < 2) {
|
||||
for (int i = -1; i < 2; i++) {
|
||||
mut.set(pos).move(Direction.NORTH, 2).move(Direction.EAST, i);
|
||||
|
@ -95,12 +98,13 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
|
||||
mut.move(Direction.DOWN);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN));
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
|
||||
.with(AttachedBlock.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int h = radius + 1;
|
||||
for (int y = 0; y < h; y++) {
|
||||
mut.setY(pos.getY() + y + 1);
|
||||
|
@ -114,7 +118,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mut.setY(pos.getY() + h + 1);
|
||||
for (int x = -1; x < 2; x++) {
|
||||
mut.setX(pos.getX() + x);
|
||||
|
@ -125,9 +129,8 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (radius < 4) {
|
||||
pos = pos.add(-1, 0, -1);
|
||||
} 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);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
|
@ -158,18 +161,21 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
|
||||
BlockPos offseted = mut.offset(axis, distance);
|
||||
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
|
||||
Direction dir = Direction.from(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, dir));
|
||||
Direction dir = Direction.fromAxisAndDirection(axis,
|
||||
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||
BlocksHelper.setWithoutUpdate(world, offseted,
|
||||
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
|
||||
}
|
||||
mut.move(Direction.DOWN);
|
||||
}
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN));
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
|
||||
.with(AttachedBlock.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int h = radius - 1;
|
||||
for (int y = 0; y < h; y++) {
|
||||
mut.setY(pos.getY() + y + 1);
|
||||
|
@ -183,7 +189,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mut.setY(pos.getY() + h + 1);
|
||||
for (int x = -1; x < 3; x++) {
|
||||
mut.setX(pos.getX() + x);
|
||||
|
@ -194,8 +200,7 @@ 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()) {
|
||||
|
@ -209,7 +214,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
}
|
||||
|
||||
|
||||
mut.set(pos).move(Direction.SOUTH, 3).move(Direction.EAST, i);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
|
@ -222,7 +227,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
}
|
||||
|
||||
|
||||
mut.set(pos).move(Direction.EAST, 3).move(Direction.NORTH, i);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
|
@ -235,7 +240,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
}
|
||||
|
||||
|
||||
mut.set(pos).move(Direction.WEST, 3).move(Direction.NORTH, i);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
|
@ -249,14 +254,15 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3).move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3);
|
||||
mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3)
|
||||
.move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int z = -2; z < 3; z++) {
|
||||
mut.set(pos).move(x, 0, z);
|
||||
|
@ -269,18 +275,21 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
|
||||
BlockPos offseted = mut.offset(axis, distance);
|
||||
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
|
||||
Direction dir = Direction.from(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, dir));
|
||||
Direction dir = Direction.fromAxisAndDirection(axis,
|
||||
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||
BlocksHelper.setWithoutUpdate(world, offseted,
|
||||
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
|
||||
}
|
||||
mut.move(Direction.DOWN);
|
||||
}
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN));
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
|
||||
.with(AttachedBlock.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
mut.setY(pos.getY() + y + 1);
|
||||
for (int x = -2; x < 3; x++) {
|
||||
|
@ -293,7 +302,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int h = radius + 1;
|
||||
for (int y = 4; y < h; y++) {
|
||||
mut.setY(pos.getY() + y);
|
||||
|
@ -302,12 +311,13 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
for (int z = -2; z < 3; z++) {
|
||||
mut.setZ(pos.getZ() + z);
|
||||
if (y < 6) {
|
||||
if (((x / 2) == 0 || (z / 2) == 0) && world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
if (((x / 2) == 0 || (z / 2) == 0)
|
||||
&& world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2) && world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +326,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
|
||||
|
@ -324,14 +334,14 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.DRAGON_TREE.isTreeLog(state);
|
||||
};
|
||||
|
||||
|
||||
POST = (info) -> {
|
||||
if (!info.getStateUp().isOf(EndBlocks.AMARANITA_STEM) || !info.getStateDown().isOf(EndBlocks.AMARANITA_STEM)) {
|
||||
return EndBlocks.AMARANITA_HYPHAE.getDefaultState();
|
||||
if (!info.getStateUp().is(EndBlocks.AMARANITA_STEM) || !info.getStateDown().is(EndBlocks.AMARANITA_STEM)) {
|
||||
return EndBlocks.AMARANITA_HYPHAE.defaultBlockState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -31,16 +31,18 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class HelixTreeFeature extends DefaultFeature {
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
|
||||
|
||||
float angle = random.nextFloat() * MHelper.PI2;
|
||||
float radiusRange = MHelper.randRange(4.5F, 6F, random);
|
||||
float scale = MHelper.randRange(0.5F, 1F, random);
|
||||
|
||||
|
||||
float dx;
|
||||
float dz;
|
||||
List<Vector3f> spline = new ArrayList<Vector3f>(10);
|
||||
|
@ -50,35 +52,40 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
dz = (float) Math.cos(i + angle) * radius;
|
||||
spline.add(new Vector3f(dx, i * 2, dz));
|
||||
}
|
||||
SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> { return EndBlocks.HELIX_TREE.bark.getDefaultState(); });
|
||||
SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> {
|
||||
return EndBlocks.HELIX_TREE.bark.defaultBlockState();
|
||||
});
|
||||
SDF rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(sdf);
|
||||
sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf);
|
||||
|
||||
|
||||
Vector3f lastPoint = spline.get(spline.size() - 1);
|
||||
List<Vector3f> spline2 = SplineHelper.makeSpline(0, 0, 0, 0, 20, 0, 5);
|
||||
SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> { return EndBlocks.HELIX_TREE.bark.getDefaultState(); });
|
||||
SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> {
|
||||
return EndBlocks.HELIX_TREE.bark.defaultBlockState();
|
||||
});
|
||||
stem = new SDFTranslate().setTranslate(lastPoint.getX(), lastPoint.getY(), lastPoint.getZ()).setSource(stem);
|
||||
sdf = new SDFSmoothUnion().setRadius(3).setSourceA(sdf).setSourceB(stem);
|
||||
|
||||
|
||||
sdf = new SDFScale().setScale(scale).setSource(sdf);
|
||||
dx = 30 * scale;
|
||||
float dy1 = -20 * scale;
|
||||
float dy2 = 100 * scale;
|
||||
sdf.addPostProcess(POST).fillArea(world, pos, new Box(pos.add(-dx, dy1, -dx), pos.add(dx, dy2, dx)));
|
||||
sdf.addPostProcess(POST).fillArea(world, pos, new Box(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
|
||||
SplineHelper.scale(spline, scale);
|
||||
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.getDefaultState(), pos, (state) -> {
|
||||
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
});
|
||||
SplineHelper.rotateSpline(spline, (float) Math.PI);
|
||||
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.getDefaultState(), pos, (state) -> {
|
||||
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
});
|
||||
SplineHelper.scale(spline2, scale);
|
||||
BlockPos leafStart = pos.add(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5);
|
||||
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.getDefaultState(), leafStart, (state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
});
|
||||
|
||||
BlockPos leafStart = pos.offset(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5);
|
||||
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart,
|
||||
(state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
});
|
||||
|
||||
spline.clear();
|
||||
float rad = MHelper.randRange(8F, 11F, random);
|
||||
int count = MHelper.randRange(20, 30, random);
|
||||
|
@ -93,11 +100,11 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
dz = (float) Math.cos(i * 0.45F + angle) * radius;
|
||||
spline.add(new Vector3f(dx, i * scaleM, dz));
|
||||
}
|
||||
|
||||
|
||||
Vector3f start = new Vector3f();
|
||||
Vector3f end = new Vector3f();
|
||||
lastPoint = spline.get(0);
|
||||
BlockState leaf = EndBlocks.HELIX_TREE_LEAVES.getDefaultState();
|
||||
BlockState leaf = EndBlocks.HELIX_TREE_LEAVES.defaultBlockState();
|
||||
for (int i = 1; i < spline.size(); i++) {
|
||||
Vector3f point = spline.get(i);
|
||||
int minY = MHelper.floor(lastPoint.getY());
|
||||
|
@ -106,8 +113,8 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
for (float py = minY; py <= maxY; py += 0.2F) {
|
||||
start.set(0, py, 0);
|
||||
float delta = (float) (py - minY) / div;
|
||||
float px = MathHelper.lerp(delta, lastPoint.getX(), point.getX());
|
||||
float pz = MathHelper.lerp(delta, lastPoint.getZ(), point.getZ());
|
||||
float px = Mth.lerp(delta, lastPoint.getX(), point.getX());
|
||||
float pz = Mth.lerp(delta, lastPoint.getZ(), point.getZ());
|
||||
end.set(px, py, pz);
|
||||
fillLine(start, end, world, leaf, leafStart, i / 2 - 1);
|
||||
float ax = Math.abs(px);
|
||||
|
@ -115,8 +122,7 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
if (ax > az) {
|
||||
start.set(start.getX(), start.getY(), start.getZ() + az > 0 ? 1 : -1);
|
||||
end.set(end.getX(), end.getY(), end.getZ() + az > 0 ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
start.set(start.getX() + ax > 0 ? 1 : -1, start.getY(), start.getZ());
|
||||
end.set(end.getX() + ax > 0 ? 1 : -1, end.getY(), end.getZ());
|
||||
}
|
||||
|
@ -124,7 +130,7 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
}
|
||||
lastPoint = point;
|
||||
}
|
||||
|
||||
|
||||
leaf = leaf.with(HelixTreeLeavesBlock.COLOR, 7);
|
||||
leafStart = leafStart.add(0, lastPoint.getY(), 0);
|
||||
if (world.getBlockState(leafStart).isAir()) {
|
||||
|
@ -133,16 +139,17 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
if (world.getBlockState(leafStart).isAir()) {
|
||||
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
|
||||
leafStart = leafStart.up();
|
||||
if (world.getBlockState(leafStart).isAir()) {
|
||||
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
|
||||
}
|
||||
if (world.getBlockState(leafStart).isAir()) {
|
||||
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, int offset) {
|
||||
|
||||
private void fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos,
|
||||
int offset) {
|
||||
float dx = end.getX() - start.getX();
|
||||
float dy = end.getY() - start.getY();
|
||||
float dz = end.getZ() - start.getZ();
|
||||
|
@ -154,12 +161,12 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
float x = start.getX();
|
||||
float y = start.getY();
|
||||
float z = start.getZ();
|
||||
|
||||
Mutable bPos = new Mutable();
|
||||
|
||||
MutableBlockPos bPos = new MutableBlockPos();
|
||||
for (int i = 0; i < count; i++) {
|
||||
bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ());
|
||||
int color = MHelper.floor((float) i / (float) count * 7F + 0.5F) + offset;
|
||||
color = MathHelper.clamp(color, 0, 7);
|
||||
color = Mth.clamp(color, 0, 7);
|
||||
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, color));
|
||||
}
|
||||
|
@ -172,11 +179,12 @@ public class HelixTreeFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, 7));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp()) && EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.HELIX_TREE.log.getDefaultState();
|
||||
if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp())
|
||||
&& EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.HELIX_TREE.log.defaultBlockState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
|
|
@ -6,11 +6,11 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -31,14 +31,16 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
public class JellyshroomFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final List<Vector3f> ROOT;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
BlockState bark = EndBlocks.JELLYSHROOM.bark.getDefaultState();
|
||||
BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.getDefaultState();
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState bark = EndBlocks.JELLYSHROOM.bark.defaultBlockState();
|
||||
BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.defaultBlockState();
|
||||
|
||||
int height = MHelper.randRange(5, 8, random);
|
||||
float radius = height * MHelper.randRange(0.15F, 0.25F, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, -1, 0, 0, height, 0, 3);
|
||||
|
@ -46,7 +48,7 @@ public class JellyshroomFeature extends DefaultFeature {
|
|||
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> {
|
||||
return bark;
|
||||
});
|
||||
|
||||
|
||||
radius = height * MHelper.randRange(0.7F, 0.9F, random);
|
||||
if (radius < 1.5F) {
|
||||
radius = 1.5F;
|
||||
|
@ -58,67 +60,63 @@ public class JellyshroomFeature extends DefaultFeature {
|
|||
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
|
||||
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
|
||||
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getState())) {
|
||||
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp()) && EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.JELLYSHROOM.log.getDefaultState();
|
||||
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp())
|
||||
&& EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.JELLYSHROOM.log.defaultBlockState();
|
||||
}
|
||||
}
|
||||
else if (info.getState().isOf(EndBlocks.JELLYSHROOM_CAP_PURPLE)) {
|
||||
} else if (info.getState().is(EndBlocks.JELLYSHROOM_CAP_PURPLE)) {
|
||||
float dx = info.getPos().getX() - pos.getX() - last.getX();
|
||||
float dz = info.getPos().getZ() - pos.getZ() - last.getZ();
|
||||
float distance = MHelper.length(dx, dz) / membraneRadius * 7F;
|
||||
int color = MathHelper.clamp(MHelper.floor(distance), 0, 7);
|
||||
int color = Mth.clamp(MHelper.floor(distance), 0, 7);
|
||||
return info.getState().with(JellyshroomCapBlock.COLOR, color);
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, pos);
|
||||
radius = height * 0.5F;
|
||||
makeRoots(world, pos.add(0, 2, 0), radius, random, bark);
|
||||
|
||||
makeRoots(world, pos.offset(0, 2, 0), radius, random, bark);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) {
|
||||
int count = (int) (radius * 3.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private SDF makeCap(float radius, Random random, BlockState cap) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
|
||||
SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
|
||||
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
|
||||
sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere);
|
||||
|
||||
|
||||
float angle = random.nextFloat() * MHelper.PI2;
|
||||
int count = (int) MHelper.randRange(radius * 0.5F, radius, random);
|
||||
if (count < 3) {
|
||||
count = 3;
|
||||
}
|
||||
sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.2F).setSource(sphere);
|
||||
|
||||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
ROOT = Lists.newArrayList(
|
||||
new Vector3f(0.1F, 0.70F, 0),
|
||||
new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.20F, 0)
|
||||
);
|
||||
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
|
||||
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
|
|
|
@ -4,13 +4,13 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -32,39 +32,41 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float size = MHelper.randRange(15, 25, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
|
||||
|
||||
float radius = MHelper.randRange(6F, 8F, random);
|
||||
radius *= (size - 15F) / 20F + 1F;
|
||||
Vector3f center = spline.get(4);
|
||||
leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||
|
||||
leavesBall(world, pos.offset(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||
|
||||
radius = MHelper.randRange(1.2F, 1.8F, random);
|
||||
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
|
||||
return EndBlocks.LACUGROVE.bark.getDefaultState();
|
||||
return EndBlocks.LACUGROVE.bark.defaultBlockState();
|
||||
});
|
||||
|
||||
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.addPostProcess(POST);
|
||||
function.fillRecursive(world, pos);
|
||||
|
||||
|
||||
spline = spline.subList(4, 6);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.defaultBlockState(), pos, REPLACE);
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
int offset = random.nextInt(2);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
double px = pos.getX() + MHelper.randRange(-5, 5, random);
|
||||
|
@ -89,10 +91,11 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
for (int y = top; y >= minY; y--) {
|
||||
mut.setY(y);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.isIn(EndTags.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
|
||||
}
|
||||
else {
|
||||
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.isIn(EndTags.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut,
|
||||
y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -100,25 +103,32 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LACUGROVE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random,
|
||||
OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius)
|
||||
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return random.nextFloat() * 3F - 1.5F;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere)
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (random.nextInt(5) == 0) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockState state = info.getState(dir, 2);
|
||||
if (state.isAir()) {
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
info.setState(EndBlocks.LACUGROVE.bark.getDefaultState());
|
||||
info.setState(EndBlocks.LACUGROVE.bark.defaultBlockState());
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
mut.setX(x + info.getPos().getX());
|
||||
|
@ -132,7 +142,7 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -145,15 +155,16 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
return info.getState();
|
||||
});
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
|
||||
|
||||
if (radius > 5) {
|
||||
int count = (int) (radius * 2.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
|
||||
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1,
|
||||
random.nextGaussian() * 1);
|
||||
boolean place = true;
|
||||
for (Direction d: Direction.values()) {
|
||||
for (Direction d : Direction.values()) {
|
||||
BlockState state = world.getBlockState(p.offset(d));
|
||||
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.isOf(EndBlocks.LACUGROVE_LEAVES)) {
|
||||
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.is(EndBlocks.LACUGROVE_LEAVES)) {
|
||||
place = false;
|
||||
break;
|
||||
}
|
||||
|
@ -163,10 +174,10 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LACUGROVE.bark);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
@ -183,14 +194,15 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.LACUGROVE.isTreeLog(state);
|
||||
};
|
||||
|
||||
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.LACUGROVE.log.getDefaultState();
|
||||
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp())
|
||||
&& EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.LACUGROVE.log.defaultBlockState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -40,14 +40,16 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final List<Vector3f> SPLINE;
|
||||
private static final List<Vector3f> ROOT;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float size = MHelper.randRange(12, 20, random);
|
||||
int count = (int) (size * 0.3F);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
|
||||
|
@ -55,65 +57,74 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.scale(spline, size * MHelper.randRange(0.5F, 1F, random));
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.LUCERNIA.bark.getDefaultState(), pos, REPLACE);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE);
|
||||
Vector3f last = spline.get(spline.size() - 1);
|
||||
float leavesRadius = (size * 0.13F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
leavesBall(world, pos.add(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise, config != null);
|
||||
leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise,
|
||||
config != null);
|
||||
}
|
||||
|
||||
makeRoots(world, pos.add(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
|
||||
|
||||
|
||||
makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise, boolean natural) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LUCERNIA_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6));
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random,
|
||||
OpenSimplexNoise noise, boolean natural) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius)
|
||||
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
|
||||
SDF sub = new SDFScale().setScale(5).setSource(sphere);
|
||||
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
|
||||
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-1.5F, 1.5F, random); }).setSource(sphere);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
for (Direction d1: BlocksHelper.HORIZONTAL) {
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-1.5F, 1.5F, random);
|
||||
}).setSource(sphere);
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
for (Direction d1 : BlocksHelper.HORIZONTAL) {
|
||||
BlockPos p = mut.set(pos).move(Direction.UP).move(d1).toImmutable();
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.getDefaultState());
|
||||
for (Direction d2: BlocksHelper.HORIZONTAL) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.defaultBlockState());
|
||||
for (Direction d2 : BlocksHelper.HORIZONTAL) {
|
||||
mut.set(p).move(Direction.UP).move(d2);
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
BlockState top = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
|
||||
BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.getDefaultState();
|
||||
|
||||
|
||||
BlockState top = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.BOTTOM);
|
||||
BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.defaultBlockState();
|
||||
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (natural && random.nextInt(6) == 0 && info.getStateDown().isAir()) {
|
||||
BlockPos d = info.getPos().down();
|
||||
BlockPos d = info.getPos().below();
|
||||
support.add(d);
|
||||
}
|
||||
if (random.nextInt(15) == 0) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockState state = info.getState(dir, 2);
|
||||
if (state.isAir()) {
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
info.setState(EndBlocks.LUCERNIA.bark.getDefaultState());
|
||||
info.setState(EndBlocks.LUCERNIA.bark.defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
MHelper.shuffle(DIRECTIONS, random);
|
||||
for (Direction d: DIRECTIONS) {
|
||||
for (Direction d : DIRECTIONS) {
|
||||
if (info.getState(d).isAir()) {
|
||||
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (EndBlocks.LUCERNIA.isTreeLog(info.getState())) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
|
@ -128,7 +139,7 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -142,20 +153,19 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
});
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LUCERNIA.bark);
|
||||
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
if (state.isAir() || state.isOf(EndBlocks.LUCERNIA_OUTER_LEAVES)) {
|
||||
if (state.isAir() || state.is(EndBlocks.LUCERNIA_OUTER_LEAVES)) {
|
||||
int count = MHelper.randRange(3, 8, random);
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut.up()).isOf(EndBlocks.LUCERNIA_LEAVES)) {
|
||||
if (world.getBlockState(mut.up()).is(EndBlocks.LUCERNIA_LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
for (int i = 1; i < count; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
if (world.isAir(mut.down())) {
|
||||
if (world.isAir(mut.below())) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, middle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -164,23 +174,23 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random) {
|
||||
int count = (int) (radius * 1.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.getDefaultState(), pos, REPLACE);
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
@ -194,26 +204,17 @@ public class LucerniaFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.LUCERNIA.isTreeLog(state);
|
||||
};
|
||||
|
||||
SPLINE = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.00F, 0.00F),
|
||||
new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F),
|
||||
new Vector3f(0.30F, 0.55F, 0.00F),
|
||||
new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F)
|
||||
);
|
||||
|
||||
ROOT = Lists.newArrayList(
|
||||
new Vector3f(0.1F, 0.70F, 0),
|
||||
new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.20F, 0)
|
||||
);
|
||||
|
||||
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F));
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -41,122 +41,128 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
private static final SDFBinary FUNCTION;
|
||||
private static final SDFTranslate HEAD_POS;
|
||||
private static final SDFFlatWave ROOTS_ROT;
|
||||
|
||||
|
||||
private static final SDFPrimitive CONE1;
|
||||
private static final SDFPrimitive CONE2;
|
||||
private static final SDFPrimitive CONE_GLOW;
|
||||
private static final SDFPrimitive ROOTS;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||
BlockState down = world.getBlockState(blockPos.down());
|
||||
if (!down.isOf(EndBlocks.END_MYCELIUM) && !down.isOf(EndBlocks.END_MOSS)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos,
|
||||
DefaultFeatureConfig featureConfig) {
|
||||
BlockState down = world.getBlockState(blockPos.below());
|
||||
if (!down.is(EndBlocks.END_MYCELIUM) && !down.is(EndBlocks.END_MOSS))
|
||||
return false;
|
||||
|
||||
CONE1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
|
||||
CONE2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
|
||||
CONE_GLOW.setBlock(EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE);
|
||||
ROOTS.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);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
SDF sdf = SplineHelper.buildSDF(spline, 2.1F, 1.5F, (pos) -> {
|
||||
return EndBlocks.MOSSY_GLOWSHROOM.log.getDefaultState();
|
||||
return EndBlocks.MOSSY_GLOWSHROOM.log.defaultBlockState();
|
||||
});
|
||||
Vector3f pos = spline.get(spline.size() - 1);
|
||||
float scale = MHelper.randRange(0.75F, 1.1F, random);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(spline, scale, blockPos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
|
||||
|
||||
|
||||
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
|
||||
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
|
||||
FUNCTION.setSourceA(sdf);
|
||||
|
||||
new SDFScale().setScale(scale)
|
||||
.setSource(FUNCTION)
|
||||
.setReplaceFunction(REPLACE)
|
||||
.addPostProcess((info) -> {
|
||||
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
|
||||
if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true));
|
||||
return info.getState();
|
||||
}
|
||||
else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.getDefaultState());
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
|
||||
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true));
|
||||
return info.getState();
|
||||
}
|
||||
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState());
|
||||
return info.getState();
|
||||
}
|
||||
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
if (info.getState(dir) == AIR) {
|
||||
info.setBlockPos(info.getPos().offset(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, dir));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
|
||||
info.setBlockPos(info.getPos().down(), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
|
||||
new SDFScale().setScale(scale).setSource(FUNCTION).setReplaceFunction(REPLACE).addPostProcess((info) -> {
|
||||
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
|
||||
if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
|
||||
.with(MossyGlowshroomCapBlock.TRANSITION, true));
|
||||
return info.getState();
|
||||
})
|
||||
.fillRecursive(world, blockPos);
|
||||
|
||||
} else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp())
|
||||
|| !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState());
|
||||
return info.getState();
|
||||
}
|
||||
} else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
|
||||
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
|
||||
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
|
||||
.with(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) {
|
||||
if (info.getState(dir) == AIR) {
|
||||
info.setBlockPos(info.getPos().offset(dir),
|
||||
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, dir));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
|
||||
info.setBlockPos(info.getPos().below(),
|
||||
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, blockPos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
SDFCappedCone cone1 = new SDFCappedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
|
||||
SDFCappedCone cone2 = new SDFCappedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F);
|
||||
SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2);
|
||||
SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0).setSource(new SDFScale().setScale(2).setSource(cone2));
|
||||
SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0)
|
||||
.setSource(new SDFScale().setScale(2).setSource(cone2));
|
||||
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);
|
||||
|
||||
|
||||
CONE1 = cone1;
|
||||
CONE2 = cone2;
|
||||
|
||||
|
||||
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);
|
||||
CONE_GLOW = (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.getX(), pos.getZ());
|
||||
float y = pos.getY() + (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist * 0.3F - dist * 0.15F;
|
||||
float y = pos.getY()
|
||||
+ (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist
|
||||
* 0.3F
|
||||
- dist * 0.15F;
|
||||
pos.set(pos.getX(), y, pos.getZ());
|
||||
}).setSource(cones);
|
||||
|
||||
HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
|
||||
|
||||
|
||||
HEAD_POS = (SDFTranslate) new SDFTranslate()
|
||||
.setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
|
||||
|
||||
SDF roots = new SDFSphere().setRadius(4F);
|
||||
ROOTS = (SDFPrimitive) roots;
|
||||
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
|
||||
ROOTS_ROT = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
|
||||
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
|
||||
|
||||
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(4)
|
||||
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
|
||||
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
return true;
|
||||
|
|
|
@ -4,13 +4,13 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -33,71 +33,78 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (world.getBlockState(pos.down()).getBlock() != EndBlocks.CHORUS_NYLIUM) return false;
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (world.getBlockState(pos.below()).getBlock() != EndBlocks.CHORUS_NYLIUM)
|
||||
return false;
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 4);
|
||||
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
|
||||
Vector3f last = spline.get(spline.size() - 1);
|
||||
|
||||
|
||||
int depth = MHelper.floor((size - 10F) * 3F / 10F + 1F);
|
||||
float bsize = (10F - (size - 10F)) / 10F + 1.5F;
|
||||
branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth, world, pos);
|
||||
|
||||
branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random,
|
||||
depth, world, pos);
|
||||
|
||||
SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> {
|
||||
return EndBlocks.PYTHADENDRON.bark.getDefaultState();
|
||||
return EndBlocks.PYTHADENDRON.bark.defaultBlockState();
|
||||
});
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.addPostProcess(POST);
|
||||
function.fillRecursive(world, pos);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void branch(float x, float y, float z, float size, float angle, Random random, int depth, StructureWorldAccess world, BlockPos pos) {
|
||||
if (depth == 0) return;
|
||||
|
||||
|
||||
private void branch(float x, float y, float z, float size, float angle, Random random, int depth,
|
||||
StructureWorldAccess world, BlockPos pos) {
|
||||
if (depth == 0)
|
||||
return;
|
||||
|
||||
float dx = (float) Math.cos(angle) * size * 0.15F;
|
||||
float dz = (float) Math.sin(angle) * size * 0.15F;
|
||||
|
||||
|
||||
float x1 = x + dx;
|
||||
float z1 = z + dz;
|
||||
float x2 = x - dx;
|
||||
float z2 = z - dz;
|
||||
|
||||
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(x, y, z, x1, y, z1, 5);
|
||||
SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4);
|
||||
SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F);
|
||||
Vector3f pos1 = spline.get(spline.size() - 1);
|
||||
|
||||
boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
|
||||
boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos,
|
||||
REPLACE);
|
||||
|
||||
spline = SplineHelper.makeSpline(x, y, z, x2, y, z2, 5);
|
||||
SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4);
|
||||
SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F);
|
||||
Vector3f pos2 = spline.get(spline.size() - 1);
|
||||
|
||||
boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
|
||||
boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos,
|
||||
REPLACE);
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
if (depth < 3) {
|
||||
if (s1) {
|
||||
leavesBall(world, pos.add(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise);
|
||||
leavesBall(world, pos.offset(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise);
|
||||
}
|
||||
if (s2) {
|
||||
leavesBall(world, pos.add(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise);
|
||||
leavesBall(world, pos.offset(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float size1 = size * MHelper.randRange(0.75F, 0.95F, random);
|
||||
float size2 = size * MHelper.randRange(0.75F, 0.95F, random);
|
||||
float angle1 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random);
|
||||
float angle2 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random);
|
||||
|
||||
|
||||
if (s1) {
|
||||
branch(pos1.getX(), pos1.getY(), pos1.getZ(), size1, angle1, random, depth - 1, world, pos);
|
||||
}
|
||||
|
@ -105,25 +112,31 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
branch(pos2.getX(), pos2.getY(), pos2.getZ(), size2, angle2, random, depth - 1, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, Random random, OpenSimplexNoise noise) {
|
||||
float radius = MHelper.randRange(4.5F, 6.5F, random);
|
||||
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6));
|
||||
|
||||
SDF sphere = new SDFSphere().setRadius(radius)
|
||||
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
|
||||
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
Mutable mut = new Mutable();
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return random.nextFloat() * 3F - 1.5F;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere)
|
||||
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (random.nextInt(5) == 0) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockState state = info.getState(dir, 2);
|
||||
if (state.isAir()) {
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
info.setState(EndBlocks.PYTHADENDRON.bark.getDefaultState());
|
||||
info.setState(EndBlocks.PYTHADENDRON.bark.defaultBlockState());
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
mut.setX(x + info.getPos().getX());
|
||||
|
@ -137,7 +150,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -151,7 +164,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
});
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
@ -165,14 +178,15 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.PYTHADENDRON.isTreeLog(state);
|
||||
};
|
||||
|
||||
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp()) && EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.PYTHADENDRON.log.getDefaultState();
|
||||
if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp())
|
||||
&& EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.PYTHADENDRON.log.defaultBlockState();
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -39,14 +39,16 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final List<Vector3f> SPLINE;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
float size = MHelper.randRange(7, 10, random);
|
||||
int count = (int) (size * 0.45F);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
|
||||
|
@ -54,63 +56,72 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.scale(spline, size + MHelper.randRange(0, size * 0.5F, random));
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.TENANEA.bark.getDefaultState(), pos, REPLACE);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.TENANEA.bark.defaultBlockState(), pos, REPLACE);
|
||||
Vector3f last = spline.get(spline.size() - 1);
|
||||
float leavesRadius = (size * 0.3F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F;
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
leavesBall(world, pos.add(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise);
|
||||
leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.TENANEA_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6));
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random,
|
||||
OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius)
|
||||
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
|
||||
SDF sub = new SDFScale().setScale(5).setSource(sphere);
|
||||
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
|
||||
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-1.5F, 1.5F, random); }).setSource(sphere);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
for (Direction d1: BlocksHelper.HORIZONTAL) {
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F;
|
||||
}).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-1.5F, 1.5F, random);
|
||||
}).setSource(sphere);
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
for (Direction d1 : BlocksHelper.HORIZONTAL) {
|
||||
BlockPos p = mut.set(pos).move(Direction.UP).move(d1).toImmutable();
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.getDefaultState());
|
||||
for (Direction d2: BlocksHelper.HORIZONTAL) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.defaultBlockState());
|
||||
for (Direction d2 : BlocksHelper.HORIZONTAL) {
|
||||
mut.set(p).move(Direction.UP).move(d2);
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
BlockState top = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
|
||||
BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.getDefaultState();
|
||||
|
||||
|
||||
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
|
||||
TripleShape.BOTTOM);
|
||||
BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState();
|
||||
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (random.nextInt(6) == 0 && info.getStateDown().isAir()) {
|
||||
BlockPos d = info.getPos().down();
|
||||
BlockPos d = info.getPos().below();
|
||||
support.add(d);
|
||||
}
|
||||
if (random.nextInt(5) == 0) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockState state = info.getState(dir, 2);
|
||||
if (state.isAir()) {
|
||||
return info.getState();
|
||||
}
|
||||
}
|
||||
info.setState(EndBlocks.TENANEA.bark.getDefaultState());
|
||||
info.setState(EndBlocks.TENANEA.bark.defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
MHelper.shuffle(DIRECTIONS, random);
|
||||
for (Direction d: DIRECTIONS) {
|
||||
for (Direction d : DIRECTIONS) {
|
||||
if (info.getState(d).isAir()) {
|
||||
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (EndBlocks.TENANEA.isTreeLog(info.getState())) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
|
@ -125,7 +136,7 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -139,20 +150,19 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
});
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.TENANEA.bark);
|
||||
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
if (state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) {
|
||||
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
|
||||
int count = MHelper.randRange(3, 8, random);
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut.up()).isOf(EndBlocks.TENANEA_LEAVES)) {
|
||||
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
for (int i = 1; i < count; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
if (world.isAir(mut.down())) {
|
||||
if (world.isAir(mut.below())) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, middle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +171,7 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
|
@ -175,18 +185,13 @@ public class TenaneaFeature extends DefaultFeature {
|
|||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.TENANEA.isTreeLog(state);
|
||||
};
|
||||
|
||||
SPLINE = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.00F, 0.00F),
|
||||
new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F),
|
||||
new Vector3f(0.30F, 0.55F, 0.00F),
|
||||
new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F)
|
||||
);
|
||||
|
||||
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -38,77 +38,83 @@ public class UmbrellaTreeFeature extends DefaultFeature {
|
|||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final List<Vector3f> SPLINE;
|
||||
private static final List<Vector3f> ROOT;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
BlockState wood = EndBlocks.UMBRELLA_TREE.bark.getDefaultState();
|
||||
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.getDefaultState().with(UmbrellaTreeMembraneBlock.COLOR, 1);
|
||||
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.getDefaultState().with(UmbrellaTreeMembraneBlock.COLOR, 0);
|
||||
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.getDefaultState().with(UmbrellaTreeClusterBlock.NATURAL, true);
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState wood = EndBlocks.UMBRELLA_TREE.bark.defaultBlockState();
|
||||
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR,
|
||||
1);
|
||||
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR,
|
||||
0);
|
||||
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().with(UmbrellaTreeClusterBlock.NATURAL,
|
||||
true);
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
int count = (int) (size * 0.15F);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
SDF sdf = null;
|
||||
List<Center> centers = Lists.newArrayList();
|
||||
|
||||
|
||||
float scale = 1;
|
||||
if (config != null) {
|
||||
scale = MHelper.randRange(1F, 1.7F, random);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
|
||||
List<Vector3f> spline = SplineHelper.copySpline(SPLINE);
|
||||
float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F;
|
||||
SplineHelper.scale(spline, sizeXZ, sizeXZ * MHelper.randRange(1F, 2F, random), sizeXZ);
|
||||
//SplineHelper.offset(spline, new Vector3f((20 - size) * 0.2F, 0, 0));
|
||||
// SplineHelper.offset(spline, new Vector3f((20 - size) * 0.2F, 0, 0));
|
||||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
|
||||
|
||||
|
||||
if (SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||
float rScale = (scale - 1) * 0.4F + 1;
|
||||
SDF branch = SplineHelper.buildSDF(spline, 1.2F * rScale, 0.8F * rScale, (bpos) -> {
|
||||
return wood;
|
||||
});
|
||||
|
||||
|
||||
Vector3f vec = spline.get(spline.size() - 1);
|
||||
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.4F;
|
||||
|
||||
|
||||
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
|
||||
SDF mem = makeMembrane(world, radius, random, membrane, center);
|
||||
|
||||
|
||||
float px = MHelper.floor(vec.getX()) + 0.5F;
|
||||
float py = MHelper.floor(vec.getY()) + 0.5F;
|
||||
float pz = MHelper.floor(vec.getZ()) + 0.5F;
|
||||
mem = new SDFTranslate().setTranslate(px, py, pz).setSource(mem);
|
||||
sdf = new SDFSmoothUnion().setRadius(2).setSourceA(sdf).setSourceB(mem);
|
||||
centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale), pos.getZ() + (double) (pz * scale), radius * scale));
|
||||
|
||||
centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale),
|
||||
pos.getZ() + (double) (pz * scale), radius * scale));
|
||||
|
||||
vec = spline.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sdf == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (scale > 1) {
|
||||
sdf = new SDFScale().setScale(scale).setSource(sdf);
|
||||
}
|
||||
|
||||
|
||||
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
|
||||
if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp()) && EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.UMBRELLA_TREE.log.getDefaultState();
|
||||
}
|
||||
else if (info.getState().equals(membrane)) {
|
||||
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)) {
|
||||
Center min = centers.get(0);
|
||||
double d = Double.MAX_VALUE;
|
||||
BlockPos bpos = info.getPos();
|
||||
for (Center c: centers) {
|
||||
for (Center c : centers) {
|
||||
double d2 = c.distance(bpos.getX(), bpos.getZ());
|
||||
if (d2 < d) {
|
||||
d = d2;
|
||||
|
@ -116,14 +122,14 @@ public class UmbrellaTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
int color = MHelper.floor(d / min.radius * 7);
|
||||
color = MathHelper.clamp(color, 1, 7);
|
||||
color = Mth.clamp(color, 1, 7);
|
||||
return info.getState().with(UmbrellaTreeMembraneBlock.COLOR, color);
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, pos);
|
||||
makeRoots(world, pos, (size * 0.5F + 3) * scale, random, wood);
|
||||
|
||||
for (Center c: centers) {
|
||||
|
||||
for (Center c : centers) {
|
||||
if (!world.getBlockState(new BlockPos(c.px, c.py, c.pz)).isAir()) {
|
||||
count = MHelper.floor(MHelper.randRange(5F, 10F, random) * scale);
|
||||
float startAngle = random.nextFloat() * MHelper.PI2;
|
||||
|
@ -136,99 +142,93 @@ public class UmbrellaTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) {
|
||||
int count = (int) (radius * 1.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SDF makeMembrane(StructureWorldAccess world, float radius, Random random, BlockState membrane, BlockState center) {
|
||||
|
||||
private SDF makeMembrane(StructureWorldAccess world, float radius, Random random, BlockState membrane,
|
||||
BlockState center) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(membrane);
|
||||
SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
|
||||
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
|
||||
sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere);
|
||||
|
||||
|
||||
float angle = random.nextFloat() * MHelper.PI2;
|
||||
int count = (int) MHelper.randRange(radius, radius * 2, random);
|
||||
if (count < 5) {
|
||||
count = 5;
|
||||
}
|
||||
sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.6F).setSource(sphere);
|
||||
|
||||
|
||||
SDF cent = new SDFSphere().setRadius(2.5F).setBlock(center);
|
||||
sphere = new SDFUnion().setSourceA(sphere).setSourceB(cent);
|
||||
|
||||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
private void makeFruits(StructureWorldAccess world, double px, double py, double pz, BlockState fruit, float scale) {
|
||||
Mutable mut = new Mutable().set(px, py, pz);
|
||||
|
||||
private void makeFruits(StructureWorldAccess world, double px, double py, double pz, BlockState fruit,
|
||||
float scale) {
|
||||
MutableBlockPos mut = new MutableBlockPos().set(px, py, pz);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mut.move(Direction.DOWN);
|
||||
if (world.isAir(mut)) {
|
||||
BlockState state = world.getBlockState(mut.up());
|
||||
if (state.isOf(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.get(UmbrellaTreeMembraneBlock.COLOR) < 2) {
|
||||
if (state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.getValue(UmbrellaTreeMembraneBlock.COLOR) < 2) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, fruit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
SPLINE = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.00F, 0.00F),
|
||||
new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F),
|
||||
new Vector3f(0.30F, 0.55F, 0.00F),
|
||||
new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F)
|
||||
);
|
||||
|
||||
ROOT = Lists.newArrayList(
|
||||
new Vector3f(0.1F, 0.70F, 0),
|
||||
new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.20F, 0)
|
||||
);
|
||||
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F));
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
|
||||
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.isOf(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
|
||||
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private class Center {
|
||||
final double px;
|
||||
final double py;
|
||||
final double pz;
|
||||
final float radius;
|
||||
|
||||
|
||||
Center(double x, double y, double z, float radius) {
|
||||
this.px = x;
|
||||
this.py = y;
|
||||
this.pz = z;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
|
||||
double distance(float x, float z) {
|
||||
return MHelper.length(px - x, pz - z);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue