Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.gen.surfacebuilder.SurfaceConfig;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.sdf.SDF;
@ -31,10 +30,10 @@ public class BiomeIslandFeature extends DefaultFeature {
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
Biome biome = world.getBiome(pos);
SurfaceConfig surfaceConfig = biome.getGenerationSettings().getSurfaceBuilderConfig();
SurfaceBuilderConfiguration surfaceConfig = biome.getGenerationSettings().getSurfaceBuilderConfig();
BlockState topMaterial = surfaceConfig.getTopMaterial();
if (BlocksHelper.isFluid(topMaterial)) {
topBlock = ((TernarySurfaceConfig) surfaceConfig).getUnderwaterMaterial();
topBlock = ((SurfaceBuilderBaseConfiguration) surfaceConfig).getUnderwaterMaterial();
} else {
topBlock = topMaterial;
}
@ -55,13 +54,12 @@ public class BiomeIslandFeature extends DefaultFeature {
});
sdfCone = new SDFTranslate().setTranslate(0, -2, 0).setSource(sdfCone);
sdfCone = new SDFDisplacement().setFunction(pos -> {
float deltaX = Math.abs(pos.getX());
float deltaY = Math.abs(pos.getY());
float deltaZ = Math.abs(pos.getZ());
float deltaX = Math.abs(pos.x());
float deltaY = Math.abs(pos.y());
float deltaZ = Math.abs(pos.z());
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());
return (float) simplexNoise.eval(CENTER.getX() + pos.x(), CENTER.getY() + pos.y(), CENTER.getZ() + pos.z());
}).setSource(sdfCone)
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
return sdfCone;

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -11,25 +10,24 @@ import ru.betterend.util.MHelper;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
public BlueVineFeature() {
super(5);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F
+ random.nextFloat() * 0.4F;
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);
return EndBlocks.BLUE_VINE_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (small) {
BlocksHelper.setWithoutUpdate(world, blockPos,
EndBlocks.BLUE_VINE_SEED.defaultBlockState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.defaultBlockState().setValue(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
}
else {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED);
seed.growAdult(world, random, blockPos);
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
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;
@ -17,11 +16,11 @@ public class CavePlantFeature extends FullHeightScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canPlaceAt(world.getBlockState(blockPos), world, blockPos);
return plant.canSurvive(world.getBlockState(blockPos), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
@ -15,17 +14,17 @@ public class CavePumpkinFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos)
|| !world.isAir(pos.below())) {
if (!world.getBlockState(pos.above()).is(EndTags.GEN_TERRAIN) || !world.isEmptyBlock(pos)
|| !world.isEmptyBlock(pos.below())) {
return false;
}
int age = random.nextInt(4);
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().with(BlockProperties.AGE, age));
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().setValue(BlockProperties.AGE, age));
if (age > 1) {
BlocksHelper.setWithoutUpdate(world, pos.below(),
EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, age < 3));
EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(BlockProperties.SMALL, age < 3));
}
return true;

View file

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

View file

@ -1,25 +1,24 @@
package ru.betterend.world.features;
import java.util.Random;
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;
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.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockBox;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.level.material.Material;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -28,13 +27,12 @@ import ru.betterend.util.StructureHelper;
public class CrashedShipFeature extends NBTStructureFeature {
private static final StructureProcessor REPLACER;
private static final String STRUCTURE_PATH = "/data/minecraft/structures/end_city/ship.nbt";
private Structure structure;
private StructureTemplate structure;
@Override
protected Structure getStructure(WorldGenLevel world, BlockPos pos, Random random) {
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
if (structure == null) {
structure = world.toServerWorld().getStructureManager()
.getStructureOrBlank(new ResourceLocation("end_city/ship"));
structure = world.getLevel().getStructureManager().getOrCreate(new ResourceLocation("end_city/ship"));
if (structure == null) {
structure = StructureHelper.readStructure(STRUCTURE_PATH);
}
@ -49,21 +47,21 @@ public class CrashedShipFeature extends NBTStructureFeature {
if (x * x + z * z < 3600) {
return false;
}
return pos.getY() > 5 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
return pos.getY() > 5 && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
return Rotation.random(random);
return Rotation.getRandom(random);
}
@Override
protected BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return BlockMirror.values()[random.nextInt(3)];
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random) {
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
int min = structure.getSize().getY() >> 3;
int max = structure.getSize().getY() >> 2;
return -MHelper.randRange(min, max, random);
@ -79,45 +77,44 @@ public class CrashedShipFeature extends NBTStructureFeature {
NoneFeatureConfiguration featureConfig) {
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center);
BlockBox bounds = makeBox(center);
BoundingBox bounds = makeBox(center);
if (!canSpawn(world, center, random)) {
return false;
}
Structure structure = getStructure(world, center, random);
StructureTemplate structure = getStructure(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);
Mirror mirror = getMirror(world, center, random);
BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
BlockBox structB = structure.calculateBoundingBox(placementData, center);
BoundingBox structB = structure.getBoundingBox(placementData, center);
bounds = StructureHelper.intersectBoxes(bounds, structB);
addStructureData(placementData);
structure.place(world, center, placementData.setBoundingBox(bounds), random);
structure.placeInWorldChunk(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.x0, bounds.y0, bounds.z0),
new BlockPos(bounds.x1, bounds.y1, bounds.z1));
return true;
}
@Override
protected void addStructureData(StructurePlacementData data) {
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER)
.setIgnoreEntities(true);
protected void addStructureData(StructurePlaceSettings data) {
data.addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR).addProcessor(REPLACER).setIgnoreEntities(true);
}
static {
REPLACER = new StructureProcessor() {
@Override
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlacementData structurePlacementData) {
StructurePlaceSettings structurePlacementData) {
BlockState state = structureBlockInfo2.state;
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);

View file

@ -1,42 +1,42 @@
package ru.betterend.world.features;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
public abstract class DefaultFeature extends Feature<NoneFeatureConfiguration> {
protected static final BlockState AIR = Blocks.AIR.defaultBlockState();
protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
public DefaultFeature() {
super(NoneFeatureConfiguration.CODEC);
}
public static int getYOnSurface(WorldGenLevel world, int x, int z) {
return world.getHeight(Types.WORLD_SURFACE, x, z);
}
public static int getYOnSurfaceWG(WorldGenLevel world, int x, int z) {
return world.getHeight(Types.WORLD_SURFACE_WG, x, z);
}
public static BlockPos getPosOnSurface(WorldGenLevel world, BlockPos pos) {
return world.getHeightmapPos(Types.WORLD_SURFACE, pos);
}
public static BlockPos getPosOnSurfaceWG(WorldGenLevel world, BlockPos pos) {
return world.getHeightmapPos(Types.WORLD_SURFACE_WG, pos);
}
public static BlockPos getPosOnSurfaceRaycast(WorldGenLevel world, BlockPos pos) {
return getPosOnSurfaceRaycast(world, pos, 256);
}
public static BlockPos getPosOnSurfaceRaycast(WorldGenLevel world, BlockPos pos, int dist) {
int h = BlocksHelper.downRay(world, pos, dist);
return pos.below(h);

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -14,29 +13,29 @@ public class DoublePlantFeature extends ScatterFeature {
private final Block smallPlant;
private final Block largePlant;
private Block plant;
public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) {
super(radius);
this.smallPlant = smallPlant;
this.largePlant = largePlant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F
+ random.nextFloat() * 0.4F;
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.defaultBlockState(), world, blockPos);
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

@ -1,23 +1,23 @@
package ru.betterend.world.features;
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.resources.ResourceLocation;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.core.Registry;
import net.minecraft.world.gen.CountConfig;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.Features;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeatures;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeatureConfig;
import net.minecraft.world.level.levelgen.feature.OreFeatureConfig;
import net.minecraft.world.level.levelgen.feature.configurations.CountConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.ChanceDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.FeatureDecorator;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.complex.StoneMaterial;
import ru.betterend.world.features.terrain.OreLayerFeature;
@ -25,117 +25,100 @@ import ru.betterend.world.features.terrain.OreLayerFeature;
public class EndFeature {
private Feature<?> feature;
private ConfiguredFeature<?, ?> featureConfigured;
private GenerationStep.Feature featureStep;
protected EndFeature() {
}
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature,
GenerationStep.Feature featureStep) {
private GenerationStep.Decoration featureStep;
protected EndFeature() {}
public EndFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Decoration featureStep) {
this.featureStep = featureStep;
this.feature = feature;
this.featureConfigured = configuredFeature;
}
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, GenerationStep.Feature featureStep,
ConfiguredFeature<?, ?> configuredFeature) {
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, GenerationStep.Decoration 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<NoneFeatureConfiguration> feature) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
this.featureStep = GenerationStep.Decoration.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.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(100))));
}
public EndFeature(String name, Feature<NoneFeatureConfiguration> feature, int density) {
ResourceLocation id = BetterEnd.makeID(name);
this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION;
this.featureStep = GenerationStep.Decoration.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.configured(FeatureConfiguration.NONE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).countRandom(density));
}
public static EndFeature makeRawGenFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public static EndFeature makeLakeFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.LAKES, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.WATER_LAKE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.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.defaultBlockState(), veinSize);
RangeDecoratorConfig rangeDecorator = new RangeDecoratorConfig(offset, minY, maxY);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configure(featureConfig)
.decorate(Decorator.RANGE.configure(rangeDecorator)).spreadHorizontally().repeat(veins);
OreConfiguration featureConfig = new OreConfiguration(new BlockMatchTest(Blocks.END_STONE), blockOre.defaultBlockState(), veinSize);
RangeDecoratorConfiguration rangeDecorator = new RangeDecoratorConfiguration(offset, minY, maxY);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig)
.decorated(FeatureDecorator.RANGE.configured(rangeDecorator))
.squared()
.count(veins);
newFeature.feature = Feature.ORE;
newFeature.featureStep = GenerationStep.Feature.UNDERGROUND_ORES;
newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name),
oreFeature);
newFeature.featureStep = GenerationStep.Decoration.UNDERGROUND_ORES;
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)));
return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeLayerFeature(String name, Block block, float radius, int minY, int maxY, int 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);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY,
int 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);
ConfiguredFeature<?, ?> configured = layer.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(count)));
return new EndFeature(name, layer, GenerationStep.Decoration.UNDERGROUND_ORES, configured);
}
public static EndFeature makeChunkFeature(String name, Feature<NoneFeatureConfiguration> feature) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(1)));
return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(1)));
return new EndFeature(name, feature, GenerationStep.Decoration.LOCAL_MODIFICATIONS, configured);
}
public static EndFeature makeChansedFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.SURFACE_STRUCTURES, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.SURFACE_STRUCTURES, configured);
}
public static EndFeature makeCountRawFeature(String name, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.COUNT.configure(new CountConfig(chance)));
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(chance)));
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public static EndFeature makeFeatureConfigured(String name, Feature<NoneFeatureConfiguration> feature) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT);
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE);
return new EndFeature(name, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
}
public Feature<?> getFeature() {
return feature;
}
@ -144,7 +127,7 @@ public class EndFeature {
return featureConfigured;
}
public GenerationStep.Feature getFeatureStep() {
public GenerationStep.Decoration getFeatureStep() {
return featureStep;
}
}

