Application of Behaviours and Tags as replacement for Materials

This commit is contained in:
Frank 2023-05-24 23:09:21 +02:00
parent 6713e03088
commit 4bf32937c1
60 changed files with 237 additions and 350 deletions

View file

@ -62,8 +62,7 @@ public class BiomeIslandFeature extends DefaultFeature {
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());
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.canBeReplaced());
return sdfCone;
}

View file

@ -118,10 +118,10 @@ public class BuildingListFeature extends NBTFeature<BuildingListFeatureConfig> {
StructureBlockInfo structureBlockInfo2,
StructurePlaceSettings structurePlaceSettings
) {
BlockState blockState = structureBlockInfo2.state;
BlockState blockState = structureBlockInfo2.state();
if (blockState.getBlock() instanceof ChestBlock) {
RandomSource random = structurePlaceSettings.getRandom(structureBlockInfo2.pos);
BlockPos chestPos = structureBlockInfo2.pos;
RandomSource random = structurePlaceSettings.getRandom(structureBlockInfo2.pos());
BlockPos chestPos = structureBlockInfo2.pos();
ChestBlock chestBlock = (ChestBlock) blockState.getBlock();
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);
levelReader.getChunk(chestPos).setBlockEntity(entity);

View file

@ -15,6 +15,7 @@ import net.minecraft.world.level.WorldGenLevel;
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.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
@ -137,9 +138,9 @@ public class CrashedShipFeature extends NBTFeature<NBTFeatureConfig> {
StructureBlockInfo structureBlockInfo2,
StructurePlaceSettings structurePlacementData
) {
BlockState state = structureBlockInfo2.state;
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, DefaultFeature.AIR, null);
BlockState state = structureBlockInfo2.state();
if (state.is(Blocks.SPAWNER) || state.getSoundType() == SoundType.WOOL) {
return new StructureBlockInfo(structureBlockInfo2.pos(), DefaultFeature.AIR, null);
}
return structureBlockInfo2;
}

View file

@ -36,7 +36,7 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter<ScatterFeatureCo
if (state.is(EndBlocks.END_LOTUS_STEM)) {
return false;
}
return !state.getFluidState().isEmpty() || state.getMaterial().isReplaceable();
return !state.getFluidState().isEmpty() || state.canBeReplaced();
};
}
}

View file

@ -150,7 +150,7 @@ public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC
BlockState stateSt = world.getBlockState(mut);
if (!isTerrain(stateSt)) {
if (merge == TerrainMerge.SURFACE) {
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
boolean isTop = mut.getY() == surfMax && state.isSolid();
Holder<Biome> b = world.getBiome(mut);
BlockState top = (isTop
? BiomeAPI.findTopMaterial(b)
@ -160,7 +160,7 @@ public abstract class NBTFeature<FC extends NBTFeatureConfig> extends Feature<FC
BlocksHelper.setWithoutUpdate(world, mut, state);
}
} else {
if (isTerrain(state) && state.getMaterial().isSolidBlocking()) {
if (isTerrain(state) && state.isSolid()) {
if (merge == TerrainMerge.SURFACE) {
Holder<Biome> b = world.getBiome(mut);
BlockState bottom = BiomeAPI.findUnderMaterial(b).orElse(cfg.defaultBlock);

View file

@ -25,7 +25,7 @@ public class SilkMothNestFeature extends DefaultFeature {
state = world.getBlockState(pos);
if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isEmptyBlock(pos.below())) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
return !world.getBlockState(pos.below().relative(dir)).getMaterial().blocksMotion();
return !world.getBlockState(pos.below().relative(dir)).blocksMotion();
}
}
}

View file

@ -30,7 +30,7 @@ public class VineFeature extends InvertedScatterFeature<VineFeatureConfig> {
plant = cfg.getPlantState(random, blockPos);
BlockState state = world.getBlockState(blockPos);
return state.getMaterial().isReplaceable() && canPlaceBlock(state, world, blockPos);
return state.canBeReplaced() && canPlaceBlock(state, world, blockPos);
}
@Override

View file

@ -22,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import java.util.function.Function;
public class BushFeature extends Feature<BushFeatureConfig> {
@ -89,11 +88,6 @@ public class BushFeature extends Feature<BushFeatureConfig> {
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
}
}

View file

@ -23,7 +23,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import java.util.function.Function;
public class BushWithOuterFeature extends Feature<BushWithOuterFeatureConfig> {
@ -107,11 +106,6 @@ public class BushWithOuterFeature extends Feature<BushWithOuterFeatureConfig> {
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
}
}

View file

@ -26,7 +26,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import java.util.List;
@ -128,11 +127,6 @@ public class TenaneaBushFeature extends DefaultFeature {
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
}
}

View file

@ -15,7 +15,6 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
public class BigAuroraCrystalFeature extends DefaultFeature {
@ -41,11 +40,9 @@ 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.is(CommonBlockTags.GEN_END_STONES) || bState.getMaterial()
.equals(Material.PLANT) || bState
.getMaterial()
.equals(Material.LEAVES);
return bState.is(CommonBlockTags.GEN_END_STONES)
|| BlocksHelper.replaceableOrPlant(bState)
|| bState.is(CommonBlockTags.LEAVES);
});
prism.fillRecursive(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL);

