diff --git a/build.gradle b/build.gradle index e322f16adb..9590b35af9 100644 --- a/build.gradle +++ b/build.gradle @@ -161,25 +161,25 @@ dependencies { annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' //Computer Craft Support. - //implementation fg.deobf("org.squiddev:cc-tweaked-${version_cct_mc}:${version_cct}") + implementation fg.deobf("org.squiddev:cc-tweaked-${version_cct_mc}:${version_cct}") //Lost Cities //implementation "blank:lostcities-1.16-4.0.7-beta" //Thut Essentials - //implementation "${depstr_thutessentials}" + implementation "${depstr_thutessentials}" //JEI // compile against the JEI API but do not include it at runtime - //compileOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}:api") + compileOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}:api") // at runtime, use the full JEI jar - //runtimeOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}") + runtimeOnly fg.deobf("mezz.jei:jei-${version_jei_mc}:${version_jei}") //WHYLA - //implementation fg.deobf("curse.maven:Jade-${version_jade}") + implementation fg.deobf("curse.maven:Jade-${version_jade}") //Minecolonies - //implementation "blank:minecolonies-1.17.1-1.0.23-ALPHA-api" + implementation "blank:minecolonies-1.17.1-1.0.23-ALPHA-api" //Immersive Enginnering //implementation "blusunrize:ImmersiveEngineering:0.15-+" @@ -189,7 +189,7 @@ dependencies { //implementation "blank:LibVulpes-1.16.5-1.0.1-6-api" // Curios - Wearables Support - //implementation fg.deobf("curse.maven:curios-${version_curios}") + implementation fg.deobf("curse.maven:curios-${version_curios}") } sourceSets { diff --git a/gradle.properties b/gradle.properties index 8bf8bfb74e..43fecfea86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,14 +23,14 @@ compile_name=pokecube-aio author_name=Thutmose # Mod Support versions -version_cct_mc=1.17.1 -version_cct=1.98.2 -version_jei_mc=1.17.1 -version_jei=8.1.0.21 +version_cct_mc=1.18 +version_cct=1.99.0 +version_jei_mc=1.18 +version_jei=9.0.0.40 version_lostcities=1.16-4.0.3-alpha-deobf version_minecolonies=api -depstr_thutessentials=blank:thutessentials-1.17.1-4.2.0-deobf +depstr_thutessentials=blank:thutessentials-1.18-4.2.0-deobf -version_jade=324717:3468298 -version_curios=309927:3457073 +version_jade=324717:3544015 +version_curios=309927:3546313 version_journeymap=32274:3420875 diff --git a/libs/thutessentials-1.18-4.2.0-deobf.jar b/libs/thutessentials-1.18-4.2.0-deobf.jar new file mode 100644 index 0000000000..e0495f0ad4 Binary files /dev/null and b/libs/thutessentials-1.18-4.2.0-deobf.jar differ diff --git a/libs/thutessentials-1.18-4.2.0.jar b/libs/thutessentials-1.18-4.2.0.jar new file mode 100644 index 0000000000..0c7a1dde6f Binary files /dev/null and b/libs/thutessentials-1.18-4.2.0.jar differ diff --git a/pending_mod_update/lostcities/Impl.java b/pending_mod_update/lostcities/Impl.java index d32e9b0aa4..7afc2ce8ef 100644 --- a/pending_mod_update/lostcities/Impl.java +++ b/pending_mod_update/lostcities/Impl.java @@ -38,7 +38,7 @@ public static void register() @SubscribeEvent public static void buildStructure(final PickLocation event) { - final MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + final MinecraftServer server = Essentials.server; final ServerLevel world = server.getLevel(event.getDimensionKey()); final IDimensionInfo dimInfo = Registration.LOSTCITY_FEATURE.getDimensionInfo(world); if (dimInfo == null) diff --git a/src/main/java/pokecube/legends/PokecubeLegends.java b/src/main/java/pokecube/legends/PokecubeLegends.java index 43c2fcd411..b2a6d37bb4 100644 --- a/src/main/java/pokecube/legends/PokecubeLegends.java +++ b/src/main/java/pokecube/legends/PokecubeLegends.java @@ -81,6 +81,8 @@ import pokecube.legends.recipes.LegendsLootingRecipeManager; import pokecube.legends.tileentity.RaidSpawn; import pokecube.legends.tileentity.RingTile; +import pokecube.legends.worldgen.WorldgenFeatures; +import pokecube.legends.worldgen.trees.Trees; import thut.api.terrain.BiomeDatabase; import thut.core.common.ThutCore; @@ -173,9 +175,6 @@ public static void registerFeatures(final RegistryEvent.Register> eve // Currently this uses same settings as gold ore. WorldgenHandler.INSTANCE.register(check, GenerationStep.Decoration.UNDERGROUND_ORES, ORE_SAPPHIRE_PLACEMENT); - - // FIXME worldgen -// Trees.register(); } @SubscribeEvent @@ -265,7 +264,8 @@ public PokecubeLegends() Type.MOUNTAIN, Type.RARE, Type.WET); // FIXME worldgen features -// WorldgenFeatures.init(modEventBus); + // WorldgenFeatures.init(modEventBus); + Trees.init(modEventBus); BlockInit.init(); ItemInit.init(); MoveRegister.init(); diff --git a/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java b/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java index aae2ce56f2..a6c0eab0a8 100644 --- a/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java +++ b/src/main/java/pokecube/legends/worldgen/WorldgenFeatures.java @@ -32,8 +32,8 @@ import pokecube.legends.worldgen.features.TaintedKelpFeature; import pokecube.legends.worldgen.features.TaintedSeagrassFeature; import pokecube.legends.worldgen.features.TemporalBambooFeature; -import pokecube.legends.worldgen.features.treedecorators.LeavesStringOfPearlsDecorator; -import pokecube.legends.worldgen.features.treedecorators.TrunkStringOfPearlsDecorator; +import pokecube.legends.worldgen.trees.treedecorators.LeavesStringOfPearlsDecorator; +import pokecube.legends.worldgen.trees.treedecorators.TrunkStringOfPearlsDecorator; public class WorldgenFeatures { @@ -41,8 +41,6 @@ public class WorldgenFeatures // ForgeRegistries.SURFACE_BUILDERS, Reference.ID); public static final DeferredRegister> FEATURES = DeferredRegister.create( ForgeRegistries.FEATURES, Reference.ID); - public static final DeferredRegister> TREE_DECORATORS = DeferredRegister.create( - ForgeRegistries.TREE_DECORATOR_TYPES, Reference.ID); // public static final RegistryObject> BURNT_DESERT = WorldgenFeatures.SURFACE_BUILDERS.register("burnt_desert_builder", // () -> new BurntDesertSurfaceBuilder(SurfaceBuilderBaseConfiguration.CODEC)); @@ -90,15 +88,10 @@ public class WorldgenFeatures public static final RegistryObject> STRING_OF_PEARLS = WorldgenFeatures.FEATURES.register("string_of_pearls_feature", () -> new StringOfPearlsFeature(NoneFeatureConfiguration.CODEC)); - public static final RegistryObject> LEAVES_STRING_OF_PEARLS = WorldgenFeatures.TREE_DECORATORS.register("leaves_string_of_pearls_decorator", - () -> new TreeDecoratorType<>(LeavesStringOfPearlsDecorator.CODEC)); - public static final RegistryObject> TRUNK_STRING_OF_PEARLS = WorldgenFeatures.TREE_DECORATORS.register("trunk_string_of_pearls_decorator", - () -> new TreeDecoratorType<>(TrunkStringOfPearlsDecorator.CODEC)); public static void init(final IEventBus bus) { // WorldgenFeatures.SURFACE_BUILDERS.register(bus); WorldgenFeatures.FEATURES.register(bus); - WorldgenFeatures.TREE_DECORATORS.register(bus); } } diff --git a/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java b/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java index 5b4f0b39e8..589c33b19d 100644 --- a/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java +++ b/src/main/java/pokecube/legends/worldgen/features/LakeFeature.java @@ -45,8 +45,8 @@ public boolean place(final FeaturePlaceContext context) { pos = pos.below(4); for (final StructureFeature village : StructureFeature.NOISE_AFFECTING_FEATURES) - if (world.startsForFeature(SectionPos.of(pos), village).findAny().isPresent()) return false; - if (world.startsForFeature(SectionPos.of(pos), StructureFeature.VILLAGE).findAny().isPresent()) return false; + if (!world.startsForFeature(SectionPos.of(pos), village).isEmpty()) return false; + if (!world.startsForFeature(SectionPos.of(pos), StructureFeature.VILLAGE).isEmpty()) return false; else { final boolean[] aboolean = new boolean[2048]; diff --git a/src/main/java/pokecube/legends/worldgen/features/treedecorators/TrunkStringOfPearlsDecorator.java b/src/main/java/pokecube/legends/worldgen/features/treedecorators/TrunkStringOfPearlsDecorator.java deleted file mode 100644 index 863f023540..0000000000 --- a/src/main/java/pokecube/legends/worldgen/features/treedecorators/TrunkStringOfPearlsDecorator.java +++ /dev/null @@ -1,87 +0,0 @@ -package pokecube.legends.worldgen.features.treedecorators; - -import java.util.List; -import java.util.Random; -import java.util.function.BiConsumer; - -import com.mojang.serialization.Codec; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.LevelSimulatedReader; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.levelgen.feature.Feature; -import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; -import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; -import pokecube.legends.blocks.plants.StringOfPearlsBlock; -import pokecube.legends.init.BlockInit; -import pokecube.legends.worldgen.WorldgenFeatures; - -public class TrunkStringOfPearlsDecorator extends TreeDecorator -{ - public static final Codec CODEC; - public static final TrunkStringOfPearlsDecorator INSTANCE = new TrunkStringOfPearlsDecorator(); - - protected TreeDecoratorType type() - { - return WorldgenFeatures.TRUNK_STRING_OF_PEARLS.get(); - } - - @Override - public void place(LevelSimulatedReader world, BiConsumer blockPos, Random random, List listPos, List listPos1) - { - listPos.forEach((listedPos) -> - { - if (random.nextInt(3) > 0) - { - BlockPos pos = listedPos.west(); - if (Feature.isAir(world, pos)) - { - placeVine(blockPos, pos, StringOfPearlsBlock.EAST, random); - } - } - - if (random.nextInt(3) > 0) - { - BlockPos pos1 = listedPos.east(); - if (Feature.isAir(world, pos1)) - { - placeVine(blockPos, pos1, StringOfPearlsBlock.WEST, random); - } - } - - if (random.nextInt(3) > 0) - { - BlockPos pos2 = listedPos.north(); - if (Feature.isAir(world, pos2)) - { - placeVine(blockPos, pos2, StringOfPearlsBlock.SOUTH, random); - } - } - - if (random.nextInt(3) > 0) - { - BlockPos pos3 = listedPos.south(); - if (Feature.isAir(world, pos3)) - { - placeVine(blockPos, pos3, StringOfPearlsBlock.NORTH, random); - } - } - - }); - } - - public static void placeVine(BiConsumer blockPos, BlockPos pos, BooleanProperty b, Random random) - { - blockPos.accept(pos, BlockInit.STRING_OF_PEARLS.get().defaultBlockState() - .setValue(b, Boolean.valueOf(true)) - .setValue(StringOfPearlsBlock.FLOWERS, Boolean.valueOf(random.nextFloat() < 0.11F))); - } - - static { - CODEC = Codec.unit(() -> - { - return INSTANCE; - }); - } -} \ No newline at end of file diff --git a/src/main/java/pokecube/legends/worldgen/trees/Trees.java b/src/main/java/pokecube/legends/worldgen/trees/Trees.java index 4a6f5ac1d5..11e55a98be 100644 --- a/src/main/java/pokecube/legends/worldgen/trees/Trees.java +++ b/src/main/java/pokecube/legends/worldgen/trees/Trees.java @@ -4,14 +4,15 @@ import com.google.common.collect.ImmutableList; -import net.minecraft.data.BuiltinRegistries; -import net.minecraft.data.worldgen.Features; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration.TreeConfigurationBuilder; import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; import net.minecraft.world.level.levelgen.feature.foliageplacers.AcaciaFoliagePlacer; import net.minecraft.world.level.levelgen.feature.foliageplacers.BlobFoliagePlacer; @@ -20,19 +21,39 @@ import net.minecraft.world.level.levelgen.feature.foliageplacers.MegaPineFoliagePlacer; import net.minecraft.world.level.levelgen.feature.foliageplacers.PineFoliagePlacer; import net.minecraft.world.level.levelgen.feature.foliageplacers.SpruceFoliagePlacer; -import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; import net.minecraft.world.level.levelgen.feature.treedecorators.AlterGroundDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.BeehiveDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraft.world.level.levelgen.feature.trunkplacers.FancyTrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.ForkingTrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.GiantTrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.MegaJungleTrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; +import pokecube.legends.Reference; import pokecube.legends.init.BlockInit; -import pokecube.legends.worldgen.features.treedecorators.LeavesStringOfPearlsDecorator; -import pokecube.legends.worldgen.features.treedecorators.TrunkStringOfPearlsDecorator; +import pokecube.legends.worldgen.trees.treedecorators.LeavesStringOfPearlsDecorator; +import pokecube.legends.worldgen.trees.treedecorators.TrunkStringOfPearlsDecorator; public class Trees { + private static final BeehiveDecorator BEEHIVE_0002 = new BeehiveDecorator(0.002F); + + public static final DeferredRegister> TREE_DECORATORS = DeferredRegister + .create(ForgeRegistries.TREE_DECORATOR_TYPES, Reference.ID); + + public static final RegistryObject> LEAVES_STRING_OF_PEARLS = TREE_DECORATORS.register( + "leaves_string_of_pearls_decorator", () -> new TreeDecoratorType<>(LeavesStringOfPearlsDecorator.CODEC)); + public static final RegistryObject> TRUNK_STRING_OF_PEARLS = TREE_DECORATORS.register( + "trunk_string_of_pearls_decorator", () -> new TreeDecoratorType<>(TrunkStringOfPearlsDecorator.CODEC)); + public static ConfiguredFeature INVERTED_TREE; public static ConfiguredFeature INVERTED_TREE_FANCY; public static ConfiguredFeature TEMPORAL_TREE; @@ -45,29 +66,46 @@ public class Trees public static ConfiguredFeature MIRAGE_TREE; public static ConfiguredFeature DISTORTIC_TREE; + public static PlacedFeature INVERTED_TREE_FEATURE; + public static PlacedFeature INVERTED_TREE_FANCY_FEATURE; + public static PlacedFeature TEMPORAL_TREE_FEATURE; + public static PlacedFeature MEGA_TEMPORAL_TREE_FEATURE; + public static PlacedFeature AGED_PINE_TREE_FEATURE; + public static PlacedFeature AGED_SPRUCE_TREE_FEATURE; + public static PlacedFeature MEGA_AGED_PINE_TREE_FEATURE; + public static PlacedFeature MEGA_AGED_SPRUCE_TREE_FEATURE; + public static PlacedFeature CORRUPTED_TREE_FEATURE; + public static PlacedFeature MIRAGE_TREE_FEATURE; + public static PlacedFeature DISTORTIC_TREE_FEATURE; + public static final class States { public static final BlockState ULTRA_JUNGLE_GRASS = BlockInit.JUNGLE_GRASS.get().defaultBlockState(); - public static final BlockState ULTRA_AGED_GRASS = BlockInit.AGED_GRASS.get().defaultBlockState(); + public static final BlockState ULTRA_AGED_GRASS = BlockInit.AGED_GRASS.get().defaultBlockState(); } - public static TreeConfiguration getInvertedTree() + public static void init(final IEventBus bus) { - return new TreeConfiguration.TreeConfigurationBuilder( + TREE_DECORATORS.register(bus); + // Register this as a low priority, so that the tree decorator exists + // before we try to add it to the trees themseleves. + bus.addGenericListener(Feature.class, EventPriority.LOWEST, Trees::registerConfigured); + } + + public static TreeConfigurationBuilder getInvertedTree() + { + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.INVERTED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.INVERTED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new StraightTrunkPlacer(6, 4, 0), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.INVERTED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.INVERTED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.INVERTED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -81,28 +119,24 @@ public static TreeConfiguration getInvertedTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 0, 1)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getInvertedTreeFancy() + public static TreeConfigurationBuilder getInvertedTreeFancy() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.INVERTED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.INVERTED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new FancyTrunkPlacer(3, 11, 0), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.INVERTED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.INVERTED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.INVERTED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -116,28 +150,24 @@ public static TreeConfiguration getInvertedTreeFancy() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4))) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getTemporalTree() + public static TreeConfigurationBuilder getTemporalTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.TEMPORAL_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.TEMPORAL_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new StraightTrunkPlacer(6, 8, 0), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.TEMPORAL_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.TEMPORAL_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.TEMPORAL_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -152,29 +182,25 @@ public static TreeConfiguration getTemporalTree() // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(2, 0, 2)) .decorators(ImmutableList.of(TrunkStringOfPearlsDecorator.INSTANCE, LeavesStringOfPearlsDecorator.INSTANCE, - Features.Decorators.BEEHIVE_0002)) - .ignoreVines() - .build(); + BEEHIVE_0002)) + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getMegaTemporalTree() + public static TreeConfigurationBuilder getMegaTemporalTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.TEMPORAL_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.TEMPORAL_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new MegaJungleTrunkPlacer(12, 4, 24), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.TEMPORAL_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.TEMPORAL_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.TEMPORAL_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -189,28 +215,24 @@ public static TreeConfiguration getMegaTemporalTree() // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 1, 2)) .decorators(ImmutableList.of(TrunkStringOfPearlsDecorator.INSTANCE, LeavesStringOfPearlsDecorator.INSTANCE, - Features.Decorators.BEEHIVE_0002, new AlterGroundDecorator(new SimpleStateProvider(States.ULTRA_JUNGLE_GRASS)))) - .build(); + BEEHIVE_0002, new AlterGroundDecorator(BlockStateProvider.simple(States.ULTRA_JUNGLE_GRASS)))); //@formatter:on } - public static TreeConfiguration getAgedPineTree() + public static TreeConfigurationBuilder getAgedPineTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.AGED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new ForkingTrunkPlacer(7, 5, 0), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.AGED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.AGED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -224,28 +246,24 @@ public static TreeConfiguration getAgedPineTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 0, 1)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getAgedSpruceTree() + public static TreeConfigurationBuilder getAgedSpruceTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.AGED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new ForkingTrunkPlacer(8, 6, 0), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.AGED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.AGED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -259,28 +277,24 @@ public static TreeConfiguration getAgedSpruceTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 0, 1)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getMegaAgedPineTree() + public static TreeConfigurationBuilder getMegaAgedPineTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.AGED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new GiantTrunkPlacer(13, 2, 14), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.AGED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.AGED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -294,28 +308,25 @@ public static TreeConfiguration getMegaAgedPineTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 1, 2)) - .decorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002, new AlterGroundDecorator(new SimpleStateProvider(States.ULTRA_AGED_GRASS)))) - .build(); + .decorators(ImmutableList.of(BEEHIVE_0002, new AlterGroundDecorator(BlockStateProvider.simple(States.ULTRA_AGED_GRASS)))) + ; //@formatter:on } - public static TreeConfiguration getMegaAgedSpruceTree() + public static TreeConfigurationBuilder getMegaAgedSpruceTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.AGED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new GiantTrunkPlacer(13, 2, 14), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.AGED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.AGED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.AGED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -329,18 +340,18 @@ public static TreeConfiguration getMegaAgedSpruceTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 1, 2)) - .decorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002, new AlterGroundDecorator(new SimpleStateProvider(States.ULTRA_AGED_GRASS)))) - .build(); + .decorators(ImmutableList.of(BEEHIVE_0002, new AlterGroundDecorator(BlockStateProvider.simple(States.ULTRA_AGED_GRASS)))) + ; //@formatter:on } - public static TreeConfiguration getCorruptedTree() + public static TreeConfigurationBuilder getCorruptedTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.CORRUPTED_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.CORRUPTED_LOG.get().defaultBlockState()), //new BlobFoliagePlacer(FeatureSpread.fixed(2), FeatureSpread.fixed(0), 3), @@ -349,10 +360,7 @@ public static TreeConfiguration getCorruptedTree() new ForkingTrunkPlacer(6, 2, 3), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.CORRUPTED_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.CORRUPTED_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.CORRUPTED_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -366,28 +374,24 @@ public static TreeConfiguration getCorruptedTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 0, 2)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getMirageTree() + public static TreeConfigurationBuilder getMirageTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.MIRAGE_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.MIRAGE_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new StraightTrunkPlacer(10, 5, 15), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.MIRAGE_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.MIRAGE_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.MIRAGE_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -401,28 +405,24 @@ public static TreeConfiguration getMirageTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 1, 2)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static TreeConfiguration getDistorticTree() + public static TreeConfigurationBuilder getDistorticTree() { - return new TreeConfiguration.TreeConfigurationBuilder( + return new TreeConfigurationBuilder( //@formatter:off // This line specifies what is the base log, different block state providers // can allow for randomization in the log - new SimpleStateProvider(BlockInit.DISTORTIC_LOG.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.DISTORTIC_LOG.get().defaultBlockState()), // This is how the tree trunk works, there are also DarkOak, Fancy, // Forking, Giant, MegaJungle available new StraightTrunkPlacer(14, 2, 10), // This one is similar, but for the leaves - new SimpleStateProvider(BlockInit.DISTORTIC_LEAVES.get().defaultBlockState()), - - // This one is similar, but for the saplings - new SimpleStateProvider(BlockInit.DISTORTIC_SAPLING.get().defaultBlockState()), + BlockStateProvider.simple(BlockInit.DISTORTIC_LEAVES.get().defaultBlockState()), // This is how the leaves are arranged, this is the default for oak, there // are also AcaciaFoliagePlacer, DarkOak, Jungle, MegaPine, Pine and Spruce available @@ -436,49 +436,64 @@ public static TreeConfiguration getDistorticTree() // Different trees use a variety of the three values below, usually ranging from // 0 to 2, this example is from basic oak trees, but it can vary for different ones new TwoLayersFeatureSize(1, 0, 1)) - .ignoreVines() - .build(); + .ignoreVines(); //@formatter:on } - public static void register() + private static void registerPlacements() + { + Trees.INVERTED_TREE_FEATURE = PlacementUtils.register("pokecube_legends:inverted_tree", + INVERTED_TREE.filteredByBlockSurvival(BlockInit.INVERTED_SAPLING.get())); + Trees.INVERTED_TREE_FANCY_FEATURE = PlacementUtils.register("pokecube_legends:inverted_fancy_tree", + INVERTED_TREE_FANCY.filteredByBlockSurvival(BlockInit.INVERTED_SAPLING.get())); + Trees.TEMPORAL_TREE_FEATURE = PlacementUtils.register("pokecube_legends:temporal_tree", + TEMPORAL_TREE.filteredByBlockSurvival(BlockInit.TEMPORAL_SAPLING.get())); + Trees.MEGA_TEMPORAL_TREE_FEATURE = PlacementUtils.register("pokecube_legends:mega_temporal_tree", + MEGA_TEMPORAL_TREE.filteredByBlockSurvival(BlockInit.TEMPORAL_SAPLING.get())); + Trees.AGED_PINE_TREE_FEATURE = PlacementUtils.register("pokecube_legends:aged_pine_tree", + AGED_PINE_TREE.filteredByBlockSurvival(BlockInit.AGED_SAPLING.get())); + Trees.AGED_SPRUCE_TREE_FEATURE = PlacementUtils.register("pokecube_legends:aged_spruce_tree", + AGED_SPRUCE_TREE.filteredByBlockSurvival(BlockInit.AGED_SAPLING.get())); + Trees.MEGA_AGED_PINE_TREE_FEATURE = PlacementUtils.register("pokecube_legends:mega_aged_pine_tree", + MEGA_AGED_PINE_TREE.filteredByBlockSurvival(BlockInit.AGED_SAPLING.get())); + Trees.MEGA_AGED_SPRUCE_TREE_FEATURE = PlacementUtils.register("pokecube_legends:mega_aged_spruce_tree", + MEGA_AGED_SPRUCE_TREE.filteredByBlockSurvival(BlockInit.AGED_SAPLING.get())); + Trees.CORRUPTED_TREE_FEATURE = PlacementUtils.register("pokecube_legends:corrupted_tree", + CORRUPTED_TREE.filteredByBlockSurvival(BlockInit.CORRUPTED_SAPLING.get())); + Trees.MIRAGE_TREE_FEATURE = PlacementUtils.register("pokecube_legends:mirage_tree", + MIRAGE_TREE.filteredByBlockSurvival(BlockInit.MIRAGE_SAPLING.get())); + Trees.DISTORTIC_TREE_FEATURE = PlacementUtils.register("pokecube_legends:distortic_tree", + DISTORTIC_TREE.filteredByBlockSurvival(BlockInit.DISTORTIC_SAPLING.get())); + } + + private static void registerConfigured(final RegistryEvent.Register> event) { - Trees.INVERTED_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:inverted_tree", Trees.INVERTED_TREE = Feature.TREE.configured(Trees.getInvertedTree() - .withDecorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002)))); - Trees.INVERTED_TREE_FANCY = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:inverted_fancy_tree", Trees.INVERTED_TREE_FANCY = Feature.TREE.configured(Trees - .getInvertedTreeFancy().withDecorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002)))); - - Trees.TEMPORAL_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:temporal_tree", Trees.TEMPORAL_TREE = Feature.TREE.configured(Trees - .getTemporalTree())); - Trees.MEGA_TEMPORAL_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:mega_temporal_tree", Trees.MEGA_TEMPORAL_TREE = Feature.TREE.configured(Trees - .getMegaTemporalTree())); - - Trees.AGED_PINE_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:aged_pine_tree", Trees.AGED_PINE_TREE = Feature.TREE.configured(Trees.getAgedPineTree() - .withDecorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002)))); - Trees.AGED_SPRUCE_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:aged_spruce_tree", Trees.AGED_SPRUCE_TREE = Feature.TREE.configured(Trees.getAgedSpruceTree() - .withDecorators(ImmutableList.of(Features.Decorators.BEEHIVE_0002)))); - Trees.MEGA_AGED_PINE_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:mega_aged_pine_tree", Trees.MEGA_AGED_PINE_TREE = Feature.TREE.configured(Trees - .getMegaAgedPineTree())); - Trees.MEGA_AGED_SPRUCE_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:mega_aged_spruce_tree", Trees.MEGA_AGED_SPRUCE_TREE = Feature.TREE.configured(Trees - .getMegaAgedSpruceTree())); - - Trees.CORRUPTED_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:corrupted_tree", Trees.CORRUPTED_TREE = Feature.TREE.configured(Trees - .getCorruptedTree())); - - Trees.MIRAGE_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:mirage_tree", Trees.MIRAGE_TREE = Feature.TREE.configured(Trees.getMirageTree())); - - Trees.DISTORTIC_TREE = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, - "pokecube_legends:distortic_tree", Trees.DISTORTIC_TREE = Feature.TREE.configured(Trees - .getDistorticTree())); + Trees.INVERTED_TREE = FeatureUtils.register("pokecube_legends:inverted_tree", + Feature.TREE.configured(Trees.getInvertedTree().decorators(ImmutableList.of(BEEHIVE_0002)).build())); + Trees.INVERTED_TREE_FANCY = FeatureUtils.register("pokecube_legends:inverted_fancy_tree", Feature.TREE + .configured(Trees.getInvertedTreeFancy().decorators(ImmutableList.of(BEEHIVE_0002)).build())); + + Trees.TEMPORAL_TREE = FeatureUtils.register("pokecube_legends:temporal_tree", + Feature.TREE.configured(Trees.getTemporalTree().build())); + Trees.MEGA_TEMPORAL_TREE = FeatureUtils.register("pokecube_legends:mega_temporal_tree", + Feature.TREE.configured(Trees.getMegaTemporalTree().build())); + + Trees.AGED_PINE_TREE = FeatureUtils.register("pokecube_legends:aged_pine_tree", + Feature.TREE.configured(Trees.getAgedPineTree().decorators(ImmutableList.of(BEEHIVE_0002)).build())); + Trees.AGED_SPRUCE_TREE = FeatureUtils.register("pokecube_legends:aged_spruce_tree", + Feature.TREE.configured(Trees.getAgedSpruceTree().decorators(ImmutableList.of(BEEHIVE_0002)).build())); + Trees.MEGA_AGED_PINE_TREE = FeatureUtils.register("pokecube_legends:mega_aged_pine_tree", + Feature.TREE.configured(Trees.getMegaAgedPineTree().build())); + Trees.MEGA_AGED_SPRUCE_TREE = FeatureUtils.register("pokecube_legends:mega_aged_spruce_tree", + Feature.TREE.configured(Trees.getMegaAgedSpruceTree().build())); + + Trees.CORRUPTED_TREE = FeatureUtils.register("pokecube_legends:corrupted_tree", + Feature.TREE.configured(Trees.getCorruptedTree().build())); + + Trees.MIRAGE_TREE = FeatureUtils.register("pokecube_legends:mirage_tree", + Feature.TREE.configured(Trees.getMirageTree().build())); + + Trees.DISTORTIC_TREE = FeatureUtils.register("pokecube_legends:distortic_tree", + Feature.TREE.configured(Trees.getDistorticTree().build())); } } diff --git a/src/main/java/pokecube/legends/worldgen/features/treedecorators/LeavesStringOfPearlsDecorator.java b/src/main/java/pokecube/legends/worldgen/trees/treedecorators/LeavesStringOfPearlsDecorator.java similarity index 72% rename from src/main/java/pokecube/legends/worldgen/features/treedecorators/LeavesStringOfPearlsDecorator.java rename to src/main/java/pokecube/legends/worldgen/trees/treedecorators/LeavesStringOfPearlsDecorator.java index b1923459b4..ea26b7324b 100644 --- a/src/main/java/pokecube/legends/worldgen/features/treedecorators/LeavesStringOfPearlsDecorator.java +++ b/src/main/java/pokecube/legends/worldgen/trees/treedecorators/LeavesStringOfPearlsDecorator.java @@ -1,4 +1,4 @@ -package pokecube.legends.worldgen.features.treedecorators; +package pokecube.legends.worldgen.trees.treedecorators; import java.util.List; import java.util.Random; @@ -16,48 +16,47 @@ import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import pokecube.legends.blocks.plants.StringOfPearlsBlock; import pokecube.legends.init.BlockInit; -import pokecube.legends.worldgen.WorldgenFeatures; +import pokecube.legends.worldgen.trees.Trees; public class LeavesStringOfPearlsDecorator extends TreeDecorator { public static final Codec CODEC; - public static final LeavesStringOfPearlsDecorator INSTANCE = new LeavesStringOfPearlsDecorator(); + public static final LeavesStringOfPearlsDecorator INSTANCE = new LeavesStringOfPearlsDecorator(); @Override public TreeDecoratorType type() { - return WorldgenFeatures.LEAVES_STRING_OF_PEARLS.get(); + return Trees.LEAVES_STRING_OF_PEARLS.get(); } @Override public void place(final LevelSimulatedReader world, final BiConsumer blockPos, final Random random, final List listPos, final List listPos1) { - listPos1.forEach((listedPos) -> - { + listPos1.forEach((listedPos) -> { if (random.nextInt(4) == 0) { final BlockPos pos = listedPos.west(); - if (Feature.isAir(world, pos)) LeavesStringOfPearlsDecorator.addHangingVine(world, pos, VineBlock.EAST, - blockPos, random); + if (Feature.isAir(world, pos)) + LeavesStringOfPearlsDecorator.addHangingVine(world, pos, VineBlock.EAST, blockPos, random); } if (random.nextInt(4) == 0) { final BlockPos pos1 = listedPos.east(); - if (Feature.isAir(world, pos1)) LeavesStringOfPearlsDecorator.addHangingVine(world, pos1, - VineBlock.WEST, blockPos, random); + if (Feature.isAir(world, pos1)) + LeavesStringOfPearlsDecorator.addHangingVine(world, pos1, VineBlock.WEST, blockPos, random); } if (random.nextInt(4) == 0) { final BlockPos pos2 = listedPos.north(); - if (Feature.isAir(world, pos2)) LeavesStringOfPearlsDecorator.addHangingVine(world, pos2, - VineBlock.SOUTH, blockPos, random); + if (Feature.isAir(world, pos2)) + LeavesStringOfPearlsDecorator.addHangingVine(world, pos2, VineBlock.SOUTH, blockPos, random); } if (random.nextInt(4) == 0) { final BlockPos pos3 = listedPos.south(); - if (Feature.isAir(world, pos3)) LeavesStringOfPearlsDecorator.addHangingVine(world, pos3, - VineBlock.NORTH, blockPos, random); + if (Feature.isAir(world, pos3)) + LeavesStringOfPearlsDecorator.addHangingVine(world, pos3, VineBlock.NORTH, blockPos, random); } }); } @@ -85,8 +84,7 @@ public static void placeVine(final BiConsumer blockPos, fi static { - CODEC = Codec.unit(() -> - { + CODEC = Codec.unit(() -> { return LeavesStringOfPearlsDecorator.INSTANCE; }); } diff --git a/src/main/java/pokecube/legends/worldgen/trees/treedecorators/TrunkStringOfPearlsDecorator.java b/src/main/java/pokecube/legends/worldgen/trees/treedecorators/TrunkStringOfPearlsDecorator.java new file mode 100644 index 0000000000..1f436b0c0e --- /dev/null +++ b/src/main/java/pokecube/legends/worldgen/trees/treedecorators/TrunkStringOfPearlsDecorator.java @@ -0,0 +1,87 @@ +package pokecube.legends.worldgen.trees.treedecorators; + +import java.util.List; +import java.util.Random; +import java.util.function.BiConsumer; + +import com.mojang.serialization.Codec; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelSimulatedReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; +import pokecube.legends.blocks.plants.StringOfPearlsBlock; +import pokecube.legends.init.BlockInit; +import pokecube.legends.worldgen.trees.Trees; + +public class TrunkStringOfPearlsDecorator extends TreeDecorator +{ + public static final Codec CODEC; + public static final TrunkStringOfPearlsDecorator INSTANCE = new TrunkStringOfPearlsDecorator(); + + protected TreeDecoratorType type() + { + return Trees.TRUNK_STRING_OF_PEARLS.get(); + } + + @Override + public void place(LevelSimulatedReader world, BiConsumer blockPos, Random random, + List listPos, List listPos1) + { + listPos.forEach((listedPos) -> { + if (random.nextInt(3) > 0) + { + BlockPos pos = listedPos.west(); + if (Feature.isAir(world, pos)) + { + placeVine(blockPos, pos, StringOfPearlsBlock.EAST, random); + } + } + + if (random.nextInt(3) > 0) + { + BlockPos pos1 = listedPos.east(); + if (Feature.isAir(world, pos1)) + { + placeVine(blockPos, pos1, StringOfPearlsBlock.WEST, random); + } + } + + if (random.nextInt(3) > 0) + { + BlockPos pos2 = listedPos.north(); + if (Feature.isAir(world, pos2)) + { + placeVine(blockPos, pos2, StringOfPearlsBlock.SOUTH, random); + } + } + + if (random.nextInt(3) > 0) + { + BlockPos pos3 = listedPos.south(); + if (Feature.isAir(world, pos3)) + { + placeVine(blockPos, pos3, StringOfPearlsBlock.NORTH, random); + } + } + + }); + } + + public static void placeVine(BiConsumer blockPos, BlockPos pos, BooleanProperty b, + Random random) + { + blockPos.accept(pos, BlockInit.STRING_OF_PEARLS.get().defaultBlockState().setValue(b, Boolean.valueOf(true)) + .setValue(StringOfPearlsBlock.FLOWERS, Boolean.valueOf(random.nextFloat() < 0.11F))); + } + + static + { + CODEC = Codec.unit(() -> { + return INSTANCE; + }); + } +} \ No newline at end of file