[JAVA] Forge Modding 1.12.2 Part1 -Base class

Forge Modding Part1 (See elsewhere for Forge Project setup instructions)

Object Create an Object package and put it in it

・ItemBase.java ・BlockBase.java

Created. Create an Implements package in it. there, -Create IHasModel.java.

ItemBase

String name;
    public BlockBase(String name, Material material, CreativeTabs tabs,float blockHardness) {
        super(material);
        setTranslationKey(name);
        setRegistryName(Refarence.MOD_ID,name);
        setCreativeTab(tabs);
        setHardness(blockHardness);
        setResistance(1.0F);
        this.name=name;

        Blockinit.BLOCKS.add(this);
        Iteminit.Items.add(new ItemBlock(this).setRegistryName(Refarence.MOD_ID,name));
    }

    @Override
    public void registerModels(){
        System.out.println("ModelRegistered");
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(new ResourceLocation(Refarence.MOD_ID,name) ,"inventory"));
    }

BlockBase

public ItemBase(String name,CreativeTabs tabs){
        setTranslationKey(name);
        setRegistryName(Refarence.MOD_ID,name);
        setCreativeTab(tabs);
        Iteminit.Items.add(this);
    }


    @Override
    public void registerModels() {
        nobamod.Proxy.registerItemRenderer(this,0,"inventory");
    }

IHasModel

public interface IHasModel {
    public void registerModels();
}

I feel like this.

Next time: I will actually add items

Recommended Posts

Forge Modding 1.12.2 Part1 -Base class
Class and instant part2