Search in sources :

Example 1 with StateMap

use of net.minecraft.client.renderer.block.statemap.StateMap in project TechReborn by TechReborn.

the class ClientProxy method init.

@Override
public void init(FMLInitializationEvent event) {
    super.init(event);
    MinecraftForge.EVENT_BUS.register(new StackToolTipEvent());
    multiblockRenderEvent = new MultiblockRenderEvent();
    MinecraftForge.EVENT_BUS.register(GuiSlotConfiguration.class);
    MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
    // TODO FIX ME
    ClientRegistry.registerKeyBinding(KeyBindings.config);
    ClientMultiBlocks.init();
    StateMap rubberLeavesStateMap = new StateMap.Builder().ignore(BlockRubberLeaves.CHECK_DECAY, BlockRubberLeaves.DECAYABLE).build();
    ModelLoader.setCustomStateMapper(ModBlocks.RUBBER_LEAVES, rubberLeavesStateMap);
}
Also used : MultiblockRenderEvent(reborncore.client.multiblock.MultiblockRenderEvent) StateMap(net.minecraft.client.renderer.block.statemap.StateMap)

Example 2 with StateMap

use of net.minecraft.client.renderer.block.statemap.StateMap in project OpenModularTurrets by OpenModularTurretsTeam.

the class ClientProxy method initModelLoaders.

@Override
public void initModelLoaders() {
    StateMap ignoreRotation = new StateMap.Builder().ignore(LeverBlock.ROTATION).build();
    StateMap ignoreConcealed = new StateMap.Builder().ignore(BlockAbstractTurretHead.CONCEALED).build();
    ModelLoader.setCustomStateMapper(ModBlocks.leverBlock, ignoreRotation);
    if (OMTConfigHandler.getDisposableTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.disposableItemTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getGrenadeTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.grenadeLauncherTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getTeleporterTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.teleporterTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getIncendiaryTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.incendiaryTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getLaserTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.laserTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getRailgunTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.railGunTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getRelativisticTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.relativisticTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getRocketTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.rocketTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getGunTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.machineGunTurret, ignoreConcealed);
    }
    if (OMTConfigHandler.getPotatoCannonTurretSettings().isEnabled()) {
        ModelLoader.setCustomStateMapper(ModBlocks.potatoCannonTurret, ignoreConcealed);
    }
    ModelLoaderRegistry.registerLoader(new TurretBaseBakedModel.ModelLoader());
    ModelLoader.setCustomStateMapper(ModBlocks.turretBase, new TurretBaseBakedModel.Statemapper());
    for (int i = 0; i < 5; i++) {
        registerBlockModelAsItem(ModBlocks.turretBase, i, OMTNames.Blocks.turretBase + "_normal", "tier=" + (i + 1));
    }
    for (int i = 0; i < 10; i++) {
        registerBlockModelAsItem(ModBlocks.expander, i, OMTNames.Blocks.expander, "facing=north,meta=" + i);
    }
    for (int i = 0; i < 1; i++) {
        registerBlockModelAsItem(ModBlocks.baseAddon, i, OMTNames.Blocks.baseAddon, "facing=north,model=" + i);
    }
    for (int i = 0; i < 15; i++) {
        registerItemModel(ModItems.intermediateProductTiered, i, IntermediateProductTiered.subNames[i], true);
    }
    for (int i = 0; i < 8; i++) {
        registerItemModel(ModItems.addonMetaItem, i, AddonMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 5; i++) {
        registerItemModel(ModItems.upgradeMetaItem, i, UpgradeMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 1; i++) {
        registerItemModel(ModItems.intermediateProductRegular, i, IntermediateProductRegular.subNames[i], true);
    }
    for (int i = 0; i < 5; i++) {
        registerItemModel(ModItems.ammoMetaItem, i, AmmoMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 3; i++) {
        registerItemModel(ModItems.usableMetaItem, i, UsableMetaItem.subNames[i], true);
    }
    initTileRenderers();
}
Also used : TurretBaseBakedModel(omtteam.openmodularturrets.client.render.models.TurretBaseBakedModel) StateMap(net.minecraft.client.renderer.block.statemap.StateMap)

Example 3 with StateMap

use of net.minecraft.client.renderer.block.statemap.StateMap in project MinecraftForge by MinecraftForge.

the class ForgeBlockStatesLoaderDebug method preInitClient.

@SideOnly(Side.CLIENT)
public void preInitClient(FMLPreInitializationEvent event) {
    //ModelLoader.setCustomStateMapper(blockCustom, new StateMap.Builder().withName(CustomMappedBlock.VARIANT).build());
    ModelLoader.setCustomStateMapper(BLOCKS.custom_wall, new IStateMapper() {

        StateMap stateMap = new StateMap.Builder().withName(BlockWall.VARIANT).withSuffix("_wall").build();

        @Override
        public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
            Map<IBlockState, ModelResourceLocation> map = (Map<IBlockState, ModelResourceLocation>) stateMap.putStateModelLocations(block);
            Map<IBlockState, ModelResourceLocation> newMap = Maps.newHashMap();
            for (Entry<IBlockState, ModelResourceLocation> e : map.entrySet()) {
                ModelResourceLocation loc = e.getValue();
                newMap.put(e.getKey(), new ModelResourceLocation(ASSETS + loc.getResourcePath(), loc.getVariant()));
            }
            return newMap;
        }
    });
    ModelLoader.setCustomModelResourceLocation(ITEMS.custom_wall, 0, new ModelResourceLocation(ASSETS + "cobblestone_wall", "inventory"));
    ModelLoader.setCustomModelResourceLocation(ITEMS.custom_wall, 1, new ModelResourceLocation(ASSETS + "mossy_cobblestone_wall", "inventory"));
}
Also used : Entry(java.util.Map.Entry) IBlockState(net.minecraft.block.state.IBlockState) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) IStateMapper(net.minecraft.client.renderer.block.statemap.IStateMapper) Block(net.minecraft.block.Block) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Map(java.util.Map) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with StateMap

