Search in sources :

Example 1 with IStateMapper

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

use of net.minecraft.client.renderer.block.statemap.IStateMapper in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method registerBlockSided.

@Override
public void registerBlockSided(Block block) {
    if (block instanceof IBOPBlock) {
        IBOPBlock bopBlock = (IBOPBlock) block;
        // Register non-rendering properties
        IProperty[] nonRenderingProperties = bopBlock.getNonRenderingProperties();
        if (nonRenderingProperties != null) {
            // use a custom state mapper which will ignore the properties specified in the block as being non-rendering
            IStateMapper custom_mapper = (new StateMap.Builder()).ignore(nonRenderingProperties).build();
            ModelLoader.setCustomStateMapper(block, custom_mapper);
        }
        // Register colour handlers
        if (bopBlock.getBlockColor() != null || bopBlock.getItemColor() != null) {
            blocksToColour.add(block);
        }
    }
}
Also used : IBOPBlock(biomesoplenty.common.block.IBOPBlock) IProperty(net.minecraft.block.properties.IProperty) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) IStateMapper(net.minecraft.client.renderer.block.statemap.IStateMapper)

Aggregations

IStateMapper (net.minecraft.client.renderer.block.statemap.IStateMapper)2 StateMap (net.minecraft.client.renderer.block.statemap.StateMap)2 IBOPBlock (biomesoplenty.common.block.IBOPBlock)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Block (net.minecraft.block.Block)1 IProperty (net.minecraft.block.properties.IProperty)1 IBlockState (net.minecraft.block.state.IBlockState)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1