Jump to content

[1.16.3] Generate a vegetal decoration


Timebreaker900

Recommended Posts

Hi, 

I'm trying to generate a bush object in 1.16.3 and I need some help with it.

This is my attempt:

 

public static void initBushes() {
        Registry.register(WorldGenRegistries.field_243653_e, BlockInit.XP_BUSH.get().getRegistryName(),
                Feature.FLOWER
                        .withConfiguration(init.XP_BUSH)
                        .withPlacement(Placement.field_242907_l
                                .configure(new TopSolidRangeConfig(5, 5, 128))
                        )
        );
    }
    public static void setupBushes() {
        for (Map.Entry<RegistryKey<Biome>, Biome> biome : WorldGenRegistries.field_243657_i.func_239659_c_()) {
            if (!biome.getValue().getCategory().equals(Biome.Category.NETHER) && !biome.getValue().getCategory().equals(Biome.Category.THEEND)) {
                addFeatureToBiome(biome.getValue(), GenerationStage.Decoration.VEGETAL_DECORATION,
                        WorldGenRegistries.field_243653_e.getOrDefault(BlockInit.XP_BUSH.get().getRegistryName()));
            }
        }
    }

private static void addFeatureToBiome(Biome biome, GenerationStage.Decoration vegetalDecoration, ConfiguredFeature<?, ?> configuredFeature) {
        List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = new ArrayList<>(biome.func_242440_e().func_242498_c());
        while (biomeFeatures.size() <= vegetalDecoration.ordinal()) {
            biomeFeatures.add(Lists.newArrayList());
        }
        List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(biomeFeatures.get(vegetalDecoration.ordinal()));
        features.add(() -> configuredFeature);
        biomeFeatures.set(vegetalDecoration.ordinal(), features);

        ObfuscationReflectionHelper.setPrivateValue(BiomeGenerationSettings.class, biome.func_242440_e(), biomeFeatures,"field_242484_f");
    }

 

I can't get it to work.

 

If you need more code here is my github: https://github.com/Timebreaker900/MetalBushesMod/tree/1.16.3

 

Thanks in advance!!!

Edited by Timebreaker900
Link to comment
Share on other sites

First, Problematic Code 11.

Second, no need to register the configured feature.

Third, you need to defer execution of the configs

Fourth, one try will fail about 99.9% of the time.

Fifth, you don't need to register the configured feature.

Sixth, try to avoid using someone else's source as a direct reference as it most likely has problems of its own. Instead, indirectly view the code and try to understand what it's attempting to do and apply the underlying logic in the correct method.

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.

Announcements



×
×
  • Create New...

Important Information

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