use of net.minecraft.client.renderer.block.statemap.StateMap in project OpenModularTurrets by OpenModularTurretsTeam.

the class ClientProxy method preInit.

@Override
public void preInit() {
    super.preInit();
    StateMap ignoreRotation = new StateMap.Builder().ignore(LeverBlock.ROTATION).build();
    StateMap ignoreConcealed = new StateMap.Builder().ignore(BlockAbstractTurretHead.CONCEALED).build();
    ModelLoader.setCustomStateMapper(ModBlocks.leverBlock, ignoreRotation);
    ModelLoader.setCustomStateMapper(ModBlocks.disposableItemTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.grenadeLauncherTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.teleporterTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.incendiaryTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.laserTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.railGunTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.relativisticTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.rocketTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.machineGunTurret, ignoreConcealed);
    ModelLoader.setCustomStateMapper(ModBlocks.potatoCannonTurret, ignoreConcealed);
    ModelLoaderRegistry.registerLoader(new TurretBaseBakedModel.ModelLoader());
    ModelLoader.setCustomStateMapper(ModBlocks.turretBase, new TurretBaseBakedModel.Statemapper());
    for (int i = 0; i < 5; i++) {
        registerBlockModelAsItem(ModBlocks.turretBase, i, OMTNames.Blocks.turretBase + "_normal", "tier=" + (i + 1));
    }
    for (int i = 0; i < 10; i++) {
        registerBlockModelAsItem(ModBlocks.expander, i, OMTNames.Blocks.expander, "facing=north,meta=" + i);
    }
    for (int i = 0; i < 15; i++) {
        registerItemModel(ModItems.intermediateProductTiered, i, IntermediateProductTiered.subNames[i], true);
    }
    for (int i = 0; i < 7; i++) {
        registerItemModel(ModItems.addonMetaItem, i, AddonMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 5; i++) {
        registerItemModel(ModItems.upgradeMetaItem, i, UpgradeMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 1; i++) {
        registerItemModel(ModItems.intermediateProductRegular, i, IntermediateProductRegular.subNames[i], true);
    }
    for (int i = 0; i < 5; i++) {
        registerItemModel(ModItems.ammoMetaItem, i, AmmoMetaItem.subNames[i], true);
    }
    for (int i = 0; i < 3; i++) {
        registerItemModel(ModItems.usableMetaItem, i, UsableMetaItem.subNames[i], true);
    }
}
Also used : TurretBaseBakedModel(omtteam.openmodularturrets.client.render.models.TurretBaseBakedModel) StateMap(net.minecraft.client.renderer.block.statemap.StateMap)

Example 5 with StateMap

use of net.minecraft.client.renderer.block.statemap.StateMap 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

StateMap (net.minecraft.client.renderer.block.statemap.StateMap)5 Block (net.minecraft.block.Block)2 TurretBaseBakedModel (omtteam.openmodularturrets.client.render.models.TurretBaseBakedModel)2 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 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 IProperty (net.minecraft.block.properties.IProperty)1 IBlockState (net.minecraft.block.state.IBlockState)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 IStateMapper (net.minecraft.client.renderer.block.statemap.IStateMapper)1 Item (net.minecraft.item.Item)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 MultiblockRenderEvent (reborncore.client.multiblock.MultiblockRenderEvent)1