Search in sources :

Example 16 with ItemMeshDefinition

use of net.minecraft.client.renderer.ItemMeshDefinition in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method replaceBOPBucketTexture.

@Override
public void replaceBOPBucketTexture() {
    // Use BOP bucket texture
    Map<Item, ItemMeshDefinition> meshMapping = ReflectionHelper.getPrivateValue(ItemModelMesher.class, Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), "field_178092_c", "shapers");
    final ItemMeshDefinition meshDefinition = meshMapping.get(ForgeModContainer.getInstance().universalBucket);
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ForgeModContainer.getInstance().universalBucket, new ItemMeshDefinition() {

        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack) {
            FluidStack fluidStack = FluidUtil.getFluidContained(stack);
            if (fluidStack != null && MiscConfigurationHandler.useBoPBucketTexture) {
                if (fluidStack.getFluid() == BloodFluid.instance) {
                    return bucketModelLocations[0];
                }
                if (fluidStack.getFluid() == HoneyFluid.instance) {
                    return bucketModelLocations[1];
                }
                if (fluidStack.getFluid() == HotSpringWaterFluid.instance) {
                    return bucketModelLocations[2];
                }
                if (fluidStack.getFluid() == PoisonFluid.instance) {
                    return bucketModelLocations[3];
                }
                if (fluidStack.getFluid() == QuicksandFluid.instance) {
                    return bucketModelLocations[4];
                }
            }
            return meshDefinition == null ? ModelDynBucket.LOCATION : meshDefinition.getModelLocation(stack);
        }
    });
}
Also used : ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) Item(net.minecraft.item.Item) IColoredItem(biomesoplenty.common.item.IColoredItem) FluidStack(net.minecraftforge.fluids.FluidStack) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ItemStack(net.minecraft.item.ItemStack)

Example 17 with ItemMeshDefinition

use of net.minecraft.client.renderer.ItemMeshDefinition 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)

Aggregations

ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)17 ItemStack (net.minecraft.item.ItemStack)16 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)9 ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 Item (net.minecraft.item.Item)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 IIEMetaBlock (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IIEMetaBlock)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 Block (net.minecraft.block.Block)2 IColoredItem (biomesoplenty.common.item.IColoredItem)1 BlockIEFluid (blusunrize.immersiveengineering.common.blocks.BlockIEFluid)1 IColouredBlock (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IColouredBlock)1 IColouredItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IColouredItem)1 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)1 IECompatModule (blusunrize.immersiveengineering.common.util.compat.IECompatModule)1 PositionedItemStack (blusunrize.lib.manual.ManualPages.PositionedItemStack)1 CookedItem (com.skelril.nitro.registry.item.CookedItem)1 ICustomItem (com.skelril.nitro.registry.item.ICustomItem)1 BlockITFluid (ferro2000.immersivetech.common.blocks.BlockITFluid)1