View file

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

View file

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

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.EndLotusLeafBlock;
import ru.betterend.registry.EndBlocks;
@ -19,48 +18,46 @@ public class EndLotusLeafFeature extends ScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (canGenerate(world, blockPos)) {
generateLeaf(world, blockPos);
}
}
@Override
protected int getChance() {
return 15;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurface(world, pos);
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.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));
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i ++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2),
leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY());
int count = 0;
for (int x = -1; x < 2; x++) {
for (int x = -1; x < 2; x ++) {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z++) {
for (int z = -1; z < 2; z ++) {
p.setZ(pos.getZ() + z);
if (world.isAir(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count++;
if (world.isEmptyBlock(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count ++;
}
}
return count == 9;
@ -68,6 +65,6 @@ public class EndLotusLeafFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.isAir(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
return world.isEmptyBlock(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.registry.EndBlocks;
@ -19,13 +18,13 @@ public class FilaluxFeature extends SkyScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
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) {
BlocksHelper.setWithoutUpdate(world, blockPos.offset(dir), wings.with(Properties.FACING, dir));
BlocksHelper.setWithoutUpdate(world, blockPos.above(), wings.setValue(BlockStateProperties.FACING, Direction.UP));
for (Direction dir: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, blockPos.relative(dir), wings.setValue(BlockStateProperties.FACING, dir));
}
int length = MHelper.randRange(1, 3, random);
for (int i = 1; i <= length; i++) {
@ -33,7 +32,7 @@ public class FilaluxFeature extends SkyScatterFeature {
if (i > 1) {
shape = i == length ? TripleShape.BOTTOM : TripleShape.MIDDLE;
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), vine.with(BlockProperties.TRIPLE_SHAPE, shape));
BlocksHelper.setWithoutUpdate(world, blockPos.below(i), vine.setValue(BlockProperties.TRIPLE_SHAPE, shape));
}
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,12 +21,12 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.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());

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -14,15 +13,15 @@ public class GlowPillarFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.GLOWING_PILLAR_SEED.canPlaceAt(AIR, world, blockPos);
return EndBlocks.GLOWING_PILLAR_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 10;

View file

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

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,16 +21,16 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.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--) {
POS.set(center.getX(), y, center.getZ());
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.up()).isAir()) {
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.above()).isAir()) {
float r = MHelper.randRange(radius * 0.5F, radius, random);
int count = MHelper.floor(r * r * MHelper.randRange(0.5F, 1.5F, random));
for (int i = 0; i < count; i++) {

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -14,15 +13,15 @@ public class LanceleafFeature extends ScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.LANCELEAF_SEED.canPlaceAt(AIR, world, blockPos);
return EndBlocks.LANCELEAF_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 5;

View file

@ -2,26 +2,25 @@ package ru.betterend.world.features;
import java.util.List;
import java.util.Random;
import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import ru.betterend.registry.EndTags;
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(WorldGenLevel world, BlockPos pos, Random random) {
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
selected = list.get(random.nextInt(list.size()));
return selected.getStructure();
}
@ -30,21 +29,21 @@ public class ListFeature extends NBTStructureFeature {
protected boolean canSpawn(WorldGenLevel 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.below()).isIn(EndTags.GEN_TERRAIN);
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
return Rotation.random(random);
return Rotation.getRandom(random);
}
@Override
protected BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return BlockMirror.values()[random.nextInt(3)];
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random) {
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
return selected.offsetY;
}
@ -52,25 +51,24 @@ public class ListFeature extends NBTStructureFeature {
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) {
return selected.terrainMerge;
}
@Override
protected void addStructureData(StructurePlacementData data) {
}
protected void addStructureData(StructurePlaceSettings data) {}
public static final class StructureInfo {
public final TerrainMerge terrainMerge;
public final String structurePath;
public final int offsetY;
private Structure structure;
private StructureTemplate structure;
public StructureInfo(String structurePath, int offsetY, TerrainMerge terrainMerge) {
this.terrainMerge = terrainMerge;
this.structurePath = structurePath;
this.offsetY = offsetY;
}
public Structure getStructure() {
public StructureTemplate getStructure() {
if (structure == null) {
structure = StructureHelper.readStructure(structurePath);
}

View file

@ -2,34 +2,33 @@ package ru.betterend.world.features;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
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);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.MENGER_SPONGE_WET);
if (random.nextBoolean()) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos pos = blockPos.offset(dir);
for (Direction dir: BlocksHelper.DIRECTIONS) {
BlockPos pos = blockPos.relative(dir);
if (REPLACE.apply(world.getBlockState(pos))) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.MENGER_SPONGE_WET);
}
}
}
}
static {
REPLACE = (state) -> {
if (state.is(EndBlocks.END_LOTUS_STEM)) {

View file

@ -3,25 +3,24 @@ package ru.betterend.world.features;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
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.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockBox;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.gen.surfacebuilder.SurfaceConfig;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -30,19 +29,19 @@ import ru.betterend.world.processors.DestructionStructureProcessor;
public abstract class NBTStructureFeature extends DefaultFeature {
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
protected abstract Structure getStructure(WorldGenLevel world, BlockPos pos, Random random);
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random);
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random);
protected abstract BlockMirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
protected abstract int getYOffset(Structure structure, WorldGenLevel world, BlockPos pos, Random random);
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random);
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random);
protected abstract void addStructureData(StructurePlacementData data);
protected abstract void addStructureData(StructurePlaceSettings data);
protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
Biome biome = world.getBiome(center);
@ -85,18 +84,18 @@ public abstract class NBTStructureFeature extends DefaultFeature {
}
int posY = center.getY() + 1;
Structure structure = getStructure(world, center, random);
StructureTemplate structure = getStructure(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);
Mirror mirror = getMirror(world, center, random);
BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
BlockBox bounds = makeBox(center);
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror)
BoundingBox bounds = makeBox(center);
StructurePlaceSettings placementData = new StructurePlaceSettings().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);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
structure.placeInWorldChunk(world, center, placementData, random);
TerrainMerge merge = getTerrainMerge(world, center, random);
int x1 = center.getX();
@ -125,24 +124,24 @@ public abstract class NBTStructureFeature extends DefaultFeature {
mut.setZ(z);
mut.setY(surfMax);
BlockState state = world.getBlockState(mut);
if (!state.isIn(EndTags.GEN_TERRAIN) && state.isSideSolidFullSquare(world, mut, Direction.DOWN)) {
if (!state.is(EndTags.GEN_TERRAIN) && state.isFaceSturdy(world, mut, Direction.DOWN)) {
for (int i = 0; i < 10; i++) {
mut.setY(mut.getY() - 1);
BlockState stateSt = world.getBlockState(mut);
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
if (!stateSt.is(EndTags.GEN_TERRAIN)) {
if (merge == TerrainMerge.SURFACE) {
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings()
.getSurfaceBuilderConfig();
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
BlocksHelper.setWithoutUpdate(world, mut, top);
} else {
BlocksHelper.setWithoutUpdate(world, mut, state);
}
} else {
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
if (stateSt.is(EndTags.END_GROUND) && state.getMaterial().isSolidBlocking()) {
if (merge == TerrainMerge.SURFACE) {
SurfaceConfig config = world.getBiome(mut).getGenerationSettings()
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings()
.getSurfaceBuilderConfig();
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
} else {
@ -162,15 +161,15 @@ public abstract class NBTStructureFeature extends DefaultFeature {
return true;
}
protected BlockBox makeBox(BlockPos pos) {
protected BoundingBox makeBox(BlockPos pos) {
int sx = ((pos.getX() >> 4) << 4) - 16;
int sz = ((pos.getZ() >> 4) << 4) - 16;
int ex = sx + 47;
int ez = sz + 47;
return BlockBox.create(sx, 0, sz, ex, 255, ez);
return BoundingBox.createProper(sx, 0, sz, ex, 255, ez);
}
protected static Structure readStructure(ResourceLocation resource) {
protected static StructureTemplate readStructure(ResourceLocation resource) {
String ns = resource.getNamespace();
String nm = resource.getPath();
@ -185,11 +184,11 @@ public abstract class NBTStructureFeature extends DefaultFeature {
return null;
}
private static Structure readStructureFromStream(InputStream stream) throws IOException {
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
Structure template = new Structure();
template.fromTag(nbttagcompound);
StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound);
return template;
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -31,15 +30,16 @@ public class NeonCactusFeature extends DefaultFeature {
break;
}
int size = (h - i) >> 2;
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, Direction.UP));
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size))
.setValue(BlockStateProperties.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.getClockWise();
int bsize = i > ((h << 1) / 3) ? 0 : size > 1 ? 1 : size;
branch(world, mut.offset(dir2), dir2, random, length, bsize);
branch(world, mut.relative(dir2), dir2, random, length, bsize);
}
}
mut.move(Direction.UP);
@ -56,8 +56,9 @@ public class NeonCactusFeature extends DefaultFeature {
if (!world.getBlockState(mut).getMaterial().isReplaceable()) {
return;
}
BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState()
.with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, dir));
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.NEON_CACTUS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, getBySize(size))
.setValue(BlockStateProperties.FACING, dir));
if (i == rotIndex) {
dir = Direction.UP;
size--;
@ -65,7 +66,7 @@ public class NeonCactusFeature extends DefaultFeature {
if (i > 1 && i < (length - 1) && random.nextBoolean()) {
Direction dir2 = dir == Direction.UP ? hor : Direction.UP;
hor = hor.getClockWise();
branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random),
branch(world, mut.relative(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random),
size > 0 ? size - 1 : size);
}
mut.move(dir);

View file

@ -1,7 +1,6 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
@ -22,7 +21,7 @@ public abstract class ScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract void place(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurfaceWG(world, pos);
@ -31,7 +30,7 @@ public abstract class ScatterFeature extends DefaultFeature {
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
if (pos.getY() < 5) {
return false;
} else if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
} else if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return false;
}
return true;

View file

@ -1,16 +1,15 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
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.tags.BlockTags;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.registry.EndBlocks;
@ -20,12 +19,12 @@ public class SilkMothNestFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
BlockState state = world.getBlockState(pos.up());
if (state.isIn(BlockTags.LEAVES) || state.isIn(BlockTags.LOGS)) {
BlockState state = world.getBlockState(pos.above());
if (state.is(BlockTags.LEAVES) || state.is(BlockTags.LOGS)) {
state = world.getBlockState(pos);
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.below())) {
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isEmptyBlock(pos.below())) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (world.getBlockState(pos.below().offset(dir)).getMaterial().blocksMovement()) {
if (world.getBlockState(pos.below().relative(dir)).getMaterial().blocksMotion()) {
return false;
}
return true;
@ -38,7 +37,7 @@ public class SilkMothNestFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());
int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY);
POS.set(center);
for (int y = maxY; y > minY; y--) {
@ -46,10 +45,10 @@ public class SilkMothNestFeature extends DefaultFeature {
if (canGenerate(world, POS)) {
Direction dir = BlocksHelper.randomHorizontal(random);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false));
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir).setValue(BlockProperties.ACTIVE, false));
POS.setY(y - 1);
BlocksHelper.setWithoutUpdate(world, POS,
EndBlocks.SILK_MOTH_NEST.defaultBlockState().with(Properties.HORIZONTAL_FACING, dir));
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir));
return true;
}
}

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
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;
@ -21,21 +20,21 @@ public class SingleInvertedScatterFeature extends InvertedScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
if (!world.isAir(blockPos)) {
if (!world.isEmptyBlock(blockPos)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, Direction.DOWN);
state = state.setValue(BlockStateProperties.FACING, Direction.DOWN);
}
return state.canPlaceAt(world, blockPos);
return state.canSurvive(world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlockState state = block.defaultBlockState();
if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, Direction.DOWN);
state = state.setValue(BlockStateProperties.FACING, Direction.DOWN);
}
BlocksHelper.setWithoutUpdate(world, blockPos, state);
}

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.blocks.basis.EndCropBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
@ -15,55 +14,58 @@ public class SinglePlantFeature extends ScatterFeature {
private final Block plant;
private final boolean rawHeightmap;
private final int chance;
public SinglePlantFeature(Block plant, int radius) {
this(plant, radius, true, 1);
}
public SinglePlantFeature(Block plant, int radius, int chance) {
this(plant, radius, true, chance);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap) {
this(plant, radius, rawHeightmap, 1);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap, int chance) {
super(radius);
this.plant = plant;
this.rawHeightmap = rawHeightmap;
this.chance = chance;
}
protected int getChance() {
return chance;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(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.defaultBlockState().with(EndCropBlock.AGE, 3);
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else if (plant instanceof EndCropBlock) {
BlockState state = plant.defaultBlockState().setValue(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.defaultBlockState().with(EndPlantWithAgeBlock.AGE, age);
BlockState state = plant.defaultBlockState().setValue(EndPlantWithAgeBlock.AGE, age);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

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

View file

@ -1,35 +1,35 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import 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(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.defaultBlockState(), world, blockPos);
return super.canSpawn(world, blockPos) && plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof DoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState state = plant.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
} else {
BlocksHelper.setWithoutUpdate(world, blockPos.above(), state.setValue(DoublePlantBlock.TOP, true));
}
else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
}
}

View file

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

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.VineBlock;
@ -15,7 +14,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;
@ -30,7 +29,7 @@ public class VineFeature extends InvertedScatterFeature {
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
int h = BlocksHelper.downRay(world, blockPos, random.nextInt(maxLength)) - 1;
if (h > 2) {
BlockState top = getTopState();
@ -38,32 +37,33 @@ public class VineFeature extends InvertedScatterFeature {
BlockState bottom = getBottomState();
BlocksHelper.setWithoutUpdate(world, blockPos, top);
for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), middle);
BlocksHelper.setWithoutUpdate(world, blockPos.below(i), middle);
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), bottom);
BlocksHelper.setWithoutUpdate(world, blockPos.below(h), bottom);
}
}
private boolean canPlaceBlock(BlockState state, WorldGenLevel world, BlockPos blockPos) {
if (vine) {
return ((VineBlock) vineBlock).canGenerate(state, world, blockPos);
} else {
return vineBlock.canPlaceAt(state, world, blockPos);
}
else {
return vineBlock.canSurvive(state, world, blockPos);
}
}
private BlockState getTopState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
}
private BlockState getMiggleState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
}
private BlockState getBottomState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
}
}

