Jump to content

[1.16.3] Add custom generation


Maciej916

Recommended Posts

Hello, I'm having troubles with adding custom generation on 1.16.3. I used solution from this post https://forums.minecraftforge.net/topic/90560-1162-how-to-add-custom-ore-to-world-generation/ and it's working for ores but i also want to add new tree and Im getting cast error

RubberTreeBlockStateProvider cannot be cast to net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider

 Code I use:

    public static void initGen() {
        Registry.register(
                WorldGenRegistries.CONFIGURED_FEATURE,
                ModBlocks.COPPER_ORE.getRegistryName(),
                Feature.ORE
                        .withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.field_241882_a /* base_stone_overworld */, ModBlocks.COPPER_ORE.getDefaultState(), ModConfig.worldgen_copper_size))
                        .withPlacement(Placement.field_242907_l/* RANGE */.configure(new TopSolidRangeConfig(ModConfig.worldgen_copper_min_height, 0, ModConfig.worldgen_copper_max_height)))
                        .func_242728_a() /* spreadHorizontally */
                        .func_242731_b(ModConfig.worldgen_copper_size) /* repeat */
        );


        Registry.register(
                WorldGenRegistries.CONFIGURED_FEATURE /* Feature Registering */,
                ModBlocks.RUBBER_SAPLING.getRegistryName() /* Resource Location */,
                Feature.TREE /* no_surface_ore */.withConfiguration(RUBBER_TREE_CONFIG)
                        .withPlacement(Placement.field_242902_f/* RANGE */.configure(new AtSurfaceWithExtraConfig(12, 12, 72)))
        );

    }

    public static void setupGen() {
        for (Map.Entry<RegistryKey<Biome>, Biome> biome : WorldGenRegistries.BIOME.getEntries() /* Collection of Biome Entries */) {
            if (!biome.getValue().getCategory().equals(Biome.Category.NETHER) && !biome.getValue().getCategory().equals(Biome.Category.THEEND)) {

                addFeatureToBiome(
                        biome.getValue(),
                        GenerationStage.Decoration.UNDERGROUND_ORES,
                        WorldGenRegistries.CONFIGURED_FEATURE.getOrDefault(ModBlocks.COPPER_ORE.getRegistryName())
                );

                addFeatureToBiome(
                        biome.getValue(),
                        GenerationStage.Decoration.VEGETAL_DECORATION,
                        WorldGenRegistries.CONFIGURED_FEATURE.getOrDefault(ModBlocks.RUBBER_SAPLING.getRegistryName())
                );
            }
        }
    }

    public static void addFeatureToBiome(Biome biome, GenerationStage.Decoration decoration, ConfiguredFeature<?, ?> configuredFeature) {
        List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = new ArrayList<>(
                biome.getGenerationSettings().getFeatures()/* List of Configured Features */
        );

        while (biomeFeatures.size() <= decoration.ordinal()) {
            biomeFeatures.add(Lists.newArrayList());
        }

        List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(biomeFeatures.get(decoration.ordinal()));
        features.add(() -> configuredFeature);
        biomeFeatures.set(decoration.ordinal(), features);

        ObfuscationReflectionHelper.setPrivateValue(BiomeGenerationSettings.class, biome.getGenerationSettings(), biomeFeatures, "features");
    }

 

Rubber tree:

public class RubberTree extends Tree {

    public static final BaseTreeFeatureConfig RUBBER_TREE_CONFIG = (
            new BaseTreeFeatureConfig.Builder(
                    new RubberTreeBlockStateProvider(ModBlocks.RUBBER_LOG.getDefaultState()),
                    new SimpleBlockStateProvider(ModBlocks.RUBBER_LEAVES.getDefaultState()),
                    new RubberFoliagePlacer(2, 0),
                    new StraightTrunkPlacer(4, 2, 0),
                    new TwoLayerFeature(1, 0, 1))
    ).build();

    @Nullable
    @Override
    protected ConfiguredFeature<BaseTreeFeatureConfig, ?> getTreeFeature(Random randomIn, boolean p_225546_2_) {
        return Feature.TREE.withConfiguration(RUBBER_TREE_CONFIG);
    }
}

 

Is there a simple solution to fix this? I can add that tree is working correctly in game, Im only having troubles to add it to generation.

Edited by Maciej916
Link to comment
Share on other sites

1 minute ago, Maciej916 said:

RubberTreeBlockStateProvider cannot be cast to net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider

I think that statement should be self explanatory if you understand java well enough.

 

Also, 1.16.3 has a new way of registering features for biomes via BiomeLoadingEvent. Use that instead over this outdated makeshift answer which would result in a lot of concurrency issues.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Also wondering how to create these manually.  First time creating a forge server.
    • Exception in thread "main" java.lang.IllegalStateException: Could not find forge-1.19-41.1.0 in classpath at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonDevLaunchHandler.lambda$findJarOnClasspath$3(CommonDevLaunchHandler.java:90) at java.base/java.util.Optional.orElseThrow(Optional.java:403) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonDevLaunchHandler.findJarOnClasspath(CommonDevLaunchHandler.java:90) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler.processStreams(ForgeUserdevLaunchHandler.java:17) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonUserdevLaunchHandler.getMinecraftPaths(CommonUserdevLaunchHandler.java:32) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator.scanMods(MinecraftLocator.java:36) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:74) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:166) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.FMLServiceProvider.beginScanning(FMLServiceProvider.java:86) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:112) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:100) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:102) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:55) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.Launcher.run(Launcher.java:88) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.Launcher.main(Launcher.java:78) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) I tried to make a minecraft mod but this error appears every time I click on the RunClient button and it won't start. Does anyone know how to get rid of this? (btw. I'm using version 1.19.2-43.3.5) https://pastebin.com/mQ3q4SwW
    • I've been following the discussion on automatically downloading mods from server to client, and I thought I'd share a helpful resource I stumbled upon. If you're looking for high-quality images for your mods or any other project, Depositphotos offers a fantastic collection for free download: free download images. In the spirit of collaboration, I believe that access to free, high-resolution visuals can greatly enhance the overall modding experience. Feel free to explore the link, and let me know what you think. Looking forward to hearing your thoughts and ideas on how we can collectively improve mod development efficiency.
    • Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira
    • full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.