View file

@ -237,12 +237,9 @@ public class DesertLakeFeature extends DefaultFeature {
}
private boolean canReplace(BlockState state) {
return state.getMaterial()
.isReplaceable() || state.is(CommonBlockTags.GEN_END_STONES) || state.is(EndBlocks.ENDSTONE_DUST) || state
.getMaterial()
.equals(
Material.PLANT) || state
.getMaterial()
.equals(Material.WATER_PLANT);
return state.is(CommonBlockTags.GEN_END_STONES)
|| state.is(EndBlocks.ENDSTONE_DUST)
|| BlocksHelper.replaceableOrPlant(state)
|| state.is(CommonBlockTags.WATER_PLANT);
}
}

View file

@ -229,12 +229,9 @@ public class EndLakeFeature extends DefaultFeature {
}
private boolean canReplace(BlockState state) {
return state.getMaterial()
.isReplaceable() || state.is(CommonBlockTags.GEN_END_STONES) || state.is(EndBlocks.ENDSTONE_DUST) || state
.getMaterial()
.equals(
Material.PLANT) || state
.getMaterial()
.equals(Material.WATER_PLANT);
return state.is(CommonBlockTags.GEN_END_STONES)
|| state.is(EndBlocks.ENDSTONE_DUST)
|| BlocksHelper.replaceableOrPlant(state)
|| state.is(CommonBlockTags.WATER_PLANT);
}
}

View file

@ -6,6 +6,7 @@ import org.betterx.bclib.sdf.operator.SDFDisplacement;
import org.betterx.bclib.sdf.operator.SDFRotation;
import org.betterx.bclib.sdf.operator.SDFTranslate;
import org.betterx.bclib.sdf.primitive.SDFCappedCone;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import org.betterx.betterend.noise.OpenSimplexNoise;
import org.betterx.betterend.registry.EndBlocks;
@ -19,7 +20,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
public class FallenPillarFeature extends DefaultFeature {
@ -59,9 +59,7 @@ public class FallenPillarFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial()
.isReplaceable() || state.is(CommonBlockTags.GEN_END_STONES) || state.getMaterial()
.equals(Material.PLANT);
return state.is(CommonBlockTags.GEN_END_STONES) || BlocksHelper.replaceableOrPlant(state);
}).fillRecursive(world, pos);
return true;

View file