View file

@ -1,20 +1,19 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.blocks.basis.EndWallPlantBlock;
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,22 +22,24 @@ public class WallPlantFeature extends WallScatterFeature {
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
if (block instanceof EndWallPlantBlock) {
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);
BlockState state = block.defaultBlockState().setValue(EndWallPlantBlock.FACING, dir);
return block.canSurvive(state, world, pos);
}
return block.canPlaceAt(block.defaultBlockState(), world, pos);
else if (block instanceof AttachedBlock) {
BlockState state = block.defaultBlockState().setValue(BlockStateProperties.FACING, dir);
return block.canSurvive(state, world, pos);
}
return block.canSurvive(block.defaultBlockState(), world, pos);
}
@Override
public void place(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
public void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockState state = block.defaultBlockState();
if (block instanceof EndWallPlantBlock) {
state = state.with(EndWallPlantBlock.FACING, dir);
} else if (block instanceof AttachedBlock) {
state = state.with(Properties.FACING, dir);
state = state.setValue(EndWallPlantBlock.FACING, dir);
}
else if (block instanceof AttachedBlock) {
state = state.setValue(BlockStateProperties.FACING, dir);
}
BlocksHelper.setWithoutUpdate(world, pos, state);
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
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.tags.BlockTags;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class WallPlantOnLogFeature extends WallPlantFeature {
public WallPlantOnLogFeature(Block block, int radius) {
@ -18,6 +17,6 @@ public class WallPlantOnLogFeature extends WallPlantFeature {
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockPos blockPos = pos.relative(dir.getOpposite());
BlockState blockState = world.getBlockState(blockPos);
return blockState.isIn(BlockTags.LOGS);
return blockState.is(BlockTags.LOGS);
}
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Heightmap;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -22,12 +21,12 @@ public abstract class WallScatterFeature extends DefaultFeature {
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
public abstract void place(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
public abstract void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
NoneFeatureConfiguration featureConfig) {
int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ());
int maxY = world.getHeight(Heightmap.Types.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;
@ -41,7 +40,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
mut.setY(py + y);
for (int z = -radius; z <= radius; z++) {
mut.setZ(center.getZ() + z);
if (random.nextInt(4) == 0 && world.isAir(mut)) {
if (random.nextInt(4) == 0 && world.isEmptyBlock(mut)) {
shuffle(random);
for (Direction dir : DIR) {
if (canGenerate(world, random, mut, dir)) {

View file

@ -2,16 +2,15 @@ package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,8 +36,8 @@ public class BushFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND)
&& !world.getBlockState(pos.above()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -56,9 +55,9 @@ public class BushFeature extends DefaultFeature {
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -69,9 +68,10 @@ public class BushFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}

View file

@ -2,17 +2,16 @@ package ru.betterend.world.features.bushes;
import java.util.Random;
import java.util.function.Function;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -41,8 +40,8 @@ public class BushWithOuterFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)
&& !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND)
&& !world.getBlockState(pos.above()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -60,9 +59,9 @@ public class BushWithOuterFeature extends DefaultFeature {
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -73,8 +72,8 @@ public class BushWithOuterFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction dir : DIRECTIONS) {
if (info.getState(dir).isAir()) {
info.setBlockPos(info.getPos().offset(dir),
outer_leaves.defaultBlockState().with(Properties.FACING, dir));
info.setBlockPos(info.getPos().relative(dir),
outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
}
}
}
@ -84,9 +83,10 @@ public class BushWithOuterFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
} else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -21,27 +20,27 @@ public class LargeAmaranitaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(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);
if (!world.isAir(mut)) {
if (!world.isEmptyBlock(mut)) {
return false;
}
}
mut.set(pos);
BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.defaultBlockState();
BlocksHelper.setWithUpdate(world, mut, state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithUpdate(world, mut, state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
if (height > 2) {
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
return true;
}

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.bushes;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties.LumecornShape;
@ -21,28 +20,28 @@ public class Lumecorn extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
int height = MHelper.randRange(4, 7, random);
MutableBlockPos mut = new MutableBlockPos().set(pos);
for (int i = 1; i < height; i++) {
mut.move(Direction.UP);
if (!world.isAir(mut)) {
if (!world.isEmptyBlock(mut)) {
return false;
}
}
mut.set(pos);
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_TOP_MIDDLE);
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_MIDDLE);
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE,
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_BOTTOM);
BlockState top = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
BlockState top = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
if (height == 4) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
EndBlocks.LUMECORN.defaultBlockState().setValue(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);
@ -50,12 +49,12 @@ public class Lumecorn extends DefaultFeature {
}
if (random.nextBoolean()) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
} else {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
height--;
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.bushes;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.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.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -41,7 +39,7 @@ public class TenaneaBushFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
@ -61,7 +59,7 @@ public class TenaneaBushFeature extends DefaultFeature {
List<BlockPos> support = Lists.newArrayList();
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getPos().getManhattanDistance(pos);
int distance = info.getPos().distManhattan(pos);
if (distance < 7) {
if (random.nextInt(4) == 0 && info.getStateDown().isAir()) {
BlockPos d = info.getPos().below();
@ -71,12 +69,12 @@ public class TenaneaBushFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d),
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d),
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().setValue(FurBlock.FACING, d));
}
}
return info.getState().with(LeavesBlock.DISTANCE, distance);
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
}
@ -88,28 +86,28 @@ public class TenaneaBushFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, stem);
for (Direction d : Direction.values()) {
BlockPos p = pos.relative(d);
if (world.isAir(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves.with(LeavesBlock.DISTANCE, 1));
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves.setValue(LeavesBlock.DISTANCE, 1));
}
}
MutableBlockPos mut = new MutableBlockPos();
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
support.forEach((bpos) -> {
BlockState state = world.getBlockState(bpos);
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
if (world.getBlockState(mut.above()).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.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,7 +36,7 @@ public class BigAuroraCrystalFeature extends DefaultFeature {
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)
return bState.getMaterial().isReplaceable() || bState.is(EndTags.GEN_TERRAIN)
|| bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
});
prism.fillRecursive(world, pos);

View file

@ -1,16 +1,15 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
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.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -37,22 +36,22 @@ public class EndLakeFeature extends DefaultFeature {
int waterLevel = blockPos.getY();
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).up(10), 20);
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).above(10), 20);
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);
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).above(10), 20);
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);
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).above(10), 20);
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);
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5)
return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
@ -116,11 +115,11 @@ public class EndLakeFeature extends DefaultFeature {
r *= r;
if (x2 + z2 <= r) {
state = world.getBlockState(POS);
if (state.isIn(EndTags.GEN_TERRAIN)) {
if (state.is(EndTags.GEN_TERRAIN)) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
pos = POS.below();
if (world.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos).is(EndTags.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig()
.getTopMaterial();
if (y > waterLevel + 1)
@ -165,24 +164,24 @@ public class EndLakeFeature extends DefaultFeature {
if (y2 + x2 + z2 <= r) {
state = world.getBlockState(POS);
if (canReplace(state)) {
state = world.getBlockState(POS.up());
state = world.getBlockState(POS.above());
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
BlocksHelper.setWithoutUpdate(world, POS, state);
}
pos = POS.below();
if (world.getBlockState(pos).getBlock().isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos).getBlock().is(EndTags.GEN_TERRAIN)) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
}
pos = POS.up();
pos = POS.above();
while (canReplace(state = world.getBlockState(pos)) && !state.isAir()
&& state.getFluidState().isEmpty()) {
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
pos = pos.up();
pos = pos.above();
}
}
// Make border
else if (y < waterLevel && y2 + x2 + z2 <= rb) {
if (world.isAir(POS.up())) {
if (world.isEmptyBlock(POS.above())) {
state = world.getBiome(POS).getGenerationSettings().getSurfaceBuilderConfig()
.getTopMaterial();
BlocksHelper.setWithoutUpdate(world, POS,
@ -206,9 +205,8 @@ public class EndLakeFeature extends DefaultFeature {
}
private boolean canReplace(BlockState state) {
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);
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST)
|| state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT)
|| state.getMaterial().equals(Material.CORAL);
}
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -27,7 +26,7 @@ public class FallenPillarFeature extends DefaultFeature {
NoneFeatureConfiguration 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)) {
if (!world.getBlockState(pos.below(5)).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -51,7 +50,7 @@ public class FallenPillarFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);

View file

@ -2,15 +2,13 @@ package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
@ -50,7 +48,7 @@ public class FloatingSpireFeature extends SpireFeature {
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (info.getStateUp().isAir()) {
if (random.nextInt(16) == 0) {
support.add(info.getPos().up());
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {

View file

@ -1,20 +1,19 @@
package ru.betterend.world.features.terrain;
import com.mojang.math.Vector3f;
import java.util.Random;
import java.util.function.Function;
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 com.mojang.math.Vector3f;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.HydrothermalVentBlock;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
@ -56,7 +55,7 @@ public class GeyserFeature extends DefaultFeature {
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) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -107,7 +106,7 @@ public class GeyserFeature extends DefaultFeature {
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(cut);
bowl = new SDFTranslate().setTranslate(radius, py - radius, 0).setSource(bowl);
bowl = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, i * 4F).setSource(bowl);
bowl = new SDFRotation().setRotation(Vector3f.YP, i * 4F).setSource(bowl);
sdf = new SDFUnion().setSourceA(sdf).setSourceB(bowl);
}
sdf.setReplaceFunction(REPLACE2).fillRecursive(world, pos);
@ -165,7 +164,7 @@ public class GeyserFeature extends DefaultFeature {
for (int i = 0; i < count; i++) {
BlocksHelper.setWithoutUpdate(world, mut, WATER);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER);
BlocksHelper.setWithoutUpdate(world, mut.relative(dir), WATER);
}
mut.setY(mut.getY() + 1);
}
@ -177,24 +176,25 @@ public class GeyserFeature extends DefaultFeature {
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).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);
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.with(HorizontalFacingBlock.FACING, dir));
.setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
@ -219,12 +219,12 @@ public class GeyserFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN)) {
if (state.is(EndTags.GEN_TERRAIN)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED,
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
@ -250,11 +250,11 @@ public class GeyserFeature extends DefaultFeature {
static {
REPLACE1 = (state) -> {
return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN));
return state.isAir() || (state.is(EndTags.GEN_TERRAIN));
};
REPLACE2 = (state) -> {
if (state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
if (state.is(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|| state.is(EndBlocks.SULPHUR_CRYSTAL)) {
return true;
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import com.mojang.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndBlocks;
@ -45,12 +44,12 @@ public class IceStarFeature extends DefaultFeature {
for (Vector3f point : points) {
SDF rotated = spike;
point = MHelper.normalize(point);
float angle = MHelper.angle(Vector3f.POSITIVE_Y, point);
float angle = MHelper.angle(Vector3f.YP, point);
if (angle > 0.01F && angle < 3.14F) {
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.POSITIVE_Y, point));
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.YP, point));
rotated = new SDFRotation().setRotation(axis, angle).setSource(spike);
} else if (angle > 1) {
rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(spike);
rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(spike);
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
}

View file

@ -1,14 +1,13 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -25,7 +24,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
NoneFeatureConfiguration 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)) {
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return false;
}
@ -40,7 +39,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
private void makeBoulder(WorldGenLevel world, BlockPos pos, Random random) {
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
return;
}
@ -62,7 +61,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);
}

View file

@ -1,15 +1,14 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -29,7 +28,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
NoneFeatureConfiguration 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)) {
if (!world.getBlockState(pos.below(5)).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -59,7 +58,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)
return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.noise.OpenSimplexNoise;

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndTags;
@ -23,14 +22,14 @@ public class SingleBlockFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block.getStateManager().getProperty("waterlogged") != null) {
if (block.getStateDefinition().getProperty("waterlogged") != null) {
boolean waterlogged = !world.getFluidState(pos).isEmpty();
state = state.with(Properties.WATERLOGGED, waterlogged);
state = state.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
}
BlocksHelper.setWithoutUpdate(world, pos, state);

View file

@ -1,12 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.registry.EndBlocks;
@ -19,7 +18,7 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) {
if (!world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN)) {
return false;
}
@ -38,13 +37,14 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(crystal.getBlock())) {
if (state.is(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(crystal.getBlock())) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, crystal);
mut.setY(mut.getY() + 1);
}
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlocksHelper.setWithoutUpdate(world, mut, shard.with(Properties.WATERLOGGED, waterlogged));
BlocksHelper.setWithoutUpdate(world, mut,
shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged));
}
}
}

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
@ -46,7 +44,7 @@ public class SpireFeature extends DefaultFeature {
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction(vec -> {
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F
+ Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);

View file

@ -1,14 +1,13 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.basis.StalactiteBlock;
@ -30,7 +29,7 @@ public class StalactiteFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.below()).getBlock())) {
if (!isGround(world.getBlockState(ceiling ? pos.above() : pos.below()).getBlock())) {
return false;
}
@ -43,7 +42,7 @@ public class StalactiteFeature extends DefaultFeature {
mut.setY(pos.getY() + i * dir);
BlockState state = world.getBlockState(mut);
if (!state.getMaterial().isReplaceable()) {
stalagnate = state.isIn(EndTags.GEN_TERRAIN);
stalagnate = state.is(EndTags.GEN_TERRAIN);
height = i;
break;
}
@ -58,10 +57,10 @@ public class StalactiteFeature extends DefaultFeature {
mut.setY(pos.getY() + i * dir);
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.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);
BlockState base = block.defaultBlockState().setValue(StalactiteBlock.SIZE, size)
.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center)
: base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlocksHelper.setWithoutUpdate(world, mut, state);
}

