Here is the code I have currently:
ModConfiguredFeatures.java:
package net.KaiHallow.magicalcraft.worldgen;
import net.KaiHallow.magicalcraft.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import java.util.List;
//This is just to be able to use the variable in a way that keeps the code cleaner and less confusing
import static net.KaiHallow.magicalcraft.MagicalCraft.MOD_ID;
public class ModConfiguredFeatures
{
public static final ResourceKey<ConfiguredFeature<?,?>> LIGHTNING_CRYSTAL_ORE = registerKey("lightning_crystal_ore");
public static final ResourceKey<ConfiguredFeature<?,?>> DEEPSLATE_LIGHTNING_CRYSTAL_ORE = registerKey("deepslate_lightning_crystal_ore");
public static ResourceKey<ConfiguredFeature<?,?>> registerKey(String name)
{
return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(MOD_ID, name));
}
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context)
{
RuleTest stonereplaceables = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
RuleTest deepslatereplaceables = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
register(context, LIGHTNING_CRYSTAL_ORE, Feature.ORE, new OreConfiguration(stonereplaceables, ModBlocks.LIGHTNING_CRYSTAL_ORE.get().defaultBlockState(), 8, 0.2F));
register(context, DEEPSLATE_LIGHTNING_CRYSTAL_ORE, Feature.ORE, new OreConfiguration(deepslatereplaceables, ModBlocks.DEEPSLATE_LIGHTNING_CRYSTAL_ORE.get().defaultBlockState(), 8, 0.5F));
}
public static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context,
ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC config) {
context.register(key, new ConfiguredFeature<>(feature, config));
}
}
ModPlacementFeatures.java:
package net.KaiHallow.magicalcraft.worldgen;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.*;
import java.util.List;
import static net.KaiHallow.magicalcraft.MagicalCraft.MOD_ID;
public class ModPlacementFeatures
{
public static final ResourceKey<PlacedFeature> LIGHTNING_CRYSTAL_ORE_UPPER = registerKey("lightning_crystal_ore_upper");
public static final ResourceKey<PlacedFeature> LIGHTNING_CRYSTAL_ORE_MIDDLE = registerKey("lightning_crystal_ore_middle");
public static final ResourceKey<PlacedFeature> LIGHTNING_CRYSTAL_ORE_LOWER = registerKey("lightning_crystal_ore_lower");
private static List<PlacementModifier> orePlacement(PlacementModifier count, PlacementModifier heightRange) {
return List.of(count, InSquarePlacement.spread(), heightRange, BiomeFilter.biome());
}
private static List<PlacementModifier> commonOrePlacement(int pCount, PlacementModifier pHeightRange) {
return orePlacement(CountPlacement.of(pCount), pHeightRange);
}
private static List<PlacementModifier> rareOrePlacement(int pChance, PlacementModifier pHeightRange) {
return orePlacement(RarityFilter.onAverageOnceEvery(pChance), pHeightRange);
}
public static void bootstrap(BootstapContext<PlacedFeature> context)
{
HolderGetter<ConfiguredFeature<?,?>> holderGetter = context.lookup(Registries.CONFIGURED_FEATURE);
register(context, LIGHTNING_CRYSTAL_ORE_UPPER, holderGetter.getOrThrow(ModConfiguredFeatures.LIGHTNING_CRYSTAL_ORE), commonOrePlacement(90, HeightRangePlacement.triangle(VerticalAnchor.absolute(150), VerticalAnchor.absolute(319))));
register(context, LIGHTNING_CRYSTAL_ORE_MIDDLE, holderGetter.getOrThrow(ModConfiguredFeatures.LIGHTNING_CRYSTAL_ORE), commonOrePlacement(40, HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(150))));
register(context, LIGHTNING_CRYSTAL_ORE_LOWER, holderGetter.getOrThrow(ModConfiguredFeatures.DEEPSLATE_LIGHTNING_CRYSTAL_ORE), commonOrePlacement(15, HeightRangePlacement.triangle(VerticalAnchor.absolute(-63), VerticalAnchor.absolute(-1))));
}
public static ResourceKey<PlacedFeature> registerKey(String name)
{
return ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(MOD_ID, name));
}
public static void register(BootstapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuredFeature, List<PlacementModifier> placements) {
context.register(key, new PlacedFeature(configuredFeature, List.copyOf(placements)));
}
public static void register(BootstapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuredFeatures, PlacementModifier... placements) {
register(context, key, configuredFeatures, List.of(placements));
}
}
ModWorldGenerator.java
package net.KaiHallow.magicalcraft.datagen;
import net.KaiHallow.magicalcraft.worldgen. ModConfiguredFeatures;
import net.KaiHallow.magicalcraft.worldgen. ModPlacementFeatures;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import static net.KaiHallow.magicalcraft.MagicalCraft.MOD_ID;
public class ModWorldGenerator extends DatapackBuiltinEntriesProvider
{
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, ModConfiguredFeatures::bootstrap)
.add(Registries.PLACED_FEATURE, ModPlacementFeatures::bootstrap);
public ModWorldGenerator(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries, BUILDER, Set.of(MOD_ID));
}
}
My problem is while it creates the json files, everything with said json files being as they should be, the ore refuses to generate, however just in case there is something wrong in them here they are:
worldgen > configured_feature > lightning_crystal_ore.json
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.2,
"size": 8,
"targets": [
{
"state": {
"Name": "magicalcraft:lightning_crystal_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
}
]
}
}
worldgen > configured_feature > deepslate_lightning_crystal_ore.json
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.5,
"size": 8,
"targets": [
{
"state": {
"Name": "magicalcraft:deepslate_lightning_crystal_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
}
worldgen > placed_feature > lightning_crystal_ore_upper.json
{
"feature": "magicalcraft:lightning_crystal_ore",
"placement": [
{
"type": "minecraft:count",
"count": 90
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": 319
},
"min_inclusive": {
"absolute": 150
}
}
},
{
"type": "minecraft:biome"
}
]
}
worldgen > placed_feature > lightning_crystal_ore_middle.json
{
"feature": "magicalcraft:lightning_crystal_ore",
"placement": [
{
"type": "minecraft:count",
"count": 40
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": 150
},
"min_inclusive": {
"absolute": 0
}
}
},
{
"type": "minecraft:biome"
}
]
}
worldgen > placed_feature > lightning_crystal_ore_lower.json
{
"feature": "magicalcraft:deepslate_lightning_crystal_ore",
"placement": [
{
"type": "minecraft:count",
"count": 15
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": -1
},
"min_inclusive": {
"absolute": -63
}
}
},
{
"type": "minecraft:biome"
}
]
}
can someone tell me what is wrong, why it won’t generate? (Note: I have the blocks registered and tags, models, and blockstates made for them and everything, I followed a tutorial for all that) I’ve looked everywhere but I cannot seem to find a solution, there are no errors, game boots up just fine without a hitch, and the ore just will not generate.
I’ve tried this, I’ve tried messing with the registration where the blocks get registered, I’ve tried messing with the tags, and nothing. As the question states, this was supposed to make my custom ore generate in the world but it won’t generate, it exists in the creative inventory and can be placed and destroyed, but it won’t generate.