Search in sources :

Example 1 with IHaveTESR

use of crazypants.enderio.base.render.IHaveTESR in project EnderIO by SleepyTrousers.

the class ClientProxy method onModelRegistryEvent.

@SubscribeEvent
public static void onModelRegistryEvent(@Nonnull ModelRegistryEvent event) {
    // Custom state mappers
    EnderIOGlassesStateMapper.create();
    ColdFireStateMapper.create();
    LeverStateMapper.create();
    final StateMap doorMapper = (new StateMap.Builder()).ignore(new IProperty[] { BlockDoor.POWERED }).build();
    ModelLoader.setCustomStateMapper(ModObject.blockDarkSteelDoor.getBlockNN(), doorMapper);
    ModelLoader.setCustomStateMapper(ModObject.blockPaintedDarkSteelDoor.getBlockNN(), doorMapper);
    ModelLoader.setCustomStateMapper(ModObject.blockPaintedIronDoor.getBlockNN(), doorMapper);
    ModelLoader.setCustomStateMapper(ModObject.blockPaintedWoodenDoor.getBlockNN(), doorMapper);
    // Items of blocks that use smart rendering
    SmartModelAttacher.registerBlockItemModels();
    /*
     * Most blocks register themselves with the SmartModelAttacher which will also handle their items. Those that don't need to implement IHaveRenderers and
     * have their items handled here.
     * 
     * Items that do _not_ belong to a block are handled here by either having the item implement IHaveRenderers or by registering the default renderer.
     */
    for (IModObject mo : ModObjectRegistry.getObjects()) {
        final Block block = mo.getBlock();
        if (block instanceof ICustomSubItems) {
        // NOP, handled by SmartModelAttacher
        } else if (block instanceof IHaveRenderers) {
            ((IHaveRenderers) block).registerRenderers(mo);
        } else if (block instanceof IDefaultRenderers) {
            ClientUtil.registerDefaultItemRenderer(mo);
        } else if (block == null || block == Blocks.AIR) {
            final Item item = mo.getItem();
            if (item instanceof ICustomSubItems) {
            // NOP, handled by SmartModelAttacher
            } else if (item instanceof IHaveRenderers) {
                ((IHaveRenderers) item).registerRenderers(mo);
            } else if (item != null && item != Items.AIR) {
                ClientUtil.registerDefaultItemRenderer(mo);
            }
        }
        if (block instanceof IHaveTESR) {
            ((IHaveTESR) block).bindTileEntitySpecialRenderer();
        }
    }
}
Also used : Item(net.minecraft.item.Item) ICustomSubItems(crazypants.enderio.base.render.ICustomSubItems) IProperty(net.minecraft.block.properties.IProperty) IHaveTESR(crazypants.enderio.base.render.IHaveTESR) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) IDefaultRenderers(crazypants.enderio.base.render.IDefaultRenderers) Block(net.minecraft.block.Block) IHaveRenderers(crazypants.enderio.base.render.IHaveRenderers) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ICustomSubItems (crazypants.enderio.base.render.ICustomSubItems)1 IDefaultRenderers (crazypants.enderio.base.render.IDefaultRenderers)1 IHaveRenderers (crazypants.enderio.base.render.IHaveRenderers)1 IHaveTESR (crazypants.enderio.base.render.IHaveTESR)1 Block (net.minecraft.block.Block)1 IProperty (net.minecraft.block.properties.IProperty)1 StateMap (net.minecraft.client.renderer.block.statemap.StateMap)1 Item (net.minecraft.item.Item)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1