diff --git a/src/main/java/org/betterx/betterend/integration/byg/BYGBlocks.java b/src/main/java/org/betterx/betterend/integration/byg/BYGBlocks.java deleted file mode 100644 index be446473..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/BYGBlocks.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.betterx.betterend.integration.byg; - -import org.betterx.bclib.blocks.BaseVineBlock; -import org.betterx.betterend.blocks.basis.EndWallPlantBlock; -import org.betterx.betterend.registry.EndBlocks; - -import net.minecraft.world.level.block.Block; - -public class BYGBlocks { - public static final Block IVIS_MOSS = EndBlocks.registerBlock("ivis_moss", new EndWallPlantBlock()); - public static final Block NIGHTSHADE_MOSS = EndBlocks.registerBlock("nightshade_moss", new EndWallPlantBlock()); - - public static final Block IVIS_VINE = EndBlocks.registerBlock("ivis_vine", new BaseVineBlock()); - - public static void register() { - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/BYGIntegration.java b/src/main/java/org/betterx/betterend/integration/byg/BYGIntegration.java deleted file mode 100644 index 2c82aaf2..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/BYGIntegration.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.betterx.betterend.integration.byg; - -import org.betterx.bclib.api.v2.ModIntegrationAPI; -import org.betterx.bclib.integration.ModIntegration; -import org.betterx.betterend.integration.EndBiomeIntegration; -import org.betterx.betterend.integration.byg.biomes.BYGBiomes; -import org.betterx.betterend.integration.byg.features.BYGFeatures; -import org.betterx.worlds.together.tag.v3.CommonBlockTags; -import org.betterx.worlds.together.tag.v3.TagManager; - -import net.minecraft.world.level.block.Block; - -public class BYGIntegration extends ModIntegration implements EndBiomeIntegration { - public static final ModIntegration BYG = ModIntegrationAPI.register(new BYGIntegration()); - - public BYGIntegration() { - super("byg"); - } - - @Override - public void init() { - Block block = BYG.getBlock("ivis_phylium"); - if (block != null) { - TagManager.BLOCKS.add(block, CommonBlockTags.END_STONES, CommonBlockTags.GEN_END_STONES); - } - BYGBlocks.register(); - BYGFeatures.register(); - BYGBiomes.register(); - } - - @Override - public void addBiomes() { - BYGBiomes.addBiomes(); - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/biomes/BYGBiomes.java b/src/main/java/org/betterx/betterend/integration/byg/biomes/BYGBiomes.java deleted file mode 100644 index c540228f..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/biomes/BYGBiomes.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.betterx.betterend.integration.byg.biomes; - -import org.betterx.betterend.BetterEnd; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.betterend.registry.EndBiomes; -import org.betterx.betterend.world.biome.EndBiome; - -import net.minecraft.world.level.levelgen.SurfaceRules; - -public class BYGBiomes { - public static final SurfaceRules.ConditionSource BYG_WATER_CHECK = SurfaceRules.waterBlockCheck(-1, 0); - // New Biomes - public static final EndBiome OLD_BULBIS_GARDENS = EndBiomes.registerSubBiomeIntegration(new OldBulbisGardens()); - public static final EndBiome NIGHTSHADE_REDWOODS = EndBiomes.registerSubBiomeIntegration(new NightshadeRedwoods()); - //public static final EndBiome ETHERIAL_GROVE = EndBiomes.registerSubBiomeIntegration(new EterialGrove()); - - public static void register() { - BetterEnd.LOGGER.info("Registered " + OLD_BULBIS_GARDENS); - } - - public static void addBiomes() { - EndBiomes.addSubBiomeIntegration(OLD_BULBIS_GARDENS, BYGIntegration.BYG.getID("bulbis_gardens")); - EndBiomes.addSubBiomeIntegration(NIGHTSHADE_REDWOODS, BYGIntegration.BYG.getID("nightshade_forest")); - //EndBiomes.addSubBiomeIntegration(ETHERIAL_GROVE, Integrations.BYG.getID("ethereal_islands")); - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/biomes/NightshadeRedwoods.java b/src/main/java/org/betterx/betterend/integration/byg/biomes/NightshadeRedwoods.java deleted file mode 100644 index d4b1464a..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/biomes/NightshadeRedwoods.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.betterx.betterend.integration.byg.biomes; - -import org.betterx.bclib.BCLib; -import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder; -import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleBuilder; -import org.betterx.bclib.interfaces.SurfaceMaterialProvider; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.betterend.integration.byg.features.BYGFeatures; -import org.betterx.betterend.registry.EndFeatures; -import org.betterx.betterend.world.biome.EndBiome; - -import net.minecraft.core.Holder; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeSpecialEffects; -import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.GenerationStep.Decoration; -import net.minecraft.world.level.levelgen.SurfaceRules; - -import java.util.List; - -public class NightshadeRedwoods extends EndBiome.Config { - public NightshadeRedwoods() { - super("nightshade_redwoods"); - } - - @Override - protected void addCustomBuildData(BCLBiomeBuilder builder) { - Holder biome = BYGIntegration.BYG.getBiome("nightshade_forest"); - BiomeSpecialEffects effects = biome.value().getSpecialEffects(); - - builder.fogColor(140, 108, 47) - .fogDensity(1.5F) - .waterAndFogColor(55, 70, 186) - .foliageColor(122, 17, 155) - .particles( - ParticleTypes.REVERSE_PORTAL, - 0.002F - ) - .grassColor(48, 13, 89) - .plantsColor(200, 125, 9) - .feature(EndFeatures.END_LAKE_RARE) - .feature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE) - .feature(BYGFeatures.NIGHTSHADE_MOSS_WOOD) - .feature(BYGFeatures.NIGHTSHADE_MOSS); - - if (BCLib.isClient()) { - Holder loop = effects.getAmbientLoopSoundEvent() - .get(); - Holder music = effects.getBackgroundMusic() - .get() - .getEvent(); - Holder additions = effects.getAmbientAdditionsSettings() - .get() - .getSoundEvent(); - Holder mood = effects.getAmbientMoodSettings() - .get() - .getSoundEvent(); - builder.loop(loop) - .music(music) - .additions(additions) - .mood(mood); - } - biome.value().getGenerationSettings() - .features() - .forEach((list) -> { - list.forEach((feature) -> { - builder.feature(Decoration.VEGETAL_DECORATION, feature); - }); - }); - - for (MobCategory group : MobCategory.values()) { - List list = biome.value() - .getMobSettings() - .getMobs(group) - .unwrap(); - list.forEach((entry) -> { - builder.spawn((EntityType) entry.type, 1, entry.minCount, entry.maxCount); - }); - } - } - - @Override - protected SurfaceMaterialProvider surfaceMaterial() { - return new EndBiome.DefaultSurfaceMaterialProvider() { - @Override - public BlockState getTopMaterial() { - return BYGIntegration.BYG.getBlock("nightshade_phylium").defaultBlockState(); - } - - @Override - public SurfaceRuleBuilder surface() { - return SurfaceRuleBuilder - .start() - .rule(4, SurfaceRules.sequence(SurfaceRules.ifTrue( - BYGBiomes.BYG_WATER_CHECK, - SurfaceRules.ifTrue( - SurfaceRules.ON_FLOOR, - SurfaceRules.state(getTopMaterial()) - ) - ) - ) - ); - } - }; - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/biomes/OldBulbisGardens.java b/src/main/java/org/betterx/betterend/integration/byg/biomes/OldBulbisGardens.java deleted file mode 100644 index 738153cb..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/biomes/OldBulbisGardens.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.betterx.betterend.integration.byg.biomes; - -import org.betterx.bclib.BCLib; -import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder; -import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleBuilder; -import org.betterx.bclib.api.v2.levelgen.surface.rules.RoughNoiseCondition; -import org.betterx.bclib.interfaces.SurfaceMaterialProvider; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.betterend.integration.byg.features.BYGFeatures; -import org.betterx.betterend.registry.EndFeatures; -import org.betterx.betterend.world.biome.EndBiome; - -import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeSpecialEffects; -import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.GenerationStep.Decoration; -import net.minecraft.world.level.levelgen.Noises; -import net.minecraft.world.level.levelgen.SurfaceRules; -import net.minecraft.world.level.levelgen.placement.PlacedFeature; - -import java.util.List; - - -public class OldBulbisGardens extends EndBiome.Config { - public OldBulbisGardens() { - super("old_bulbis_gardens"); - } - - @Override - protected void addCustomBuildData(BCLBiomeBuilder builder) { - Holder biome = BYGIntegration.BYG.getBiome("bulbis_gardens"); - BiomeSpecialEffects effects = biome.value().getSpecialEffects(); - - builder.fogColor(215, 132, 207) - .fogDensity(1.8F) - .waterAndFogColor(40, 0, 56) - .foliageColor(122, 17, 155) - .particles( - ParticleTypes.REVERSE_PORTAL, - 0.002F - ) - .feature(EndFeatures.END_LAKE_RARE) - .feature(BYGFeatures.OLD_BULBIS_TREE); - - if (BCLib.isClient()) { - Holder loop = effects.getAmbientLoopSoundEvent() - .get(); - Holder music = effects.getBackgroundMusic() - .get() - .getEvent(); - Holder additions = effects.getAmbientAdditionsSettings() - .get() - .getSoundEvent(); - Holder mood = effects.getAmbientMoodSettings() - .get() - .getSoundEvent(); - builder.loop(loop) - .music(music) - .additions(additions) - .mood(mood); - } - - for (MobCategory group : MobCategory.values()) { - List list = biome.value() - .getMobSettings() - .getMobs(group) - .unwrap(); - list.forEach((entry) -> { - builder.spawn((EntityType) entry.type, 1, entry.minCount, entry.maxCount); - }); - } - - List> features = biome.value().getGenerationSettings() - .features(); - HolderSet vegetal = features.get(Decoration.VEGETAL_DECORATION.ordinal()); -// if (vegetal.size() > 2) { -// Supplier getter; - for (var feature : vegetal) { - builder.feature(Decoration.VEGETAL_DECORATION, feature); - } -// // Trees (first two features) -// // I couldn't process them with conditions, so that's why they are hardcoded (paulevs) -// for (int i = 0; i < 2; i++) { -// getter = vegetal.get(i); -// Holder feature = getter.get(); -// ResourceLocation id = BetterEnd.makeID("obg_feature_" + i); -// feature = Registry.register( -// BuiltinRegistries.PLACED_FEATURE, -// id, -// feature -// ); -// builder.feature(Decoration.VEGETAL_DECORATION, feature); -// } -// // Grasses and other features -// for (int i = 2; i < vegetal.size(); i++) { -// getter = vegetal.get(i); -// Holder feature = getter.get(); -// builder.feature(Decoration.VEGETAL_DECORATION, feature); -// } -// } - - builder.feature(EndFeatures.PURPLE_POLYPORE) - .feature(BYGFeatures.IVIS_MOSS_WOOD) - .feature(BYGFeatures.IVIS_MOSS) - .feature(BYGFeatures.IVIS_VINE) - .feature(BYGFeatures.IVIS_SPROUT); - } - - @Override - protected SurfaceMaterialProvider surfaceMaterial() { - return new EndBiome.DefaultSurfaceMaterialProvider() { - @Override - public BlockState getTopMaterial() { - return BYGIntegration.BYG.getBlock("ivis_phylium").defaultBlockState(); - } - - @Override - public BlockState getAltTopMaterial() { - return BYGIntegration.BYG.getBlock("bulbis_phycelium").defaultBlockState(); - } - - @Override - public SurfaceRuleBuilder surface() { - return SurfaceRuleBuilder - .start() - .rule(4, SurfaceRules.sequence(SurfaceRules.ifTrue( - BYGBiomes.BYG_WATER_CHECK, - SurfaceRules.ifTrue( - SurfaceRules.ON_FLOOR, - SurfaceRules.sequence( - SurfaceRules.ifTrue( - new RoughNoiseCondition(Noises.NETHERRACK, 0.19), - SurfaceRules.state(getTopMaterial()) - ), - SurfaceRules.state(getAltTopMaterial()) - ) - ) - ) - ) - ); - } - }; - } - -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/features/BYGFeatures.java b/src/main/java/org/betterx/betterend/integration/byg/features/BYGFeatures.java deleted file mode 100644 index bd019b9e..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/features/BYGFeatures.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.betterx.betterend.integration.byg.features; - -import org.betterx.bclib.api.v3.levelgen.features.BCLFeature; -import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder; -import org.betterx.betterend.BetterEnd; -import org.betterx.betterend.integration.byg.BYGBlocks; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.betterend.registry.EndFeatures; -import org.betterx.betterend.world.features.*; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.levelgen.feature.Feature; -import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; - -public class BYGFeatures { - public static final BCLFeature OLD_BULBIS_TREE = registerVegetation( - "old_bulbis_tree", - EndFeatures.inlineBuild("old_bulbis_tree_feature", new OldBulbisTreeFeature()), - 1 - ); - public static final BCLFeature IVIS_SPROUT = registerVegetation( - "ivis_sprout", - EndFeatures.SINGLE_PLANT_FEATURE, - new SinglePlantFeatureConfig(BYGIntegration.BYG.getBlock("ivis_sprout"), 6, 2), - 6 - ); - public static final BCLFeature IVIS_VINE = registerVegetation( - "ivis_vine", - EndFeatures.VINE_FEATURE, - new VineFeatureConfig(BYGBlocks.IVIS_VINE, 24), - 5 - ); - public static final BCLFeature IVIS_MOSS = registerVegetation( - "ivis_moss", - EndFeatures.WALL_PLANT_FEATURE, - new WallPlantFeatureConfig(BYGBlocks.IVIS_MOSS, 6), - 1 - ); - public static final BCLFeature IVIS_MOSS_WOOD = registerVegetation( - "ivis_moss_wood", - EndFeatures.WALL_PLANT_ON_LOG_FEATURE, - new WallPlantFeatureConfig(BYGBlocks.IVIS_MOSS, 6), - 15 - ); - public static final BCLFeature NIGHTSHADE_MOSS = registerVegetation( - "nightshade_moss", - EndFeatures.WALL_PLANT_FEATURE, - new WallPlantFeatureConfig(BYGBlocks.NIGHTSHADE_MOSS, 5), - 2 - ); - public static final BCLFeature NIGHTSHADE_MOSS_WOOD = registerVegetation( - "nightshade_moss_wood", - EndFeatures.WALL_PLANT_ON_LOG_FEATURE, - new WallPlantFeatureConfig(BYGBlocks.NIGHTSHADE_MOSS, 5), - 8 - ); - - public static final NightshadeRedwoodTreeFeature NIGHTSHADE_REDWOOD_TREE_FEATURE = - EndFeatures.inlineBuild( - "nightshade_redwood_tree", - new NightshadeRedwoodTreeFeature() - ); - - public static final BCLFeature NIGHTSHADE_REDWOOD_TREE = registerVegetation( - "nightshade_redwood_tree", - NIGHTSHADE_REDWOOD_TREE_FEATURE, - 1 - ); - public static final BigEtherTreeFeature BIG_ETHER_TREE_FEATURE = - EndFeatures.inlineBuild( - "big_ether_tree", - new BigEtherTreeFeature() - ); - - public static final BCLFeature BIG_ETHER_TREE = registerVegetation( - "big_ether_tree", - BIG_ETHER_TREE_FEATURE, - 1 - ); - - public static void register() { - } - - private static > BCLFeature registerVegetation( - String name, - F feature, - int density - ) { - return registerVegetation(name, feature, NoneFeatureConfiguration.NONE, density); - } - - private static , FC extends FeatureConfiguration> BCLFeature registerVegetation( - String name, - F feature, - FC config, - int density - ) { - ResourceLocation id = BetterEnd.makeID(name); - return BCLFeatureBuilder - .start(id, feature) - .configuration(config) - .build() - .place() - .countMax(density) - .squarePlacement() - .heightmap() - .onlyInBiome() - .build(); - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/features/BigEtherTreeFeature.java b/src/main/java/org/betterx/betterend/integration/byg/features/BigEtherTreeFeature.java deleted file mode 100644 index 8a6cae4e..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/features/BigEtherTreeFeature.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.betterx.betterend.integration.byg.features; - -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; -import org.betterx.bclib.sdf.SDF; -import org.betterx.bclib.util.MHelper; -import org.betterx.bclib.util.SplineHelper; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.worlds.together.tag.v3.CommonBlockTags; - -import net.minecraft.core.BlockPos; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.WorldGenLevel; -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 net.minecraft.world.level.material.Material; - -import com.google.common.base.Function; -import org.joml.Vector3f; - -import java.util.List; - -public class BigEtherTreeFeature extends DefaultFeature { - @Override - public boolean place(FeaturePlaceContext featureConfig) { - final RandomSource random = featureConfig.random(); - final BlockPos pos = featureConfig.origin(); - final WorldGenLevel world = featureConfig.level(); - if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false; - - BlockState log = BYGIntegration.BYG.getDefaultState("ether_log"); - BlockState wood = BYGIntegration.BYG.getDefaultState("ether_wood"); - Function splinePlacer = (bpos) -> { - return log; - }; - Function replace = (state) -> { - return state.is(CommonBlockTags.END_STONES) || state.getMaterial() - .equals(Material.PLANT) || state.getMaterial() - .isReplaceable(); - }; - - int height = MHelper.randRange(40, 60, random); - List trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4); - SplineHelper.offsetParts(trunk, random, 2F, 0, 2F); - SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer); - - int count = height / 15; - for (int i = 1; i < count; i++) { - float splinePos = (float) i / (float) count; - float startAngle = random.nextFloat() * MHelper.PI2; - float length = (1 - splinePos) * height * 0.4F; - int points = (int) (length / 3); - List branch = SplineHelper.makeSpline(0, 0, 0, length, 0, 0, points < 2 ? 2 : points); - SplineHelper.powerOffset(branch, length, 2F); - int rotCount = MHelper.randRange(5, 7, random); - Vector3f start = SplineHelper.getPos(trunk, splinePos * (trunk.size() - 1)); - for (int j = 0; j < rotCount; j++) { - float angle = startAngle + (float) j / rotCount * MHelper.PI2; - List br = SplineHelper.copySpline(branch); - SplineHelper.offsetParts(br, random, 0, 1, 1); - SplineHelper.rotateSpline(br, angle); - - SplineHelper.offset(br, start); - SplineHelper.fillSpline(br, world, wood, pos, replace); - } - } - - sdf.setReplaceFunction((state) -> { - return state.is(CommonBlockTags.END_STONES) || state.getMaterial() - .equals(Material.PLANT) || state.getMaterial() - .isReplaceable(); - }).addPostProcess((info) -> { - if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) { - return wood; - } - return info.getState(); - }).fillRecursive(world, pos); - - return true; - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java b/src/main/java/org/betterx/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java deleted file mode 100644 index 6c1f6fd0..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.betterx.betterend.integration.byg.features; - -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; -import org.betterx.bclib.sdf.PosInfo; -import org.betterx.bclib.sdf.SDF; -import org.betterx.bclib.sdf.operator.SDFDisplacement; -import org.betterx.bclib.sdf.operator.SDFFlatWave; -import org.betterx.bclib.sdf.operator.SDFSmoothUnion; -import org.betterx.bclib.sdf.primitive.SDFCappedCone; -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.integration.byg.BYGIntegration; -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.util.RandomSource; -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.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -import net.minecraft.world.level.material.Material; - -import com.google.common.collect.Lists; -import org.joml.Vector3f; - -import java.util.List; -import java.util.function.Function; - -public class NightshadeRedwoodTreeFeature extends DefaultFeature { - private static final List BRANCH; - - @Override - public boolean place(FeaturePlaceContext featureConfig) { - final RandomSource random = featureConfig.random(); - final BlockPos pos = featureConfig.origin(); - final WorldGenLevel world = featureConfig.level(); - if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false; - - BlockState log = BYGIntegration.BYG.getDefaultState("nightshade_log"); - BlockState wood = BYGIntegration.BYG.getDefaultState("nightshade_wood"); - BlockState leaves = BYGIntegration.BYG.getDefaultState("nightshade_leaves"); - BlockState leaves_flower = BYGIntegration.BYG.getDefaultState("flowering_nightshade_leaves"); - - Function splinePlacer = (bpos) -> log; - Function replace = (state) -> state.is(CommonBlockTags.END_STONES) || state.getMaterial() - .equals(Material.PLANT) || state.getMaterial() - .isReplaceable(); - Function post = (info) -> { - if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) { - return wood; - } - return info.getState(); - }; - Function ignore = (state) -> state.equals(log) || state.equals(wood); - - int height = MHelper.randRange(40, 60, random); - List trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4); - SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F); - - if (!SplineHelper.canGenerate(trunk, pos, world, replace)) { - return false; - } - - int count = height >> 2; - float start = trunk.size() / 3F; - float delta = trunk.size() * 0.6F; - float max = height - 7; - float startAngle = random.nextFloat() * MHelper.PI2; - for (int i = 0; i < count; i++) { - float scale = (float) (count - i) / count * 15; - Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start); - if (offset.y() > max) { - break; - } - List branch = SplineHelper.copySpline(BRANCH); - SplineHelper.rotateSpline(branch, i * 1.3F + startAngle); - SplineHelper.scale(branch, scale); - SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F); - SplineHelper.offset(branch, offset); - SplineHelper.fillSpline(branch, world, wood, pos, replace); - } - - SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer); - SDF roots = new SDFSphere().setRadius(2F).setBlock(log); - roots = new SDFFlatWave().setIntensity(2F) - .setRaysCount(MHelper.randRange(5, 7, random)) - .setAngle(random.nextFloat() * MHelper.PI2) - .setSource(roots); - sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots); - sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos); - Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.35F); - for (int y = 0; y < 8; y++) { - BlockPos p = pos.offset((int) (last.x() + 0.5), (int) (last.y() + y), (int) (last.z() + 0.5)); - BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log); - } - - for (int y = 0; y < 16; y++) { - BlockPos p = pos.offset((int) (last.x() + 0.5), (int) (last.y() + y), (int) (last.z() + 0.5)); - if (world.isEmptyBlock(p)) { - BlocksHelper.setWithoutUpdate(world, p, leaves); - } - float radius = (1 - y / 16F) * 3F; - int rad = (int) (radius + 1); - radius *= radius; - for (int x = -rad; x <= rad; x++) { - int x2 = x * x; - for (int z = -rad; z <= rad; z++) { - int z2 = z * z; - if (x2 + z2 < radius - random.nextFloat() * rad) { - BlockPos lp = p.offset(x, 0, z); - if (world.isEmptyBlock(lp)) { - BlocksHelper.setWithoutUpdate(world, lp, leaves); - } - } - } - } - } - - MutableBlockPos mut = new MutableBlockPos(); - Function leavesPost1 = (info) -> { - if (info.getState().equals(log) || info.getState().equals(wood)) { - for (int x = -6; x < 7; x++) { - int ax = Math.abs(x); - mut.setX(x + info.getPos().getX()); - for (int z = -6; z < 7; z++) { - int az = Math.abs(z); - mut.setZ(z + info.getPos().getZ()); - for (int y = -6; y < 7; y++) { - int ay = Math.abs(y); - int d = ax + ay + az; - if (d < 7) { - mut.setY(y + info.getPos().getY()); - BlockState state = info.getState(mut); - if (state.getBlock() instanceof LeavesBlock) { - int distance = state.getValue(LeavesBlock.DISTANCE); - if (d < distance) { - info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d)); - } - } - } - } - } - } - } - return info.getState(); - }; - Function leavesPost2 = (info) -> { - if (info.getState().getBlock() instanceof LeavesBlock) { - int distance = info.getState().getValue(LeavesBlock.DISTANCE); - if (distance > MHelper.randRange(2, 4, random)) { - return Blocks.AIR.defaultBlockState(); - } - int airCount = 0; - for (Direction d : BlocksHelper.DIRECTIONS) { - if (info.getState(d).isAir()) { - airCount++; - } - if (airCount > 5) { - return Blocks.AIR.defaultBlockState(); - } - } - if (random.nextInt(8) == 0) { - return leaves_flower.setValue(LeavesBlock.DISTANCE, distance); - } - } - return info.getState(); - }; - - SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves); - canopy = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-3F, 3F, random)).setSource(canopy); - canopy.addPostProcess(leavesPost1) - .addPostProcess(leavesPost2) - .fillRecursiveIgnore(world, pos.offset(0, (int) (height * 0.75), 0), ignore); - - return true; - } - - static { - BRANCH = Lists.newArrayList( - new Vector3f(0, 0, 0), - new Vector3f(0.25F, 0.1F, 0), - new Vector3f(0.40F, 0.2F, 0), - new Vector3f(0.50F, 0.4F, 0), - new Vector3f(0.55F, 0.6F, 0) - ); - } -} diff --git a/src/main/java/org/betterx/betterend/integration/byg/features/OldBulbisTreeFeature.java b/src/main/java/org/betterx/betterend/integration/byg/features/OldBulbisTreeFeature.java deleted file mode 100644 index 448161f7..00000000 --- a/src/main/java/org/betterx/betterend/integration/byg/features/OldBulbisTreeFeature.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.betterx.betterend.integration.byg.features; - -import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature; -import org.betterx.bclib.sdf.SDF; -import org.betterx.bclib.sdf.operator.SDFDisplacement; -import org.betterx.bclib.sdf.operator.SDFSubtraction; -import org.betterx.bclib.sdf.operator.SDFTranslate; -import org.betterx.bclib.sdf.operator.SDFUnion; -import org.betterx.bclib.sdf.primitive.SDFSphere; -import org.betterx.bclib.util.MHelper; -import org.betterx.bclib.util.SplineHelper; -import org.betterx.betterend.integration.byg.BYGIntegration; -import org.betterx.betterend.noise.OpenSimplexNoise; -import org.betterx.worlds.together.tag.v3.CommonBlockTags; - -import net.minecraft.core.BlockPos; -import net.minecraft.util.Mth; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.phys.AABB; - -import com.google.common.collect.Lists; -import org.joml.Vector3f; - -import java.util.List; -import java.util.function.Function; - -public class OldBulbisTreeFeature extends DefaultFeature { - private static final List SPLINE; - private static final List ROOT; - private static final List LEAF; - private static final List SIDE; - - @Override - public boolean place(FeaturePlaceContext featureConfig) { - final RandomSource random = featureConfig.random(); - final BlockPos pos = featureConfig.origin(); - final WorldGenLevel world = featureConfig.level(); - if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false; - if (!world.getBlockState(pos.below(4)).is(CommonBlockTags.GEN_END_STONES)) return false; - - BlockState stem = BYGIntegration.BYG.getDefaultState("bulbis_stem"); - BlockState wood = BYGIntegration.BYG.getDefaultState("bulbis_wood"); - BlockState cap = BYGIntegration.BYG.getDefaultState(random.nextBoolean() - ? "bulbis_shell" - : "purple_bulbis_shell"); - BlockState glow = BYGIntegration.BYG.getDefaultState("purple_shroomlight"); - - Function replacement = (state) -> { - if (state.equals(stem) || state.equals(wood) || state.is(CommonBlockTags.END_STONES) || state.getMaterial() - .equals(Material.PLANT)) { - return true; - } - return state.getMaterial().isReplaceable(); - }; - - float size = MHelper.randRange(10, 20, random); - float addSize = MHelper.randRange(1, 1.7F, random); - float addRad = addSize * 0.5F + 0.5F; - int count = (int) (size * 0.15F); - size *= addSize; - float var = MHelper.PI2 / (float) (count * 3); - float start = MHelper.randRange(0, MHelper.PI2, random); - SDF sdf = null; - int x1 = ((pos.getX() >> 4) << 4) - 16; - int z1 = ((pos.getZ() >> 4) << 4) - 16; - AABB limits = new AABB(x1, pos.getY() - 5, z1, x1 + 47, pos.getY() + size * 2, z1 + 47); - for (int i = 0; i < count; i++) { - float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start; - List spline = SplineHelper.copySpline(SPLINE); - float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F; - SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ); - SplineHelper.offset(spline, new Vector3f(size * random.nextFloat() * 0.3F, 0, 0)); - SplineHelper.rotateSpline(spline, angle); - SplineHelper.offsetParts(spline, random, 1F, 0, 1F);// 1.3F 0.8F - SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> stem); - - Vector3f vec = spline.get(spline.size() - 1); - float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F; - bigSphere( - world, - pos.offset((int) vec.x(), (int) vec.y(), (int) vec.z()), - radius, - cap, - glow, - wood, - replacement, - random - ); - vec = SplineHelper.getPos(spline, 0.3F); - makeRoots( - world, - pos.offset((int) vec.x(), (int) vec.y(), (int) vec.z()), - size * 0.4F + 5, - random, - wood, - replacement - ); - - sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch); - } - - sdf.setReplaceFunction(replacement).addPostProcess((info) -> { - if (info.getState().equals(stem) && (!info.getStateUp().equals(stem) || !info.getStateDown() - .equals(stem))) { - return wood; - } - return info.getState(); - }).fillArea(world, pos, limits); - - return true; - } - - private void bigSphere( - WorldGenLevel world, - BlockPos pos, - float radius, - BlockState cap, - BlockState glow, - BlockState wood, - Function replacement, - RandomSource random - ) { - OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); - SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap); - - SDF sphereInner = new SDFSphere().setRadius(radius * 0.53F).setBlock(Blocks.AIR); - sphereInner = new SDFDisplacement().setFunction((vec) -> (float) noise.eval( - vec.x() * 0.1, - vec.y() * 0.1, - vec.z() * 0.1 - )).setSource(sphereInner); - - SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow); - sphereGlow = new SDFDisplacement().setFunction((vec) -> (float) noise.eval( - vec.x() * 0.1, - vec.y() * 0.1, - vec.z() * 0.1 - ) * 2F).setSource(sphereGlow); - sphereGlow = new SDFSubtraction().setSourceA(sphereGlow).setSourceB(sphereInner); - - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereGlow); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereInner); - - float offsetY = radius * 1.7F; - sphere = new SDFUnion().setSourceA(sphere).setSourceB(sphereGlow); - sphere = new SDFTranslate().setTranslate(0, offsetY, 0).setSource(sphere); - - int leafCount = (int) (radius * 0.5F) + 2; - for (int i = 0; i < 4; i++) { - float angle = (float) i / 4 * MHelper.PI2; - List spline = SplineHelper.copySpline(LEAF); - SplineHelper.rotateSpline(spline, angle); - SplineHelper.scale(spline, radius * 1.4F); - SplineHelper.fillSplineForce(spline, world, wood, pos, replacement); - - for (int j = 0; j < leafCount; j++) { - float delta = ((float) j / (float) (leafCount - 1)); - float scale = (float) Math.sin(delta * Math.PI) * 0.8F + 0.2F; - float index = Mth.lerp(delta, 1F, 3.9F); - Vector3f point = SplineHelper.getPos(spline, index); - - List side = SplineHelper.copySpline(SIDE); - SplineHelper.rotateSpline(side, angle); - SplineHelper.scale(side, scale * radius); - BlockPos p = pos.offset((int) (point.x() + 0.5F), (int) (point.y() + 0.5F), (int) (point.z() + 0.5F)); - SplineHelper.fillSplineForce(side, world, wood, p, replacement); - } - } - - sphere.fillArea(world, pos, new AABB(pos.above((int) offsetY)).inflate(radius * 1.3F)); - } - - private void makeRoots( - WorldGenLevel world, - BlockPos pos, - float radius, - RandomSource random, - BlockState wood, - Function replacement - ) { - int count = (int) (radius * 1.5F); - for (int i = 0; i < count; i++) { - float angle = (float) i / (float) count * MHelper.PI2; - float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - - List branch = SplineHelper.copySpline(ROOT); - SplineHelper.rotateSpline(branch, angle); - SplineHelper.scale(branch, scale); - Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.offset((int) last.x(), (int) last.y(), (int) last.z())) - .is(CommonBlockTags.GEN_END_STONES)) { - SplineHelper.fillSpline(branch, world, wood, pos, replacement); - } - } - } - - static { - SPLINE = Lists.newArrayList( - new Vector3f(0.00F, 0.00F, 0.00F), - new Vector3f(0.10F, 0.35F, 0.00F), - new Vector3f(0.20F, 0.50F, 0.00F), - new Vector3f(0.30F, 0.55F, 0.00F), - new Vector3f(0.42F, 0.70F, 0.00F), - new Vector3f(0.50F, 1.00F, 0.00F) - ); - - ROOT = Lists.newArrayList( - new Vector3f(0F, 1F, 0), - new Vector3f(0.1F, 0.70F, 0), - new Vector3f(0.3F, 0.30F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.20F, 0) - ); - SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); - - LEAF = Lists.newArrayList( - new Vector3f(0.00F, 0.0F, 0), - new Vector3f(0.10F, 0.4F, 0), - new Vector3f(0.40F, 0.8F, 0), - new Vector3f(0.75F, 0.9F, 0), - new Vector3f(1.00F, 0.8F, 0) - ); - - SIDE = Lists.newArrayList( - new Vector3f(0, -0.3F, -0.5F), - new Vector3f(0, -0.1F, -0.3F), - new Vector3f(0, 0.0F, 0.0F), - new Vector3f(0, -0.1F, 0.3F), - new Vector3f(0, -0.3F, 0.5F) - ); - } -}