Jump to content

1.14 Ore generation works when ran from Eclipse but not when mod is built


EvanatorM

Recommended Posts

1 minute ago, EvanatorM said:

Why is it different and how can I fix it?

Post your code. I'm not gonna watch a YouTube video to see what potentially is your code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Ok. I'm not sure what I was thinking not putting the code initially. The ore generation spans across four of those videos, and it's kind of hard to follow. Sorry. I have a few files that go into ore generation.

 

OreGeneration.java

Spoiler

package evanatorm.randomizedmod.world;

import evanatorm.randomizedmod.config.OregenConfig;
import evanatorm.randomizedmod.lists.BlockList;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage.Decoration;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.feature.OreFeatureConfig.FillerBlockType;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;

public class OreGeneration
{
    public static void setupOreGeneration()
    {
        for (Biome biome : ForgeRegistries.BIOMES)
        {
            biome.addFeature(Decoration.UNDERGROUND_ORES,
                    Biome.createDecoratedFeature(Feature.ORE,
                            new OreFeatureConfig(FillerBlockType.NATURAL_STONE, BlockList.test_block.getDefaultState(),
                                    OregenConfig.sorpiph_ore_chance.get()),
                            Placement.COUNT_RANGE, new CountRangeConfig(10, 26, 0, 37)));
            biome.addFeature(Decoration.UNDERGROUND_ORES,
                    Biome.createDecoratedFeature(Feature.ORE,
                            new OreFeatureConfig(FillerBlockType.NATURAL_STONE, BlockList.test_block.getDefaultState(),
                                    OregenConfig.thoorth_ore_chance.get()),
                            Placement.COUNT_RANGE, new CountRangeConfig(10, 7, 0, 44)));
            biome.addFeature(Decoration.UNDERGROUND_ORES,
                    Biome.createDecoratedFeature(Feature.ORE,
                            new OreFeatureConfig(FillerBlockType.NATURAL_STONE, BlockList.test_block.getDefaultState(),
                                    OregenConfig.sermur_ore_chance.get()),
                            Placement.COUNT_RANGE, new CountRangeConfig(10, 10, 0, 36)));
        }
    }
}
 

 

OreGenConfig.java

Spoiler

package evanatorm.randomizedmod.config;

import net.minecraftforge.common.ForgeConfigSpec;

public class OregenConfig
{
    public static ForgeConfigSpec.IntValue sorpiph_ore_chance;
    public static ForgeConfigSpec.IntValue thoorth_ore_chance;
    public static ForgeConfigSpec.IntValue sermur_ore_chance;
    public static ForgeConfigSpec.BooleanValue generate_overworld;

    public static void init(ForgeConfigSpec.Builder server, ForgeConfigSpec.Builder client)
    {
        server.comment("Oregen Config");
        sorpiph_ore_chance = server.comment("Max number of ore veins that can spawn in one chunk.")
                .defineInRange("oregen.sorpiph_ore_chance", 100, 1, 1000);
        thoorth_ore_chance = server.comment("Max number of ore veins that can spawn in one chunk.")
                .defineInRange("oregen.thoorth_ore_chance", 100, 1, 1000);
        sermur_ore_chance = server.comment("Max number of ore veins that can spawn in one chunk.")
                .defineInRange("oregen.sermur_ore_chance", 100, 1, 1000);
        generate_overworld = server.comment("Decide if you want randomized ores to spawm in the overworld")
                .define("oregen.generate_overworld", true);
    }
}
 

 

Config.java

Spoiler

package evanatorm.randomizedmod.config;

import java.io.File;

import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;

import evanatorm.randomizedmod.RandomizedMod;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class Config
{
    private static final ForgeConfigSpec.Builder server_builder = new ForgeConfigSpec.Builder();
    private static final ForgeConfigSpec.Builder client_builder = new ForgeConfigSpec.Builder();
    public static final ForgeConfigSpec server_config;
    public static final ForgeConfigSpec client_config;
    static
    {
        OregenConfig.init(server_builder, client_builder);
        server_config = server_builder.build();
        client_config = client_builder.build();
    }

    public static void loadConfig(ForgeConfigSpec config, String path)
    {
        RandomizedMod.logger.info("Loading config: " + path);
        final CommentedFileConfig file = CommentedFileConfig.builder(new File(path)).sync().autosave()
                .writingMode(WritingMode.REPLACE).build();
        RandomizedMod.logger.info("Built config: " + path);
        file.load();
        RandomizedMod.logger.info("Loaded config: " + path);
        config.setConfig(file);
    }
}

 

