29 juil. 2019, 21:53

@robin4002

package fr.lebourguignon.bourguimod.item;

import fr.lebourguignon.bourguimod.Principale;
import fr.lebourguignon.bourguimod.block.BourguiModBlocks;
import fr.lebourguignon.bourguimod.block.Test;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BourguiModItems
{
    public static final Item BLOCK_TEST_ITEM = new ItemBlockMetadata(BourguiModBlocks.TEST, new String[]{"test_white", "test_black"} ).setRegistryName(BourguiModBlocks.TEST.getRegistryName());
    public static final Item BLOCK_UNIFORM_BLOCK_ITEM = new ItemBlock(BourguiModBlocks.UNIFORM_BLOCK).setRegistryName(BourguiModBlocks.UNIFORM_BLOCK.getRegistryName());
    
    public static void setItemName(Item item, String name)
    {
        item.setRegistryName(Principale.MODID, name).setUnlocalizedName(Principale.MODID + "." + name);
    }
 
    @SideOnly(Side.CLIENT)
    public static void registerItemModels()
    {
        for (int i = 0; i < Test.EnumType.values().length; i++)
            registerModel(BLOCK_TEST_ITEM, i);
        registerModel(BLOCK_UNIFORM_BLOCK_ITEM, 0);
    }
 
    @SideOnly(Side.CLIENT)
    public static void registerModel(Item item, int metadata)
    {
        if (metadata < 0) metadata = 0;
        String resourceName = item.getUnlocalizedName().substring(5).replace('.', ':');
        if (metadata > 0) resourceName += "_m" + String.valueOf(metadata);
 
        ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(resourceName, "inventory"));
    }
}

c’est pas à cause de ce qui a aprés le dernier " @SideOnly " ?