View file

@ -1,13 +1,12 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.BlockProperties;
@ -46,7 +45,7 @@ public class SulphurHillFeature extends DefaultFeature {
int max = radius + 4;
MutableBlockPos mut = new MutableBlockPos();
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState();
BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true);
BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
for (int x = min; x < max; x++) {
int x2 = x * x;
int px = pos.getX() + x;

View file

@ -2,20 +2,18 @@ package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Sets;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.SulphurCrystalBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -35,14 +33,14 @@ public class SulphuricCaveFeature extends DefaultFeature {
NoneFeatureConfiguration config) {
int radius = MHelper.randRange(10, 30, random);
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
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) {
while (!state.is(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -51,7 +49,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -102,7 +100,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
} else if (dist < r2 * r2) {
state = world.getBlockState(mut);
if (state.isIn(EndTags.GEN_TERRAIN) || state.is(Blocks.AIR)) {
if (state.is(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) {
@ -128,20 +126,20 @@ public class SulphuricCaveFeature extends DefaultFeature {
+ random.nextInt(2);
if (dist > 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).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);
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.with(HorizontalFacingBlock.FACING, dir));
.setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
@ -151,7 +149,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
state = world.getBlockState(mut);
while (state.is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN,
world.getBlockTicks().scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN,
MHelper.randRange(8, 32, random));
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -167,10 +165,10 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
private boolean isReplaceable(BlockState state) {
return state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
return state.is(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);
|| state.getMaterial().equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, Random random) {
@ -184,7 +182,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
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.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
}
}
return EndBlocks.BRIMSTONE.defaultBlockState();
@ -195,8 +193,8 @@ public class SulphuricCaveFeature extends DefaultFeature {
BlockPos side;
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));
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -2,18 +2,16 @@ package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Fluids;
import com.google.common.collect.Sets;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.SulphurCrystalBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -60,25 +58,25 @@ public class SulphuricLakeFeature extends DefaultFeature {
int dist = x2 + z2;
if (dist <= r) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(POS).is(EndTags.GEN_TERRAIN)) {
if (isBorder(world, POS)) {
if (random.nextInt(8) > 0) {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
}
}
} else {
if (!isAbsoluteBorder(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
world.getFluidTickScheduler().schedule(POS, Fluids.WATER, 0);
world.getLiquidTicks().scheduleTick(POS, Fluids.WATER, 0);
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
if (random.nextBoolean()) {
brimstone.add(POS.down(3));
brimstone.add(POS.below(3));
}
}
} else {
@ -92,8 +90,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos offseted = POS.offset(dir);
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
BlockPos offseted = POS.relative(dir);
if (world.getBlockState(offseted).is(EndTags.GEN_TERRAIN)) {
brimstone.add(offseted);
}
}
@ -101,29 +99,29 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, POS.move(Direction.DOWN), Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos offseted = POS.offset(dir);
if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) {
BlockPos offseted = POS.relative(dir);
if (world.getBlockState(offseted).is(EndTags.GEN_TERRAIN)) {
brimstone.add(offseted);
}
}
}
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
if (random.nextBoolean()) {
brimstone.add(POS.down(3));
brimstone.add(POS.below(3));
}
}
}
}
} else if (dist < r2) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(POS).is(EndTags.GEN_TERRAIN)) {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
if (random.nextBoolean()) {
brimstone.add(POS.down(2));
brimstone.add(POS.below(2));
}
}
}
@ -141,7 +139,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y) {
return true;
}
}
@ -151,7 +149,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isAbsoluteBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() - 2;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return true;
}
}
@ -161,9 +159,9 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isDeepWater(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
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) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 2, pos.getZ() + dir.getStepZ() * 2) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return false;
}
}
@ -181,7 +179,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
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.defaultBlockState().setValue(BlockProperties.ACTIVE, true);
}
}
return EndBlocks.BRIMSTONE.defaultBlockState();
@ -192,8 +190,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
BlockPos side;
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));
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -1,11 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.blocks.HydrothermalVentBlock;
@ -21,13 +20,13 @@ public class SurfaceVentFeature extends DefaultFeature {
NoneFeatureConfiguration 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)) {
if (!world.getBlockState(pos.below(3)).is(EndTags.GEN_TERRAIN)) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
int count = MHelper.randRange(15, 30, random);
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.WATERLOGGED,
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.WATERLOGGED,
false);
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5,
@ -40,7 +39,8 @@ public class SurfaceVentFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(EndTags.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);

