0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Forge Modding 1.12.2 Part1 -Baseクラス

Posted at

#Forge Modding Part1
(Forge Projectのセットアップの説明は他を当たってください)

##Object
Objectパッケージを作り、その中に

・ItemBase.java
・BlockBase.java

を作成。
その中に、Implmentsパッケージを作成。
そこに、
・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();
}

こんな感じになります。

次回:実際にアイテム追加してみる

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?