@ -30,7 +30,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import java.util.Optional;
import java.util.function.Function;
@ -192,7 +191,7 @@ 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.WATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.is(CommonBlockTags.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
@ -287,10 +286,7 @@ public class GeyserFeature extends DefaultFeature {
if (state.is(CommonBlockTags.GEN_END_STONES) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.SULPHUR_CRYSTAL)) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = (state) -> state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state

View file

@ -5,6 +5,7 @@ import org.betterx.bclib.sdf.SDF;
import org.betterx.bclib.sdf.operator.SDFDisplacement;
import org.betterx.bclib.sdf.operator.SDFScale3D;
import org.betterx.bclib.sdf.primitive.SDFSphere;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import org.betterx.betterend.noise.OpenSimplexNoise;
import org.betterx.betterend.registry.EndBlocks;
@ -68,9 +69,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial()
.isReplaceable() || state.is(CommonBlockTags.GEN_END_STONES) || state.getMaterial()
.equals(Material.PLANT);
return state.is(CommonBlockTags.GEN_END_STONES) || BlocksHelper.replaceableOrPlant(state);
}).fillRecursive(world, pos);
}
}

View file

@ -8,6 +8,7 @@ import org.betterx.bclib.sdf.operator.SDFSubtraction;
import org.betterx.bclib.sdf.operator.SDFTranslate;
import org.betterx.bclib.sdf.primitive.SDFCappedCone;
import org.betterx.bclib.sdf.primitive.SDFFlatland;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import org.betterx.betterend.noise.OpenSimplexNoise;
import org.betterx.betterend.registry.EndBlocks;
@ -21,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
public class ObsidianPillarBasementFeature extends DefaultFeature {
@ -65,9 +65,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial()
.isReplaceable() || state.is(CommonBlockTags.GEN_END_STONES) || state.getMaterial()
.equals(Material.PLANT);
return state.is(CommonBlockTags.GEN_END_STONES) || BlocksHelper.replaceableOrPlant(state);
}).fillRecursive(world, pos);
return true;

View file

@ -7,6 +7,7 @@ import org.betterx.bclib.sdf.operator.SDFDisplacement;
import org.betterx.bclib.sdf.operator.SDFSmoothUnion;
import org.betterx.bclib.sdf.operator.SDFTranslate;
import org.betterx.bclib.sdf.primitive.SDFSphere;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import org.betterx.betterend.noise.OpenSimplexNoise;
import org.betterx.betterend.registry.EndBiomes;
@ -16,6 +17,7 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
@ -25,7 +27,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import java.util.List;
@ -114,13 +115,10 @@ public class SpireFeature extends DefaultFeature {
if (state.is(CommonBlockTags.END_STONES)) {
return true;
}
if (state.getBlock() instanceof LeavesBlock) {
if (state.getBlock() instanceof LeavesBlock || state.is(BlockTags.LEAVES)) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
}
}

View file

