错误注册项目[1.12.2] Minecraft Forge

时间:2020-04-28 00:16:52

标签: java gradle minecraft minecraft-forge

我正在关注有关伪造的教程,该教程来自伪造1.10,我正在使用1.12版本进行编码,但遇到错误。

错误:

Caused by: java.lang.NullPointerException: Can't use a null-name for the registry, object net.minecraft.item.Item@2fd1f0e4.

代码:

public class ModItems {

    public static Item sumersHead;


    public static void preInit(){
        sumersHead = new Item().setUnlocalizedName("sumers_head").setCreativeTab(FirstMod.tabFirst);

        registerItems();
    }

    public static void registerItems()
    {
        ForgeRegistries.ITEMS.register(sumersHead);
    }

    public static void registerRenders()
    {

    }

    public static void registerRender(Item item)
    {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
    }

}

1 个答案:

答案 0 :(得分:1)

您需要先在商品上调用setRegistryName,然后再在商品上调用ForgeRegistries.ITEMS.register