RandomizedMod.java (Main file)

Spoiler

package evanatorm.randomizedmod;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import evanatorm.randomizedmod.config.Config;
import evanatorm.randomizedmod.items.ItemCustomAxe;
import evanatorm.randomizedmod.items.ItemCustomPickaxe;
import evanatorm.randomizedmod.lists.ArmorMaterialList;
import evanatorm.randomizedmod.lists.BlockList;
import evanatorm.randomizedmod.lists.ItemList;
import evanatorm.randomizedmod.lists.ToolMaterialList;
import evanatorm.randomizedmod.world.OreGeneration;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.HoeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.SwordItem;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;

@Mod("randomizedmod")
public class RandomizedMod
{
    public static RandomizedMod instance;
    public static final String modid = "randomizedmod";
    public static final Logger logger = LogManager.getLogger(modid);

    public static final ItemGroup randomized = new RandomizedItemGroup();

    public RandomizedMod()
    {
        instance = this;

        ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.server_config);
        ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.client_config);

        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries);

        Config.loadConfig(Config.client_config, FMLPaths.CONFIGDIR.get().resolve("randomized-client.toml").toString());
        Config.loadConfig(Config.server_config, FMLPaths.CONFIGDIR.get().resolve("randomized-server.toml").toString());

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        OreGeneration.setupOreGeneration();
        logger.info("Setup method registered.");
    }

    private void clientRegistries(final FMLClientSetupEvent event)
    {
        logger.info("ClientRegistries method registered.");
    }

    @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents
    {
        @SubscribeEvent
        public static void registerItems(final RegistryEvent.Register<Item> event)
        {
            event.getRegistry().registerAll(
                    ItemList.test_item = new Item(new Item.Properties().group(randomized))
                            .setRegistryName(location("test_item")),

                    ItemList.test_axe = new ItemCustomAxe(ToolMaterialList.test, -1.0f, 6.0f,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_axe")),
                    ItemList.test_pickaxe = new ItemCustomPickaxe(ToolMaterialList.test, -2, 6.0f,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_pickaxe")),
                    ItemList.test_shovel = new ShovelItem(ToolMaterialList.test, -3.0f, 6.0f,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_shovel")),
                    ItemList.test_sword = new SwordItem(ToolMaterialList.test, 0, 6.0f,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_sword")),
                    ItemList.test_hoe = new HoeItem(ToolMaterialList.test, 6.0f,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_hoe")),

                    ItemList.test_helmet = new ArmorItem(ArmorMaterialList.test, EquipmentSlotType.HEAD,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_helmet")),
                    ItemList.test_chestplate = new ArmorItem(ArmorMaterialList.test, EquipmentSlotType.CHEST,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_chestplate")),
                    ItemList.test_leggings = new ArmorItem(ArmorMaterialList.test, EquipmentSlotType.LEGS,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_leggings")),
                    ItemList.test_boots = new ArmorItem(ArmorMaterialList.test, EquipmentSlotType.FEET,
                            new Item.Properties().group(randomized)).setRegistryName(location("test_boots")),

                    ItemList.test_block = new BlockItem(BlockList.test_block, new Item.Properties().group(randomized))
                            .setRegistryName(BlockList.test_block.getRegistryName()));

            logger.info("Items registered.");
        }

        @SubscribeEvent
        public static void registerBlocks(final RegistryEvent.Register<Block> event)
        {
            event.getRegistry()
                    .registerAll(BlockList.test_block = new Block(Block.Properties.create(Material.ROCK)
                            .hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.STONE))
                                    .setRegistryName(location("test_block")));

            logger.info("Blocks registered.");
        }

        private static ResourceLocation location(String name)
        {
            return new ResourceLocation(modid, name);
        }
    }
}
 

 

The part of the main file that should do it is:

    private void setup(final FMLCommonSetupEvent event)
    {
        OreGeneration.setupOreGeneration();
        logger.info("Setup method registered.");
    }

 

Thanks for your quick response!

Link to comment
Share on other sites

2 hours ago, EvanatorM said:

 Thanks for your quick response!

I cant find anything obviously wrong at the moment.

2 hours ago, EvanatorM said:

Placement.COUNT_RANGE

Try changing this to Placement.RANDOM_COUNT_RANGE

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

  • 2 weeks later...

I finally figured it out by looking at the source code of Simple Ores 2. I don't know what was wrong with the code that was in the video. All I know is that this code works.

 

Instead of:

Spoiler

            biome.addFeature(Decoration.UNDERGROUND_ORES,
                    Biome.createDecoratedFeature(Feature.ORE,
                            new OreFeatureConfig(FillerBlockType.NATURAL_STONE, BlockList.test_block.getDefaultState(),
                                    OregenConfig.sorpiph_ore_chance.get()),
                            Placement.COUNT_RANGE, new CountRangeConfig(10, 26, 0, 37)));

I put this in:

Spoiler

            biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
                    Biome.createDecoratedFeature(Feature.ORE,
                            new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
                                    BlockList.test_block.getDefaultState(), test_veinsize),
                            Placement.COUNT_RANGE, test_cfg));

Also, there are two variables needed and they are put in the oregen file:

Spoiler

    private static final CountRangeConfig test_cfg = new CountRangeConfig(10, 20, 0, 128);
    private static final int test_veinsize = 7;

This worked fine for me!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Make a test without chameleon or storagedrawers
    • In August, during one of the most challenging periods of my life, I was introduced to REMOTE CYBAR RECOVERY by Mr. Johnny. I had recently experienced a devastating loss involving $760,000 worth of Bitcoin. This significant amount of money had been acquired by selling my shares, and I had invested it in Bitcoin, only to have it stolen. Each day felt like a battle as I faced the overwhelming possibility of losing everything I had worked so hard to accumulate. It was an emotional and financial crisis that left me feeling hopeless and desperate, Mr.. Johnny, who had faced a similar situation himself, shared his experience with me. he had also lost access to his digital wallet and had turned to REMOTE CYBAR RECOVERY for assistance. To his relief, they were able to help him recover the wallet password and regain access to his funds. Hearing her positive account of their service provided me with a glimmer of hope, and I decided to reach out to REMOTE CYBAR RECOVERY. From the moment I made contact with them, I knew I had made the right decision. Their response was prompt and professional, which immediately put my mind at ease. The team demonstrated exceptional expertise and dedication throughout the process. They worked tirelessly to address my concerns and meticulously followed up on every detail related to my case. In less than 4 days, a period that felt both incredibly short and incredibly long due to the stress I was under, my funds were fully deposited back into my account. The speed and efficiency with which REMOTE CYBAR RECOVERY handled my case were nothing short of remarkable. Their success in recovering my stolen funds was a relief beyond words and significantly alleviated the financial and emotional strain I had been enduring. The expertise and professionalism exhibited by REMOTE CYBAR RECOVERY. were beyond measure. They provided not only a solution to a complex problem but also restored my confidence in the possibility of recovering from such a dire situation. Their service was a beacon of hope during one of the darkest times in my life, and I am deeply grateful I cannot recommend REMOTE CYBAR RECOVERY highly enough. Their knowledge, responsiveness, and effectiveness in handling cases of this nature are truly commendable. If you ever face a situation where you have lost access to your digital assets or find yourself in need of recovery services, REMOTE CYBAR RECOVERY is a resource you should definitely consider. Their support can make a world of difference, as it did for me. EMAIL S U P P O R T @ R E M O T E C Y B A R R E C O V E R Y . C O M WHATS/APP + 1 7 2 5 2 2 4 2 5 9 7 WEBSITE https:// remote cybarrecovery . com/
    • That might be saved in the NBT of the villager? I'm not sure.
  • Topics

×
×
  • Create New...

Important Information

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