@ -38,7 +38,7 @@ public class StalactiteFeature extends Feature<StalactiteFeatureConfig> {
for (int i = 1; i <= height; i++) {
mut.setY(pos.getY() + i * dir);
BlockState state = world.getBlockState(mut);
if (!state.getMaterial().isReplaceable()) {
if (!state.canBeReplaced()){
stalagnate = state.is(CommonBlockTags.GEN_END_STONES);
height = i;
break;

View file

@ -63,7 +63,7 @@ public class SulphurHillFeature extends DefaultFeature {
int d = x2 + z2;
mut.setY(pos.getY());
BlockState state = world.getBlockState(mut);
if (state.getMaterial().isReplaceable() || state.is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.canBeReplaced() || state.is(EndBlocks.HYDROTHERMAL_VENT)){
if (d < r2 * r2) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.WATER);
mut.move(Direction.DOWN);
@ -75,7 +75,8 @@ public class SulphurHillFeature extends DefaultFeature {
mut.move(Direction.DOWN);
state = world.getBlockState(mut);
int maxIt = MHelper.floor(10 - Math.sqrt(d)) + random.nextInt(1);
for (int i = 0; i < maxIt && state.getMaterial().isReplaceable(); i++) {
for (int i = 0; i < maxIt && state.canBeReplaced();
i++){
BlocksHelper.setWithoutUpdate(world, mut, rock);
mut.move(Direction.DOWN);
}
@ -84,7 +85,8 @@ public class SulphurHillFeature extends DefaultFeature {
mut.move(Direction.DOWN);
state = world.getBlockState(mut);
int maxIt = MHelper.floor(10 - Math.sqrt(d)) + random.nextInt(1);
for (int i = 0; i < maxIt && state.getMaterial().isReplaceable(); i++) {
for (int i = 0; i < maxIt && state.canBeReplaced();
i++){
BlocksHelper.setWithoutUpdate(world, mut, rock);
mut.move(Direction.DOWN);
}

View file

@ -13,6 +13,7 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
@ -22,7 +23,6 @@ import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Sets;
import java.util.Set;
@ -141,7 +141,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
)) + random.nextInt(2);
if (dist > 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
while (!state.getFluidState().isEmpty() || state.is(CommonBlockTags.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
@ -187,11 +187,14 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
private boolean isReplaceable(BlockState state) {
return state.is(CommonBlockTags.GEN_END_STONES) || 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.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(CommonBlockTags.GEN_END_STONES)
|| state.is(EndBlocks.HYDROTHERMAL_VENT)
|| state.is(EndBlocks.VENT_BUBBLE_COLUMN)
|| state.is(EndBlocks.SULPHUR_CRYSTAL)
|| BlocksHelper.replaceableOrPlant(state)
|| state.is(CommonBlockTags.WATER_PLANT)
|| state.is(BlockTags.LEAVES)
;
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, RandomSource random) {

View file

@ -69,7 +69,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
Set<BlockPos> floorPositions = Sets.newConcurrentHashSet();
Set<BlockPos> ceilPositions = Sets.newConcurrentHashSet();
caveBlocks.parallelStream().forEach((bpos) -> {
if (world.getBlockState(bpos).getMaterial().isReplaceable()) {
if (world.getBlockState(bpos).canBeReplaced()){
BlockPos side = bpos.below();
if (world.getBlockState(side).is(CommonBlockTags.GEN_END_STONES)) {
floorPositions.add(side);

View file

@ -7,11 +7,11 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import com.google.common.collect.Sets;
import java.util.Set;
@ -56,13 +56,13 @@ public class RoundCaveFeature extends EndCaveFeature {
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) {
while (state.is(BlockTags.LEAVES)) {
bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos);
}
bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) {
while (state.is(BlockTags.LEAVES)) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
@ -77,8 +77,7 @@ public class RoundCaveFeature extends EndCaveFeature {
private boolean isReplaceable(BlockState state) {
return state.is(CommonBlockTags.GEN_END_STONES) ||
state.getMaterial().isReplaceable() ||
state.getMaterial().equals(Material.PLANT) ||
state.getMaterial().equals(Material.LEAVES);
BlocksHelper.replaceableOrPlant(state) ||
state.is(BlockTags.LEAVES);
}
}

View file

@ -147,7 +147,7 @@ public class TunelCaveFeature extends EndCaveFeature {
int height = world.getHeight(Types.WORLD_SURFACE, bpos.getX(), bpos.getZ());
if (mut.getY() >= height) {
remove.add(bpos);
} else if (world.getBlockState(mut).getMaterial().isReplaceable()) {
} else if (world.getBlockState(mut).canBeReplaced()){
mut.setY(bpos.getY() - 1);
if (world.getBlockState(mut).is(CommonBlockTags.GEN_END_STONES)) {
Set<BlockPos> floorPositions = floorSets.get(bio);

View file

@ -23,7 +23,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
@ -216,10 +215,7 @@ public class DragonTreeFeature extends DefaultFeature {
if (state.getBlock() == EndBlocks.DRAGON_TREE_LEAVES) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = EndBlocks.DRAGON_TREE::isTreeLog;

View file

@ -22,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
import java.util.List;
@ -80,31 +79,31 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
if (radius < 2) {
for (int i = -1; i < 2; i++) {
mut.set(pos).move(Direction.NORTH, 2).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.SOUTH, 2).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.EAST, 2).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.WEST, 2).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
mut.set(pos).move(x, 0, z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
mut.move(Direction.DOWN);
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
mut.move(Direction.DOWN);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(
world,
mut,
@ -123,7 +122,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setX(pos.getX() + x);
for (int z = -1; z < 2; z++) {
mut.setZ(pos.getZ() + z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -135,7 +134,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setX(pos.getX() + x);
for (int z = -1; z < 2; z++) {
mut.setZ(pos.getZ() + z);
if ((x == 0 || z == 0) && world.getBlockState(mut).getMaterial().isReplaceable()) {
if ((x == 0 || z == 0) && world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -144,26 +143,26 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
pos = pos.offset(-1, 0, -1);
for (int i = -2; i < 2; i++) {
mut.set(pos).move(Direction.NORTH, 2).move(Direction.WEST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.SOUTH, 3).move(Direction.WEST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.EAST, 3).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.WEST, 2).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
for (int x = -1; x < 3; x++) {
for (int z = -1; z < 3; z++) {
mut.set(pos).move(x, 0, z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
mut.move(Direction.DOWN);
if ((x >> 1) == 0 || (z >> 1) == 0) {
@ -171,7 +170,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
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.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
if (world.getBlockState(offseted).canBeReplaced()) {
Direction dir = Direction.fromAxisAndDirection(
axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE
@ -185,7 +184,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(
world,
mut,
@ -204,7 +203,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setX(pos.getX() + x);
for (int z = -1; z < 3; z++) {
mut.setZ(pos.getZ() + z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -216,7 +215,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setX(pos.getX() + x);
for (int z = -1; z < 3; z++) {
mut.setZ(pos.getZ() + z);
if (((x >> 1) == 0 || (z >> 1) == 0) && world.getBlockState(mut).getMaterial().isReplaceable()) {
if (((x >> 1) == 0 || (z >> 1) == 0) && world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -224,54 +223,54 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
} else {
for (int i = -2; i < 3; i++) {
mut.set(pos).move(Direction.NORTH, 3).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.UP);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.NORTH);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.SOUTH, 3).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.UP);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.SOUTH);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.EAST, 3).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.UP);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.EAST);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.WEST, 3).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.UP);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.move(Direction.WEST);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
@ -281,7 +280,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
.move(Direction.UP)
.move(BlocksHelper.HORIZONTAL[i], 3)
.move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
@ -289,7 +288,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
mut.set(pos).move(x, 0, z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
mut.move(Direction.DOWN);
if ((x / 2) == 0 || (z / 2) == 0) {
@ -297,7 +296,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
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.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
if (world.getBlockState(offseted).canBeReplaced()) {
Direction dir = Direction.fromAxisAndDirection(
axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE
@ -311,7 +310,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(
world,
mut,
@ -329,7 +328,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setX(pos.getX() + x);
for (int z = -2; z < 3; z++) {
mut.setZ(pos.getZ() + z);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -345,14 +344,12 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
mut.setZ(pos.getZ() + z);
if (y < 6) {
if (((x / 2) == 0 || (z / 2) == 0) && world.getBlockState(mut)
.getMaterial()
.isReplaceable()) {
.canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
} else {
if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2) && world.getBlockState(mut)
.getMaterial()
.isReplaceable()) {
.canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -363,12 +360,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
static {
REPLACE = (state) -> {
if (/*state.is(CommonBlockTags.END_STONES) || */state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
IGNORE = EndBlocks.DRAGON_TREE::isTreeLog;

View file

@ -86,7 +86,7 @@ public class HelixTreeFeature extends DefaultFeature {
world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos,
(state) -> state.getMaterial().isReplaceable()
(state) -> state.canBeReplaced()
);
SplineHelper.rotateSpline(spline, (float) Math.PI);
SplineHelper.fillSplineForce(
@ -94,7 +94,7 @@ public class HelixTreeFeature extends DefaultFeature {
world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos,
(state) -> state.getMaterial().isReplaceable()
(state) -> state.canBeReplaced()
);
SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset(
@ -107,7 +107,7 @@ public class HelixTreeFeature extends DefaultFeature {
world,
EndBlocks.HELIX_TREE.getLog().defaultBlockState(),
leafStart,
(state) -> state.getMaterial().isReplaceable()
(state) -> state.canBeReplaced()
);
spline.clear();
@ -197,7 +197,7 @@ public class HelixTreeFeature extends DefaultFeature {
bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ());
int color = MHelper.floor((float) i / (float) count * 7F + 0.5F) + offset;
color = Mth.clamp(color, 0, 7);
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
if (world.getBlockState(bPos).canBeReplaced()){
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, color));
}
x += dx;
@ -205,7 +205,7 @@ public class HelixTreeFeature extends DefaultFeature {
z += dz;
}
bPos.set(end.x() + pos.getX(), end.y() + pos.getY(), end.z() + pos.getZ());
if (world.getBlockState(bPos).getMaterial().isReplaceable()) {
if (world.getBlockState(bPos).canBeReplaced()){
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, 7));
}
}

View file

@ -4,6 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
import org.betterx.bclib.sdf.SDF;
import org.betterx.bclib.sdf.operator.*;
import org.betterx.bclib.sdf.primitive.SDFSphere;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import org.betterx.bclib.util.SplineHelper;
import org.betterx.betterend.blocks.JellyshroomCapBlock;
@ -19,7 +20,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
@ -118,11 +118,6 @@ public class JellyshroomFeature extends DefaultFeature {
);
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (/*state.is(CommonBlockTags.END_STONES) || */state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
}
}

View file

@ -25,7 +25,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
import java.util.List;
@ -98,9 +97,7 @@ public class LacugroveFeature extends DefaultFeature {
for (int y = top; y >= minY; y--) {
mut.setY(y);
BlockState state = world.getBlockState(mut);
if (state.getMaterial().isReplaceable() || state.getMaterial()
.equals(Material.PLANT) || state.is(
CommonBlockTags.END_STONES)) {
if (BlocksHelper.replaceableOrPlant(state) || state.is(CommonBlockTags.END_STONES)) {
BlocksHelper.setWithoutUpdate(
world,
mut,
@ -209,10 +206,7 @@ public class LacugroveFeature extends DefaultFeature {
if (state.getBlock() == EndBlocks.LACUGROVE_LEAVES) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = EndBlocks.LACUGROVE::isTreeLog;

View file

@ -25,7 +25,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
@ -219,10 +218,7 @@ public class LucerniaFeature extends DefaultFeature {
if (state.getBlock() == EndBlocks.LUCERNIA_LEAVES) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = EndBlocks.LUCERNIA::isTreeLog;

View file

@ -22,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
import java.util.List;
@ -161,14 +160,6 @@ public class MossyGlowshroomFeature extends DefaultFeature {
FUNCTION = new SDFSmoothUnion().setRadius(4)
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> {
/*if (state.is(CommonBlockTags.END_STONES)) {
return true;
}*/
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
REPLACE = BlocksHelper::replaceableOrPlant;
}
}

View file

@ -24,7 +24,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import org.joml.Vector3f;
import java.util.List;
@ -208,10 +207,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
if (state.getBlock() == EndBlocks.PYTHADENDRON_LEAVES) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = EndBlocks.PYTHADENDRON::isTreeLog;

View file

@ -24,7 +24,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
@ -184,10 +183,7 @@ public class TenaneaFeature extends DefaultFeature {
if (state.getBlock() == EndBlocks.TENANEA_LEAVES) {
return true;
}
if (state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
IGNORE = EndBlocks.TENANEA::isTreeLog;

View file

@ -23,7 +23,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
@ -218,11 +217,10 @@ public class UmbrellaTreeFeature extends DefaultFeature {
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (/*state.is(CommonBlockTags.END_STONES) || */state.getMaterial().equals(Material.PLANT) || state.is(
EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
if (state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
return true;
}
return state.getMaterial().isReplaceable();
return BlocksHelper.replaceableOrPlant(state);
};
}

View file

@ -80,7 +80,7 @@ public class CavePiece extends BasePiece {
BlocksHelper.setWithoutUpdate(world, pos, CAVE_AIR);
}
} else if (dist < r * r) {
if (world.getBlockState(pos).getMaterial().isReplaceable()) {
if (world.getBlockState(pos).canBeReplaced()){
BlocksHelper.setWithoutUpdate(world, pos, Blocks.END_STONE);
}
}