Jump to content

Defective Ore Generation


TeineOne

Recommended Posts

I'm making a mod that adds various ores and materials to the game. Some of (not all) of the materials are failing to generate, and I can't figure it out for the life of me. It's been two days of trying to figure it out myself, but nothing's worked so I came here.

 

The Configured Features class (the ores that work are the following - Tin, Deepslate Tin, Crimson Shroomite, and Chorite):

package com.teineone.new_world.world.feature;

import com.google.common.base.Suppliers;
import com.teineone.new_world.NewWorld;
import com.teineone.new_world.block.ModBlocks;
import net.minecraft.core.Registry;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;
import java.util.function.Supplier;

public class ModConfiguredFeatures {
    public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES =
            DeferredRegister.create(Registry.CONFIGURED_FEATURE_REGISTRY, NewWorld.MOD_ID);

    public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_ORES = Suppliers.memoize(() -> List.of(
            OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.TIN_ORE.get().defaultBlockState()),
            OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_TIN_ORE.get().defaultBlockState()),
            OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.MITHRIL_ORE.get().defaultBlockState())));
    public static final Supplier<List<OreConfiguration.TargetBlockState>> NETHER_ORES = Suppliers.memoize(() -> List.of(
            OreConfiguration.target(OreFeatures.NETHER_ORE_REPLACEABLES, ModBlocks.CRIMSON_SHROOMITE_ORE.get().defaultBlockState()),
            OreConfiguration.target(OreFeatures.NETHER_ORE_REPLACEABLES, ModBlocks.WARPED_SHROOMITE_ORE.get().defaultBlockState()),
            OreConfiguration.target(OreFeatures.NETHER_ORE_REPLACEABLES, ModBlocks.TITANIUM_ORE.get().defaultBlockState())));
    public static final Supplier<List<OreConfiguration.TargetBlockState>> END_ORES = Suppliers.memoize(() -> List.of(
            OreConfiguration.target(new BlockMatchTest(Blocks.END_STONE), ModBlocks.CHORITE_ORE.get().defaultBlockState()),
            OreConfiguration.target(new BlockMatchTest(Blocks.END_STONE), ModBlocks.TUNGSTEN_ORE.get().defaultBlockState()),
            OreConfiguration.target(new BlockMatchTest(Blocks.END_STONE), ModBlocks.ADAMANTINE_ORE.get().defaultBlockState())));

    public static final RegistryObject<ConfiguredFeature<?, ?>> TIN_ORE = CONFIGURED_FEATURES.register("tin_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_ORES.get(), 7)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> DEEPSLATE_TIN_ORE = CONFIGURED_FEATURES.register("deepslate_tin_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_ORES.get(), 7)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> MITHRIL_ORE = CONFIGURED_FEATURES.register("mithril_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_ORES.get(), 7)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> CRIMSON_SHROOMITE_ORE = CONFIGURED_FEATURES.register("crimson_shroomite_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(NETHER_ORES.get(), 9)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> WARPED_SHROOMITE_ORE = CONFIGURED_FEATURES.register("warped_shroomite_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(NETHER_ORES.get(), 9)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> TITANIUM_ORE = CONFIGURED_FEATURES.register("titanium_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(NETHER_ORES.get(), 7)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> CHORITE_ORE = CONFIGURED_FEATURES.register("chorite_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(END_ORES.get(), 9)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> TUNGSTEN_ORE = CONFIGURED_FEATURES.register("tungsten_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(END_ORES.get(), 7)));
    public static final RegistryObject<ConfiguredFeature<?, ?>> ADAMANTINE_ORE = CONFIGURED_FEATURES.register("adamantine_ore",
            () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(END_ORES.get(), 7)));

    public static void register(IEventBus eventBus) {
        CONFIGURED_FEATURES.register(eventBus);
    }
}

The placed features class (again, functioning ores are mentioned above):

package com.teineone.new_world.world.feature;

import com.teineone.new_world.NewWorld;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.placement.*;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;