View file

@ -3,18 +3,16 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.collect.Sets;
import net.minecraft.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.level.WorldGenLevel;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Sets;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.world.biome.cave.EndCaveBiome;
@ -45,8 +43,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
return true;
}
protected void fillSets(int sx, int sz, Chunk chunk, Set<BlockPos> floorPositions, Set<BlockPos> ceilPositions,
MutableBlockPos min, MutableBlockPos max) {
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions,
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
MutableBlockPos mut3 = new MutableBlockPos();
@ -57,16 +55,16 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
mut.setZ(z);
mut2.setZ(z);
mut2.setY(0);
for (int y = 1; y < chunk.getHeight(); y++) {
for (int y = 1; y < chunk.getMaxBuildHeight(); y++) {
mut.setY(y);
BlockState top = chunk.getBlockState(mut);
BlockState bottom = chunk.getBlockState(mut2);
if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) {
if (top.isAir() && (bottom.is(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) {
mut3.set(mut2).move(sx, 0, sz);
floorPositions.add(mut3.immutable());
updateMin(mut3, min);
updateMax(mut3, max);
} else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) {
} else if (bottom.isAir() && (top.is(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) {
mut3.set(mut).move(sx, 0, sz);
ceilPositions.add(mut3.immutable());
updateMin(mut3, min);
@ -110,7 +108,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
if (feature != null) {
feature.place(world, null, random, pos.up(), null);
feature.place(world, null, random, pos.above(), null);
}
}
});

View file

@ -2,20 +2,18 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
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.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Sets;
import ru.betterend.interfaces.IBiomeArray;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndTags;
@ -62,11 +60,11 @@ public abstract class EndCaveFeature extends DefaultFeature {
mut.set(bpos);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
mut.setY(bpos.getY() - 1);
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN)) {
floorPositions.add(mut.immutable());
}
mut.setY(bpos.getY() + 1);
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN)) {
ceilPositions.add(mut.immutable());
}
}
@ -82,7 +80,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
return true;
}
protected abstract Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random);
protected abstract Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random);
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random,
BlockState surfaceBlock) {
@ -92,7 +90,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
if (feature != null) {
feature.place(world, null, random, pos.up(), null);
feature.place(world, null, random, pos.above(), null);
}
}
});
@ -119,21 +117,21 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
private void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomeArray();
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes();
if (array != null) {
array.setBiome(biome.getActualBiome(), pos);
}
}
private BlockPos findPos(WorldGenLevel world, BlockPos pos, int radius, Random random) {
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
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) {
while (!state.is(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -142,7 +140,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
while (state.is(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -181,7 +179,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
end.setZ(bpos.getZ());
}
});
BlocksHelper.fixBlocks(world, start.add(-5, -5, -5), end.add(5, 5, 5));
BlocksHelper.fixBlocks(world, start.offset(-5, -5, -5), end.offset(5, 5, 5));
}
protected boolean isWaterNear(WorldGenLevel world, BlockPos pos) {

View file

@ -2,14 +2,12 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Sets;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -17,19 +15,19 @@ import ru.betterend.util.MHelper;
public class RoundCaveFeature extends EndCaveFeature {
@Override
protected Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random) {
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
int x1 = center.getX() - radius - 5;
int z1 = center.getZ() - radius - 5;
int x2 = center.getX() + radius + 5;
int z2 = center.getZ() + radius + 5;
int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
BlockState state;
MutableBlockPos bpos = new MutableBlockPos();
Set<BlockPos> blocks = Sets.newHashSet();
@ -53,13 +51,13 @@ public class RoundCaveFeature extends EndCaveFeature {
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
blocks.add(bpos.immutable());
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,12 +69,14 @@ 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.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES);
}
}

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features.terrain.caves;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.SplineHelper;
@ -19,18 +18,17 @@ import ru.betterend.util.sdf.SDF;
public class TunelCaveFeature extends EndCaveFeature {
private static final Function<BlockState, Boolean> REPLACE;
@Override
protected Set<BlockPos> place(WorldGenLevel world, BlockPos center, int radius, Random random) {
// OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534,
// center.getX(), center.getZ()));
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
//OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
float rad = radius * 0.15F;
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) {
for (Vector3f vec: spline) {
float x = Mth.clamp(vec.x(), min, max);
float y = Mth.clamp(vec.y(), -radius, radius);
float z = Mth.clamp(vec.z(), min, max);
@ -38,16 +36,18 @@ public class TunelCaveFeature extends EndCaveFeature {
}
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.is(EndTags.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES);
};
}
}

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -44,7 +42,7 @@ public class DragonTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(10, 25, random);
@ -59,10 +57,10 @@ public class DragonTreeFeature extends DefaultFeature {
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.offset(last.getX(), last.getY(), last.getZ()), radius, random, noise);
makeCap(world, pos.offset(last.x(), last.y(), last.z()), radius, random, noise);
last = spline.get(0);
makeRoots(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random);
makeRoots(world, pos.offset(last.x(), last.y(), last.z()), radius, random);
radius = MHelper.randRange(1.2F, 2.3F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> {
@ -78,7 +76,7 @@ public class DragonTreeFeature extends DefaultFeature {
private void makeCap(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
int count = (int) radius;
int offset = (int) (BRANCH.get(BRANCH.size() - 1).getY() * radius);
int offset = (int) (BRANCH.get(BRANCH.size() - 1).y() * 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);
@ -98,7 +96,7 @@ public class DragonTreeFeature extends DefaultFeature {
SplineHelper.scale(branch, scale);
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
}
leavesBall(world, pos.up(offset), radius * 1.15F + 2, random, noise);
leavesBall(world, pos.above(offset), radius * 1.15F + 2, random, noise);
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random) {
@ -111,7 +109,7 @@ public class DragonTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
}
}
@ -119,7 +117,7 @@ public class DragonTreeFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel 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));
.setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().setValue(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);
@ -155,7 +153,7 @@ public class DragonTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -174,7 +172,7 @@ public class DragonTreeFeature extends DefaultFeature {
random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.offset(d));
BlockState state = world.getBlockState(p.relative(d));
if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.is(EndBlocks.DRAGON_TREE_LEAVES)) {
place = false;
break;
@ -191,7 +189,7 @@ public class DragonTreeFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.DRAGON_TREE_LEAVES) {

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -14,8 +11,10 @@ import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -34,7 +33,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(5, 10, random);
@ -52,8 +51,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
});
Vector3f capPos = spline.get(spline.size() - 1);
makeHead(world, pos.offset(capPos.getX() + 0.5F, capPos.getY() + 1.5F, capPos.getZ() + 0.5F),
Mth.floor(size / 1.6F));
makeHead(world, pos.offset(capPos.x() + 0.5F, capPos.y() + 1.5F, capPos.z() + 0.5F), Mth.floor(size / 1.6F));
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
@ -99,7 +97,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.move(Direction.DOWN);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -159,18 +157,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
Axis axis = x < 0 || x > 1 ? Axis.X : Axis.Z;
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.offset(axis, distance);
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted,
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(AttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -273,18 +271,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
Axis axis = x < 0 || x > 1 ? Axis.X : Axis.Z;
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.offset(axis, distance);
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted,
EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(AttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.with(AttachedBlock.FACING, Direction.DOWN));
.setValue(AttachedBlock.FACING, Direction.DOWN));
}
}
}
@ -329,7 +327,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.phys.AABB;
import ru.betterend.blocks.HelixTreeLeavesBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -35,7 +34,7 @@ public class HelixTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlocksHelper.setWithoutUpdate(world, pos, AIR);
@ -55,7 +54,7 @@ public class HelixTreeFeature extends DefaultFeature {
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 rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(sdf);
sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf);
Vector3f lastPoint = spline.get(spline.size() - 1);
@ -63,14 +62,14 @@ public class HelixTreeFeature extends DefaultFeature {
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);
stem = new SDFTranslate().setTranslate(lastPoint.x(), lastPoint.y(), lastPoint.z()).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.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
sdf.addPostProcess(POST).fillArea(world, pos, new AABB(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx)));
SplineHelper.scale(spline, scale);
SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> {
return state.getMaterial().isReplaceable();
@ -80,7 +79,7 @@ public class HelixTreeFeature extends DefaultFeature {
return state.getMaterial().isReplaceable();
});
SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5);
BlockPos leafStart = pos.offset(lastPoint.x() + 0.5, lastPoint.y() + 0.5, lastPoint.z() + 0.5);
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart,
(state) -> {
return state.getMaterial().isReplaceable();
@ -107,38 +106,38 @@ public class HelixTreeFeature extends DefaultFeature {
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());
int maxY = MHelper.floor(point.getY());
float div = point.getY() - lastPoint.getY();
int minY = MHelper.floor(lastPoint.y());
int maxY = MHelper.floor(point.y());
float div = point.y() - lastPoint.y();
for (float py = minY; py <= maxY; py += 0.2F) {
start.set(0, py, 0);
float delta = (float) (py - minY) / div;
float px = Mth.lerp(delta, lastPoint.getX(), point.getX());
float pz = Mth.lerp(delta, lastPoint.getZ(), point.getZ());
float px = Mth.lerp(delta, lastPoint.x(), point.x());
float pz = Mth.lerp(delta, lastPoint.z(), point.z());
end.set(px, py, pz);
fillLine(start, end, world, leaf, leafStart, i / 2 - 1);
float ax = Math.abs(px);
float az = Math.abs(pz);
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);
start.set(start.x(), start.y(), start.z() + az > 0 ? 1 : -1);
end.set(end.x(), end.y(), end.z() + az > 0 ? 1 : -1);
} else {
start.set(start.getX() + ax > 0 ? 1 : -1, start.getY(), start.getZ());
end.set(end.getX() + ax > 0 ? 1 : -1, end.getY(), end.getZ());
start.set(start.x() + ax > 0 ? 1 : -1, start.y(), start.z());
end.set(end.x() + ax > 0 ? 1 : -1, end.y(), end.z());
}
fillLine(start, end, world, leaf, leafStart, i / 2 - 1);
}
lastPoint = point;
}
leaf = leaf.with(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.add(0, lastPoint.getY(), 0);
leaf = leaf.setValue(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.offset(0, lastPoint.y(), 0);
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
leafStart = leafStart.up();
leafStart = leafStart.above();
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
leafStart = leafStart.up();
leafStart = leafStart.above();
if (world.getBlockState(leafStart).isAir()) {
BlocksHelper.setWithoutUpdate(world, leafStart, leaf);
}
@ -150,17 +149,17 @@ public class HelixTreeFeature extends DefaultFeature {
private void fillLine(Vector3f start, Vector3f end, WorldGenLevel 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();
float dx = end.x() - start.x();
float dy = end.y() - start.y();
float dz = end.z() - start.z();
float max = MHelper.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
int count = MHelper.floor(max + 1);
dx /= max;
dy /= max;
dz /= max;
float x = start.getX();
float y = start.getY();
float z = start.getZ();
float x = start.x();
float y = start.y();
float z = start.z();
MutableBlockPos bPos = new MutableBlockPos();
for (int i = 0; i < count; i++) {
@ -168,15 +167,15 @@ public class HelixTreeFeature extends DefaultFeature {
int color = MHelper.floor((float) i / (float) count * 7F + 0.5F) + offset;
color = Mth.clamp(color, 0, 7);
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, color));
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, color));
}
x += dx;
y += dy;
z += dz;
}
bPos.set(end.getX() + pos.getX(), end.getY() + pos.getY(), end.getZ() + pos.getZ());
bPos.set(end.x() + pos.getX(), end.y() + pos.getY(), end.z() + pos.getZ());
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, 7));
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, 7));
}
}

