Jump to content

MinecraftForge 1.19.3 Ore Generation (Java Edition)


CodingNoob52

Recommended Posts

Tutorials for modding Minecraft using Minecraftforge use a constant called BuiltInRegistries.CONFIGURED_FEATURE to allow a mod to register a custom feature. This constant is missing from Minecraft 1.19.3.

Does anyone know what this has been replaced with in 1.19.3 or know of an updated tutorial. Here's what we're doing:

 

final Block MY_ORE_BLOCK = Registry.register(BuiltInRegistries.BLOCK, "my_ore", new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(3, 7))); final ResourceKey<ConfiguredFeature<?, ?>> MY_ORE_LARGE = FeatureUtils.createKey("my_ore_large"); List<OreConfiguration.TargetBlockState> list = List.of(OreConfiguration.target(ruletest1, MY_ORE_BLOCK.defaultBlockState())); ConfiguredFeature<?,?> feature = new ConfiguredFeature(Feature.ORE, new OreConfiguration(list, 4, 0.5F)); Registry.register(BuiltInRegistries.CONFIGURED_FEATURE, MY_ORE_LARGE, feature);

 

The purpose of the code being to create a new type of Ore and to register it as a feature so that the world generator generates deposits of it.

We tried to compile, but BuiltInRegistries doesn't have a CONFIGURED_FEATURE constant in 1.19.3 so that doesn't compile. We also tried to use FeatureUtils.register() to register the feature but couldn't find how to get a BootstapContext to pass to its first parameter.

Link to comment
Share on other sites

I found the solution to my problem:

In net.minecraftforge.common.world.ForgeBiomeModifiers there is a description of a json format used to add features to any existing biomes. I created a add_my_ore.json file in data/MYMOD/forge/biome_modifier/:

{
  "type": "forge:add_features",
  "biomes": "#minecraft:is_overworld",
  "features": ["examplemod:ore_mine","examplemod:ore_mine_large"],
  "step": "underground_ores"
}

I then add jsons to describe my ore feature in data/MYMOD/worldgen/configured_feature/ and data/MYMOD/worldgen/placed_feature/

For example, in configured feature: ore_mine.json

{
  "type": "minecraft:ore",
  "config": {
    "discard_chance_on_air_exposure": 0.0,
    "size": 20,
    "targets": [
      {
        "state": {
          "Name": "MYMOD:my_ore"
        },
        "target": {
          "predicate_type": "minecraft:tag_match",
          "tag": "minecraft:stone_ore_replaceables"
        }
      },
      {
        "state": {
          "Name": "MYMOD:my_ore"
        },
        "target": {
          "predicate_type": "minecraft:tag_match",
          "tag": "minecraft:deepslate_ore_replaceables"
        }
      }
    ]
  }
}

And in placed_feature: ore_mine.json

{
  "feature": "examplemod:ore_mine",
  "placement": [
    {
      "type": "minecraft:count",
      "count": 16
    },
    {
      "type": "minecraft:in_square"
    },
    {
      "type": "minecraft:height_range",
      "height": {
        "type": "minecraft:trapezoid",
        "max_inclusive": {
          "absolute": 112
        },
        "min_inclusive": {
          "absolute": -16
        }
      }
    },
    {
      "type": "minecraft:biome"
    }
  ]
}

This combination of files causes forge to create a ConfiguredFeature to add my custom ore using the same built-in class that places built-in ores, and adds this feature to all Biomes. Of course, I still needed to write the code to define my custom ore, but this solved the world-gen part.

Link to comment
Share on other sites

  • 4 weeks later...

I think I've got the solution, but @CodingNoob52, what do i import to make the "java class work. aka what imports make 

 "final Block MY_ORE_BLOCK = Registry.register(BuiltInRegistries.BLOCK, "my_ore", new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(3, 7))); final ResourceKey<ConfiguredFeature<?, ?>> MY_ORE_LARGE = FeatureUtils.createKey("my_ore_large"); List<OreConfiguration.TargetBlockState> list = List.of(OreConfiguration.target(ruletest1, MY_ORE_BLOCK.defaultBlockState())); ConfiguredFeature<?,?> feature = new ConfiguredFeature(Feature.ORE, new OreConfiguration(list, 4, 0.5F)); Registry.register(BuiltInRegistries.CONFIGURED_FEATURE, MY_ORE_LARGE, feature);" 

work.

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.



×
×
  • Create New...

Important Information

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