public class ModPlacedFeatures {
    public static final DeferredRegister<PlacedFeature> PLACED_FEATURES =
            DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, NewWorld.MOD_ID);


    public static final RegistryObject<PlacedFeature> TIN_ORE_PLACED = PLACED_FEATURES.register("tin_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.TIN_ORE.getHolder().get(), commonOrePlacement(18,
                            HeightRangePlacement.triangle(VerticalAnchor.absolute(-0), VerticalAnchor.absolute(128)))));
    public static final RegistryObject<PlacedFeature> DEEPSLATE_TIN_ORE_PLACED = PLACED_FEATURES.register("deepslate_tin_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.DEEPSLATE_TIN_ORE.getHolder().get(), commonOrePlacement(12,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(0)))));
    public static final RegistryObject<PlacedFeature> MITHRIL_ORE_PLACED = PLACED_FEATURES.register("mithril_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.MITHRIL_ORE.getHolder().get(), commonOrePlacement(12,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(0)))));

    public static final RegistryObject<PlacedFeature> CRIMSON_SHROOMITE_ORE_PLACED = PLACED_FEATURES.register("crimson_shroomite_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.CRIMSON_SHROOMITE_ORE.getHolder().get(), commonOrePlacement(12,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));
    public static final RegistryObject<PlacedFeature> WARPED_SHROOMITE_ORE_PLACED = PLACED_FEATURES.register("warped_shroomite_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.WARPED_SHROOMITE_ORE.getHolder().get(), commonOrePlacement(12,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));
    public static final RegistryObject<PlacedFeature> TITANIUM_ORE_PLACED = PLACED_FEATURES.register("titanium_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.TITANIUM_ORE.getHolder().get(), commonOrePlacement(7,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));

    public static final RegistryObject<PlacedFeature> CHORITE_ORE_PLACED = PLACED_FEATURES.register("chorite_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.CHORITE_ORE.getHolder().get(), commonOrePlacement(7,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));
    public static final RegistryObject<PlacedFeature> TUNGSTEN_ORE_PLACED = PLACED_FEATURES.register("tungsten_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.TUNGSTEN_ORE.getHolder().get(), commonOrePlacement(7,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));
    public static final RegistryObject<PlacedFeature> ADAMANTINE_ORE_PLACED = PLACED_FEATURES.register("adamantine_ore_placed",
            () -> new PlacedFeature(ModConfiguredFeatures.ADAMANTINE_ORE.getHolder().get(), commonOrePlacement(7,
                    HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(128)))));


    public static List<PlacementModifier> orePlacement(PlacementModifier p_195347_, PlacementModifier p_195348_) {
        return List.of(p_195347_, InSquarePlacement.spread(), p_195348_, BiomeFilter.biome());
    }
    public static List<PlacementModifier> commonOrePlacement(int p_195344_, PlacementModifier p_195345_) {
        return orePlacement(CountPlacement.of(p_195344_), p_195345_);
    }
    public static List<PlacementModifier> rareOrePlacement(int p_195350_, PlacementModifier p_195351_) {
        return orePlacement(RarityFilter.onAverageOnceEvery(p_195350_), p_195351_);
    }


    public static void register(IEventBus eventBus) {
        PLACED_FEATURES.register(eventBus);
    }
}

All of the .json files for ore generation function, as they're literal copies of each other and the game generates worlds without coming up with a "datapacks invalid" error. Ore counts are greatly exaggerated as a response to them not generating, me being me, I just thought they were too rare. Nope.

Side note: It may have something to do with the supplier creation in ConfiguredFeatures? I've tried a bunch of stuff on it and nothing's worked, but I've noticed that the ores that don't generate are lower down in the declarations.

Any and all help is appreciated, and thank you ahead of time.

Link to comment
Share on other sites

Quote

public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_ORES = Suppliers.memoize(() -> List.of(

  OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.TIN_ORE.get().defaultBlockState()),

  OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_TIN_ORE.get().defaultBlockState()),

  OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.MITHRIL_ORE.get().defaultBlockState())));

This will always replace deepslate blocks with deepslate tin. It is the first test to match those blocks.

Since mithril has exactly the same conditions there is no case where it could be used.

 

Similary, for the NETHER and END ores only the first could ever be used.

 

If you really do want to mix these ores together in the same "veins", you will need to write your own Feature whose ConfiguredFeature uses a WeightedRandomList or similar mechanic.

Otherwise each ConfiguredFeature will need its own List of TargetBlockStates.

 

By the way, don't just post code snippets in the forums.

Post all your code on github that is relevant to reproduce the issue (sometimes we have to run/debug the code for ourselves to see issues that are not obvious from just reading the code).

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

Posted (edited)

Alright, thank you. I thought it had something to do with the order of how they were written, but wasn't sure.
I'll avoid posting code snippets on the forum from now on.

Edited by TeineOne
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

    • with just forge it works, and the logs are the same, as the error is the same. this log i provided is from today.
    • I want to add trees to my mod but all the examples I've seen so far include data generation, and not json files. The json files for the blocks are not the issue here. Unless trees require certain json files as a structure, I'm certain I've got this part covered. The thing I'm looking for is probably a deferred register or any other way to register something as a tree so it will grow from a sapling. Here is what I currently have: public static final DeferredRegister<ConfiguredFeature<?, ?>> TREES = DeferredRegister.create(Registries.CONFIGURED_FEATURE, ExtinctionCraft.MOD_ID); // How do I register the tree? public static final ResourceKey<ConfiguredFeature<?, ?>> SEQUOIA_KEY = registerKey("sequoia"); public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) { register(SEQUOIA_KEY, Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder( BlockStateProvider.simple(ModBlocks.SEQUOIA_LOG.get()), new StraightTrunkPlacer(5, 4, 3), BlockStateProvider.simple(ModBlocks.SEQUOIA_LEAVES.get()), new PineFoliagePlacer(ConstantInt.of(3), ConstantInt.of(2), ConstantInt.of(3)), new TwoLayersFeatureSize(1, 0, 2)).build()); } public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(ExtinctionCraft.MOD_ID, name)); } private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) { context.register(key, new ConfiguredFeature<>(feature, configuration)); } I also have this Grower class: public class SequoiaGrower extends AbstractTreeGrower { @Nullable @Override protected ResourceKey<ConfiguredFeature<?, ?>> getConfiguredFeature(RandomSource pRandom, boolean pHasFlowers) { return ModConfiguredFeatures.SEQUOIA_KEY; } } And the registry of the blocks that make up the tree (excluding wood blocks that I have registered but that don't make up part of a tree): public static final RegistryObject<Block> SEQUOIA_LOG = registerBlock("sequoia_log", () -> new ModFlammableRotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.OAK_LOG).strength(3))); public static final RegistryObject<Block> SEQUOIA_LEAVES = registerBlock("sequoia_leaves", () -> new ModLeavesBlock(BlockBehaviour.Properties.copy(Blocks.OAK_LEAVES))); public static final RegistryObject<Block> SEQUOIA_SAPLING = registerBlock("sequoia_sapling", () -> new SaplingBlock(new SequoiaGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)));   How do I move on from here? Examples of your code are welcome too.
    • These libraries failed to download. Try again. com.google.code.findbugs:jsr305:3.0.2 commons-io:commons-io:2.4
    • Make a test just with Forge - without any mods Then add the latest.log from your logs-folder
  • Topics

×
×
  • Create New...

Important Information

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