[TUTORIAL] Working OreDictionary Compatibility

Started by Thales Stilhano on

Topic category: Help with modding (Java Edition)

Last seen on 18:25, 23. Dec 2022
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Working OreDictionary Compatibility
Mon, 08/12/2019 - 23:35 (edited)

Hi guys.

For a long time I was trying to figure out how to add a item to ore dictionary in mcreator but with no success. I searched in every Mcreator's topics to find out, I considered to totally remake my mod in Eclipse, but today, I was editing the code and BAAAAM, I find out.

As you all know, in Mcreator 1.9 you can just edit your mod elements code but you can't edit Main.java anymore because Mcreator replaces the code every time you build your mod.

The way i did was:

1st -> Edit the code of your element (mine was a copper ingot). Be sure that you choose "lock mcreator code" option.

2nd-> On the import's section add:

import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;

import net.minecraftforge.oredict.OreDictionary;

3rd-> Find public ItemCustom()  and under setCreativeTab(MCreatorZMSTab.tab); just put this code:

-OreDictionary.registerOre("ingotCopper", this);

DONE

My full code:

package net.mcreator.YOURMODNAME;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;

import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.oredict.OreDictionary;
import net.mcreator.YOURMODNAME.MCreatorCopperIngot.ItemCustom;

public class MCreatorCopperIngot extends YOURMODNAME.ModElement {

    @GameRegistry.ObjectHolder("YOURMODNAME:zmscopper")
    public static final Item block = null;

    public MCreatorCopperIngot(YOURMODNAME instance) {
        super(instance);
        instance.items.add(() -> new ItemCustom());
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerModels(ModelRegistryEvent event) {
        ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation("YOURMODNAME:zmscopper", "inventory"));
    }
    

    public static class ItemCustom extends Item {

        public ItemCustom() {
            setMaxDamage(0);
            maxStackSize = 64;
            setUnlocalizedName("zmscopper");
            setRegistryName("zmscopper");
            setCreativeTab(MCreatorZMSTab.tab);
            OreDictionary.registerOre("ingotCopper", this);
        }
        
    

 

        @Override
        public int getItemEnchantability() {
            return 0;
        }

        @Override
        public int getMaxItemUseDuration(ItemStack par1ItemStack) {
            return 0;
        }

        @Override
        public float getDestroySpeed(ItemStack par1ItemStack, IBlockState par2Block) {
            return 1F;
        }
    }
    
    
}

 

 

 

 

Edited by Thales Stilhano on Mon, 08/12/2019 - 23:35
MCreator 1.9.1 will add…
Tue, 08/13/2019 - 17:22

MCreator 1.9.1 will add support to lock main mod file. Ore dictionary is planned for 1.9.1 if all goes according to the plans too :) But for now, this tutorial is a nice thing to have!

Last seen on 18:25, 23. Dec 2022
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm very happy to hear that …
Wed, 08/14/2019 - 16:49

I'm very happy to hear that :)

I am a very Mcreator's supporter. I could make my own mod all on hard coding, but i really like the concept of MCreator (making the people without java knowledge make their mods), and I chosse it mostly because I have not time for modding. I'm very happy hearing that Mcreatoris growing and adding support to some forge libraries :)

If you don't mind I have found some issues and tips to the next updates:

- It would be nice to see Gui animations(arrow, and "burning")

- I had texture problems with making a ice translucent blocks.

Thanks Klemen :)