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,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);
};
}
}