Search in sources :

Example 1 with BlockLeafOlives

use of com.axanthic.loi.blocks.BlockLeafOlives in project Lands-of-Icaria by Axanthic-Game-Studios.

the class ClientProxy method registerModels.

@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
    for (ItemBlock block : Resources.blocks) {
        if (block.getBlock() instanceof BlockFlower || block.getBlock() instanceof BlockTallGrass || block.getBlock() instanceof BlockHerb) {
            for (int i = 0; i < ((IBlockMeta) block.getBlock()).getNames().length; i++) {
                ModelLoader.setCustomModelResourceLocation(block, i, new ModelResourceLocation(block.getRegistryName() + "_inv", "type=" + ((IBlockMeta) block.getBlock()).getNames()[i]));
            }
        } else if (block.getBlock() instanceof BlockLeafOlives) {
            // olive leaves are weird
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(0)));
            ModelLoader.setCustomModelResourceLocation(block, 1, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(1)));
        } else if (block instanceof ItemBlockMeta) {
            ModelLoader.setCustomMeshDefinition(block, new ItemMeshDefinition() {

                @Override
                public ModelResourceLocation getModelLocation(ItemStack stack) {
                    return new ModelResourceLocation(block.getRegistryName(), "type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(stack.getMetadata()));
                }
            });
        } else if (block.getBlock() instanceof BlockLeaf || block.getBlock() instanceof BlockSapling || block.getBlock() instanceof BlockCustomWorkbench) {
            String[] path = block.getRegistryName().getResourcePath().split("_");
            if (block.getBlock() instanceof BlockSapling)
                ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), "inv_" + path[0]));
            else
                ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]);
                }
            });
        } else if (block.getBlock() instanceof BlockLog) {
            String[] path = block.getRegistryName().getResourcePath().split("_");
            ResourceLocation loc = new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]);
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(loc, path[0] + "_y"));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    String axis = "bark";
                    int meta = ((BlockLog) block.getBlock()).getMetaFromState(state);
                    if (meta == 0) {
                        axis = "y";
                    } else if (meta == 4) {
                        axis = "x";
                    } else if (meta == 8) {
                        axis = "z";
                    }
                    return new ModelResourceLocation(loc, path[0] + "_" + axis);
                }
            });
        } else if (block.getBlock() instanceof BlockFluidCustom) {
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "normal"));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    return new ModelResourceLocation(block.getRegistryName(), "normal");
                }
            });
        } else
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
    }
    for (Item item : Resources.items) {
        if (item instanceof IItemMeta) {
            for (int i = 0; i < ((IItemMeta) item).getNames().length; i++) {
                ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(item.getRegistryName(), "type=" + ((IItemMeta) item).getNames()[i]));
            }
        } else if (item instanceof ItemTool || item instanceof ItemSword || item instanceof ItemCustomArmor) {
            String[] path = item.getRegistryName().getResourcePath().split("_");
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "tool_" + path[1]), path[0]));
        } else if (item instanceof ItemSpell) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell"), ((ItemSpell) item).getName()));
        } else if (item instanceof ItemScroll) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell_scroll"), ((ItemScroll) item).getName()));
        } else if (item instanceof ItemConcoctionFlask) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "concoction_flask_filled"), "inventory"));
        } else
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
    // register special item renderers here
    Resources.saltedFood.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.grinder.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadRevenant.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArachne.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArachneDrone.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadMyrmeke.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadCerver.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArganHound.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagPlane.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagPopulus.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagCypress.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagFir.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagOlive.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagLaurel.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagDroughtroot.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadAeternae.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadCatoblepas.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadSow.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    for (ItemScroll scroll : Resources.scrolls) scroll.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) BlockLeaf(com.axanthic.loi.blocks.BlockLeaf) IBlockMeta(com.axanthic.loi.blocks.IBlockMeta) BlockLeafOlives(com.axanthic.loi.blocks.BlockLeafOlives) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) BlockCustomWorkbench(com.axanthic.loi.blocks.BlockCustomWorkbench) Item(net.minecraft.item.Item) ItemSpell(com.axanthic.loi.items.ItemSpell) BlockSapling(com.axanthic.loi.blocks.BlockSapling) BlockHerb(com.axanthic.loi.blocks.BlockHerb) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ItemConcoctionFlask(com.axanthic.loi.items.ItemConcoctionFlask) ItemSword(net.minecraft.item.ItemSword) ItemTool(net.minecraft.item.ItemTool) IBlockState(net.minecraft.block.state.IBlockState) BlockLog(com.axanthic.loi.blocks.BlockLog) IItemMeta(com.axanthic.loi.items.IItemMeta) ItemBlock(net.minecraft.item.ItemBlock) BlockFlower(com.axanthic.loi.blocks.BlockFlower) ItemCustomArmor(com.axanthic.loi.items.ItemCustomArmor) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) BlockTallGrass(com.axanthic.loi.blocks.BlockTallGrass) ItemBlockMeta(com.axanthic.loi.items.ItemBlockMeta) ItemStack(net.minecraft.item.ItemStack) ItemScroll(com.axanthic.loi.items.ItemScroll) BlockFluidCustom(com.axanthic.loi.blocks.BlockFluidCustom) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockCustomWorkbench (com.axanthic.loi.blocks.BlockCustomWorkbench)1 BlockFlower (com.axanthic.loi.blocks.BlockFlower)1 BlockFluidCustom (com.axanthic.loi.blocks.BlockFluidCustom)1 BlockHerb (com.axanthic.loi.blocks.BlockHerb)1 BlockLeaf (com.axanthic.loi.blocks.BlockLeaf)1 BlockLeafOlives (com.axanthic.loi.blocks.BlockLeafOlives)1 BlockLog (com.axanthic.loi.blocks.BlockLog)1 BlockSapling (com.axanthic.loi.blocks.BlockSapling)1 BlockTallGrass (com.axanthic.loi.blocks.BlockTallGrass)1 IBlockMeta (com.axanthic.loi.blocks.IBlockMeta)1 IItemMeta (com.axanthic.loi.items.IItemMeta)1 ItemBlockMeta (com.axanthic.loi.items.ItemBlockMeta)1 ItemConcoctionFlask (com.axanthic.loi.items.ItemConcoctionFlask)1 ItemCustomArmor (com.axanthic.loi.items.ItemCustomArmor)1 ItemScroll (com.axanthic.loi.items.ItemScroll)1 ItemSpell (com.axanthic.loi.items.ItemSpell)1 IBlockState (net.minecraft.block.state.IBlockState)1 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)1