View file

@ -3,17 +3,15 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.JellyshroomCapBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -35,7 +33,7 @@ public class JellyshroomFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlockState bark = EndBlocks.JELLYSHROOM.bark.defaultBlockState();
@ -56,7 +54,7 @@ public class JellyshroomFeature extends DefaultFeature {
final float membraneRadius = radius;
SDF cap = makeCap(membraneRadius, random, membrane);
final Vector3f last = spline.get(spline.size() - 1);
cap = new SDFTranslate().setTranslate(last.getX(), last.getY(), last.getZ()).setSource(cap);
cap = new SDFTranslate().setTranslate(last.x(), last.y(), last.z()).setSource(cap);
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getState())) {
@ -65,11 +63,11 @@ public class JellyshroomFeature extends DefaultFeature {
return EndBlocks.JELLYSHROOM.log.defaultBlockState();
}
} 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 dx = info.getPos().getX() - pos.getX() - last.x();
float dz = info.getPos().getZ() - pos.getZ() - last.z();
float distance = MHelper.length(dx, dz) / membraneRadius * 7F;
int color = Mth.clamp(MHelper.floor(distance), 0, 7);
return info.getState().with(JellyshroomCapBlock.COLOR, color);
return info.getState().setValue(JellyshroomCapBlock.COLOR, color);
}
return info.getState();
}).fillRecursive(world, pos);
@ -89,7 +87,7 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
}
}
@ -118,7 +116,7 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -36,7 +35,7 @@ public class LacugroveFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(15, 25, random);
@ -52,7 +51,7 @@ public class LacugroveFeature extends DefaultFeature {
float radius = MHelper.randRange(6F, 8F, random);
radius *= (size - 15F) / 20F + 1F;
Vector3f center = spline.get(4);
leavesBall(world, pos.offset(center.getX(), center.getY(), center.getZ()), radius, random, noise);
leavesBall(world, pos.offset(center.x(), center.y(), center.z()), radius, random, noise);
radius = MHelper.randRange(1.2F, 1.8F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
@ -81,7 +80,7 @@ public class LacugroveFeature extends DefaultFeature {
boolean generate = false;
for (int y = minY; y < maxY; y++) {
mut.setY(y);
if (world.getBlockState(mut).isIn(EndTags.END_GROUND)) {
if (world.getBlockState(mut).is(EndTags.END_GROUND)) {
generate = true;
break;
}
@ -92,7 +91,7 @@ public class LacugroveFeature extends DefaultFeature {
mut.setY(y);
BlockState state = world.getBlockState(mut);
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|| state.isIn(EndTags.END_GROUND)) {
|| state.is(EndTags.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, mut,
y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
} else {
@ -109,7 +108,7 @@ public class LacugroveFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
@ -143,7 +142,7 @@ public class LacugroveFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -162,7 +161,7 @@ public class LacugroveFeature extends DefaultFeature {
random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.offset(d));
BlockState state = world.getBlockState(p.relative(d));
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.is(EndBlocks.LACUGROVE_LEAVES)) {
place = false;
break;
@ -179,7 +178,7 @@ public class LacugroveFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (EndBlocks.LACUGROVE.isTreeLog(state)) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -44,7 +42,7 @@ public class LucerniaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(12, 20, random);
@ -61,8 +59,7 @@ public class LucerniaFeature extends DefaultFeature {
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.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise,
config != null);
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise, config != null);
}
makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
@ -73,7 +70,7 @@ public class LucerniaFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel 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));
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().setValue(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);
@ -95,10 +92,10 @@ public class LucerniaFeature extends DefaultFeature {
}
}
BlockState top = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.defaultBlockState();
@ -121,7 +118,7 @@ public class LucerniaFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
@ -141,7 +138,7 @@ public class LucerniaFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -159,11 +156,11 @@ public class LucerniaFeature extends DefaultFeature {
if (state.isAir() || state.is(EndBlocks.LUCERNIA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.LUCERNIA_LEAVES)) {
if (world.getBlockState(mut.above()).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.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;
@ -185,7 +182,7 @@ public class LucerniaFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE);
}
}
@ -193,7 +190,7 @@ public class LucerniaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.LUCERNIA_LEAVES) {

View file

@ -1,17 +1,16 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.MossyGlowshroomCapBlock;
import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.noise.OpenSimplexNoise;
@ -75,7 +74,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
HEAD_POS.setTranslate(pos.x(), pos.y(), pos.z());
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
@ -83,7 +82,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
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));
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
} else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp())
|| !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
@ -93,7 +92,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
} 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));
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
@ -102,14 +101,14 @@ public class MossyGlowshroomFeature extends DefaultFeature {
} 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));
info.setBlockPos(info.getPos().relative(dir),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(info.getPos().below(),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, Direction.DOWN));
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState()
.setValue(FurBlock.FACING, Direction.DOWN));
}
}
return info.getState();
@ -144,12 +143,10 @@ public class MossyGlowshroomFeature extends DefaultFeature {
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
float dist = MHelper.length(pos.x(), pos.z());
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + CENTER.x(), pos.z() * 0.1 + CENTER.z()) * dist * 0.3F
- dist * 0.15F;
pos.set(pos.getX(), y, pos.getZ());
pos.set(pos.x(), y, pos.z());
}).setSource(cones);
HEAD_POS = (SDFTranslate) new SDFTranslate()
@ -164,7 +161,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.trees;
import com.mojang.math.Vector3f;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -48,8 +47,8 @@ public class PythadendronTreeFeature extends DefaultFeature {
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.x(), last.y(), last.z(), 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.defaultBlockState();
@ -93,10 +92,10 @@ public class PythadendronTreeFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
if (depth < 3) {
if (s1) {
leavesBall(world, pos.offset(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise);
leavesBall(world, pos.offset(pos1.x(), pos1.y(), pos1.z()), random, noise);
}
if (s2) {
leavesBall(world, pos.offset(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise);
leavesBall(world, pos.offset(pos2.x(), pos2.y(), pos2.z()), random, noise);
}
}
@ -106,10 +105,10 @@ public class PythadendronTreeFeature extends DefaultFeature {
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);
branch(pos1.x(), pos1.y(), pos1.z(), size1, angle1, random, depth - 1, world, pos);
}
if (s2) {
branch(pos2.getX(), pos2.getY(), pos2.getZ(), size2, angle2, random, depth - 1, world, pos);
branch(pos2.x(), pos2.y(), pos2.z(), size2, angle2, random, depth - 1, world, pos);
}
}
@ -117,7 +116,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
float radius = MHelper.randRange(4.5F, 6.5F, random);
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
@ -152,7 +151,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -167,7 +166,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.PYTHADENDRON_LEAVES) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
@ -43,7 +41,7 @@ public class TenaneaFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
float size = MHelper.randRange(7, 10, random);
@ -60,7 +58,7 @@ public class TenaneaFeature extends DefaultFeature {
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.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise);
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise);
}
return true;
@ -68,7 +66,7 @@ public class TenaneaFeature extends DefaultFeature {
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6));
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().setValue(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);
@ -90,11 +88,11 @@ public class TenaneaFeature extends DefaultFeature {
}
}
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE,
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState();
@ -117,7 +115,7 @@ public class TenaneaFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
@ -137,7 +135,7 @@ public class TenaneaFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -155,11 +153,11 @@ public class TenaneaFeature extends DefaultFeature {
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
int count = MHelper.randRange(3, 8, random);
mut.set(bpos);
if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) {
if (world.getBlockState(mut.above()).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.below())) {
if (world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, middle);
} else {
break;
@ -173,7 +171,7 @@ public class TenaneaFeature extends DefaultFeature {
static {
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND)) {
if (state.is(EndTags.END_GROUND)) {
return true;
}
if (state.getBlock() == EndBlocks.TENANEA_LEAVES) {

View file

@ -3,19 +3,17 @@ package ru.betterend.world.features.trees;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
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.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.blocks.UmbrellaTreeClusterBlock;
import ru.betterend.blocks.UmbrellaTreeMembraneBlock;
import ru.betterend.registry.EndBlocks;
@ -42,16 +40,16 @@ public class UmbrellaTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(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);
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 1);
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 0);
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState()
.setValue(UmbrellaTreeClusterBlock.NATURAL, true);
float size = MHelper.randRange(10, 20, random);
int count = (int) (size * 0.15F);
@ -123,7 +121,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
}
int color = MHelper.floor(d / min.radius * 7);
color = Mth.clamp(color, 1, 7);
return info.getState().with(UmbrellaTreeMembraneBlock.COLOR, color);
return info.getState().setValue(UmbrellaTreeMembraneBlock.COLOR, color);
}
return info.getState();
}).fillRecursive(world, pos);
@ -156,7 +154,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE);
}
}
@ -186,8 +184,8 @@ public class UmbrellaTreeFeature extends DefaultFeature {
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 (world.isEmptyBlock(mut)) {
BlockState state = world.getBlockState(mut.above());
if (state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.getValue(UmbrellaTreeMembraneBlock.COLOR) < 2) {
BlocksHelper.setWithoutUpdate(world, mut, fruit);
}
@ -206,7 +204,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
if (state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
return true;
}