Jump to content

How do i registerbootstrap(BootstapContext<PlacedFeature> context)


yusufgamer

Recommended Posts

I am trying to figure out hot to register my ore gen

 

this is my code 

public class OreFeaturesInit {

    public static final ResourceKey<ConfiguredFeature<?, ?>> LEGENDARY_ORE =
            FeatureUtils.createKey("legendary_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> RUBY_ORE =
            FeatureUtils.createKey("ruby_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> BLACK_DIAMOND_ORE =
            FeatureUtils.createKey("black_diamond_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> IMPERIUM_ORE =
            FeatureUtils.createKey("imperium_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> SPEED_ORE =
            FeatureUtils.createKey("speed_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> OMNITRIX_ORE =
            FeatureUtils.createKey("omnitrix_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> FIRE_ORE =
            FeatureUtils.createKey("fire_ore");
    public static final ResourceKey<ConfiguredFeature<?, ?>> INFINITUM_ORE =
            FeatureUtils.createKey("infinitum_ore");

    public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
        RuleTest ruleTest1 = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
        RuleTest ruleTest2 = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
        RuleTest ruleTest3 = new BlockMatchTest(Blocks.NETHERRACK);
        RuleTest ruleTest4 = new TagMatchTest(BlockTags.BASE_STONE_NETHER);

        List<OreConfiguration.TargetBlockState> legendary = List.of(
                OreConfiguration.target(ruleTest1,
                        BlockInit.LEGENDARY_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2,
                        BlockInit.LEGENDARY_ORE.get().defaultBlockState()));
        List<OreConfiguration.TargetBlockState> ruby = List.of(
                OreConfiguration.target(ruleTest1, BlockInit.RUBY_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2, BlockInit.RUBY_ORE.get().defaultBlockState()));
        List<OreConfiguration.TargetBlockState> black_diamond = List.of(
                OreConfiguration.target(ruleTest1,
                        BlockInit.BLACK_DIAMOND_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2,
                        BlockInit.BLACK_DIAMOND_ORE.get().defaultBlockState()));
        List<OreConfiguration.TargetBlockState> imperium = List.of(
                OreConfiguration.target(ruleTest1,
                        BlockInit.IMPERIUM_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2,
                        BlockInit.IMPERIUM_ORE.get().defaultBlockState()));
        List<OreConfiguration.TargetBlockState> speed = List.of(
                OreConfiguration.target(ruleTest1, BlockInit.SPEED_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2, BlockInit.SPEED_ORE.get().defaultBlockState()));
        List<OreConfiguration.TargetBlockState> omnitrix = List.of(
                OreConfiguration.target(ruleTest1,
                        BlockInit.OMNITRIX_ORE.get().defaultBlockState()),
                OreConfiguration.target(ruleTest2,
                        BlockInit.OMNITRIX_ORE.get().defaultBlockState()));

        registerOre(context, LEGENDARY_ORE, legendary, 7);
        registerOre(context, RUBY_ORE, ruby, 7);
        registerOre(context, BLACK_DIAMOND_ORE, black_diamond, 5);
        registerOre(context, IMPERIUM_ORE, imperium, 5);
        registerOre(context, SPEED_ORE, speed, 5);
        registerOre(context, OMNITRIX_ORE, omnitrix, 5);
        registerOre(context, FIRE_ORE, ruleTest3, BlockInit.FIRE_ORE.get().defaultBlockState(), 6);
        registerOre(context, INFINITUM_ORE, ruleTest4,
                BlockInit.INFINITUM_ORE.get().defaultBlockState(), 4);
    }

    private static void registerOre(BootstapContext<ConfiguredFeature<?, ?>> context,
            ResourceKey<ConfiguredFeature<?, ?>> ore,
            List<OreConfiguration.TargetBlockState> targetBlockStates, int size) {
        FeatureUtils.register(context, ore, Feature.ORE,
                new OreConfiguration(targetBlockStates, size));
    }

    private static void registerOre(BootstapContext<ConfiguredFeature<?, ?>> context,
            ResourceKey<ConfiguredFeature<?, ?>> ore, RuleTest ruleTest, BlockState blockState,
            int size) {
        FeatureUtils.register(context, ore, Feature.ORE,
                new OreConfiguration(ruleTest, blockState, size));
    }
}

 

Link to comment
Share on other sites

Directly modifying the vanilla builtin registries is not the correct way to do it.

 

Before 1.19.3 you could use the standard DeferredRegister mechanism

https://forums.minecraftforge.net/topic/115928-1182-error-trying-to-register-a-custom-feature-based-on-kelpfeature-solved/?do=findComment&comment=512366

I haven't tried doing that in 1.19.3 after Mojang refactored it all so I don't have an example.

 

The recommended way to do it though is to register your Placed/Configured features using json. Like any normal datapack.

https://forums.minecraftforge.net/topic/118924-solved-1193-placedfeature-register/#comment-522171

 

I believe you can also generate them using datagen? e.g.

https://github.com/BluSunrize/ImmersiveEngineering/blob/1.19.3/src/datagen/java/blusunrize/immersiveengineering/data/WorldGenerationProvider.java

I haven't tried this myself either.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.