Search in sources :

Example 6 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Skree by Skelril.

the class CustomItemSystem method render.

// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object item) {
    if (item instanceof Item && item instanceof ICustomItem) {
        if (Sponge.getPlatform().getExecutionType().isClient()) {
            RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
            ItemModelMesher mesher = renderItem.getItemModelMesher();
            Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition();
            if (optMeshDefinition.isPresent()) {
                mesher.register((Item) item, optMeshDefinition.get());
            }
            List<String> variants = ((ICustomItem) item).__getMeshDefinitions();
            List<ResourceLocation> modelResources = new ArrayList<>();
            for (int i = 0; i < variants.size(); ++i) {
                ModelResourceLocation resourceLocation = new ModelResourceLocation("skree:" + variants.get(i), "inventory");
                if (!optMeshDefinition.isPresent()) {
                    mesher.register((Item) item, i, resourceLocation);
                }
                modelResources.add(resourceLocation);
            }
            ModelBakery.registerItemVariants((Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
        }
    } else {
        throw new IllegalArgumentException("Invalid custom item!");
    }
}
Also used : ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ICustomItem(com.skelril.nitro.registry.item.ICustomItem) RenderItem(net.minecraft.client.renderer.RenderItem) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) Item(net.minecraft.item.Item) CookedItem(com.skelril.nitro.registry.item.CookedItem) ICustomItem(com.skelril.nitro.registry.item.ICustomItem) RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 7 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ClientProxyCombat method registerItemModel.

private void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    renderItem.getItemModelMesher().register(toRegister, 0, new ModelResourceLocation(ValkyrienWarfareCombatMod.MODID + ":" + toRegister.getUnlocalizedName().substring(5), "inventory"));
    ;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 8 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ClientProxyWorld method registerItemModel.

private void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    renderItem.getItemModelMesher().register(toRegister, 0, new ModelResourceLocation(ValkyrienWarfareWorldMod.MODID + ":" + toRegister.getUnlocalizedName().substring(5), "inventory"));
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 9 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ClientProxyControl method registerItemModel.

private void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    renderItem.getItemModelMesher().register(toRegister, 0, new ModelResourceLocation(ValkyrienWarfareControlMod.MODID + ":" + toRegister.getUnlocalizedName().substring(5), "inventory"));
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Aggregations

RenderItem (net.minecraft.client.renderer.RenderItem)9 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)6 ArrayList (java.util.ArrayList)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2 ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)2 Item (net.minecraft.item.Item)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ICustomBlock (com.skelril.nitro.registry.block.ICustomBlock)1 CookedItem (com.skelril.nitro.registry.item.CookedItem)1 ICustomItem (com.skelril.nitro.registry.item.ICustomItem)1 Block (net.minecraft.block.Block)1 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)1