Search in sources :

Example 86 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project EnderIO by SleepyTrousers.

the class BlockDecorationFacing method registerRenderers.

@Override
@SideOnly(Side.CLIENT)
public void registerRenderers(@Nonnull IModObject modObject) {
    Item item = Item.getItemFromBlock(this);
    Map<IBlockState, ModelResourceLocation> locations = new DefaultStateMapper().putStateModelLocations(this);
    NNIterator<EnumDecoBlock> iterator = NNList.of(EnumDecoBlock.class).iterator();
    while (iterator.hasNext()) {
        EnumDecoBlock type = iterator.next();
        IBlockState state = getDefaultState().withProperty(EnumDecoBlock.TYPE, type).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false);
        ModelResourceLocation mrl = locations.get(state);
        if (mrl != null) {
            ModelLoader.setCustomModelResourceLocation(item, EnumDecoBlock.getMetaFromType(type), mrl);
        }
    }
}
Also used : Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) EnumDecoBlock(crazypants.enderio.base.render.property.EnumDecoBlock) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 87 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project EnderIO by SleepyTrousers.

the class ItemConduitFacade method registerRenderers.

@Override
public void registerRenderers(@Nonnull IModObject modObject) {
    for (EnumFacadeType type : EnumFacadeType.values()) {
        final ModelResourceLocation mrl = new ModelResourceLocation(NullHelper.notnull(getRegistryName(), "unregistered item?"), "type=" + type.getName());
        ModelLoader.setCustomModelResourceLocation(this, EnumFacadeType.getMetaFromType(type), mrl);
        ItemModelRegistry.registerFacade(mrl);
    }
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 88 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project HorsePower by GoryMoon.

the class ModModelManager method registerBlockItemModel.

/**
 * Register a single model for the {@link Block}'s {@link Item}.
 * <p>
 * Uses the registry name as the domain/path and the {@link IBlockState} as the variant.
 *
 * @param state The state to use as the variant
 */
private void registerBlockItemModel(IBlockState state) {
    final Block block = state.getBlock();
    final Item item = Item.getItemFromBlock(block);
    if (item != null) {
        registerItemModel(item, new ModelResourceLocation(block.getRegistryName(), propertyStringMapper.getPropertyString(state.getProperties())));
    }
}
Also used : Item(net.minecraft.item.Item) Block(net.minecraft.block.Block) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 89 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project HorsePower by GoryMoon.

the class ModModelManager method registerItemModel.

/**
 * Register a single model for an {@link Item}.
 * <p>
 * Uses {@code modelLocation} as the domain/path and {@link "inventory"} as the variant.
 *
 * @param item          The Item
 * @param modelLocation The model location
 */
private void registerItemModel(Item item, String modelLocation) {
    final ModelResourceLocation fullModelLocation = new ModelResourceLocation(modelLocation, "inventory");
    registerItemModel(item, fullModelLocation);
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 90 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project OpenModularTurrets by OpenModularTurretsTeam.

the class ModTESRItems method init.

@SuppressWarnings("ConstantConditions")
@SideOnly(Side.CLIENT)
public static void init() {
    if (OMTConfigHandler.getDisposableTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.disposableItemTurret), 0, DisposableItemTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.disposableItemTurret), 0, new ModelResourceLocation(ModBlocks.disposableItemTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getPotatoCannonTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.potatoCannonTurret), 0, PotatoCannonTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.potatoCannonTurret), 0, new ModelResourceLocation(ModBlocks.potatoCannonTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getGunTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.machineGunTurret), 0, GunTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.machineGunTurret), 0, new ModelResourceLocation(ModBlocks.machineGunTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getIncendiaryTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.incendiaryTurret), 0, IncendiaryTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.incendiaryTurret), 0, new ModelResourceLocation(ModBlocks.incendiaryTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getRelativisticTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.relativisticTurret), 0, RelativisticTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.relativisticTurret), 0, new ModelResourceLocation(ModBlocks.relativisticTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getGrenadeTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.grenadeLauncherTurret), 0, GrenadeLauncherTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.grenadeLauncherTurret), 0, new ModelResourceLocation(ModBlocks.grenadeLauncherTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getRocketTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.rocketTurret), 0, RocketTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.rocketTurret), 0, new ModelResourceLocation(ModBlocks.rocketTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getTeleporterTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.teleporterTurret), 0, TeleporterTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.teleporterTurret), 0, new ModelResourceLocation(ModBlocks.teleporterTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getLaserTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.laserTurret), 0, LaserTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.laserTurret), 0, new ModelResourceLocation(ModBlocks.laserTurret.getRegistryName(), "inventory"));
    }
    if (OMTConfigHandler.getRailgunTurretSettings().isEnabled()) {
        ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.railGunTurret), 0, RailGunTurretTileEntity.class);
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.railGunTurret), 0, new ModelResourceLocation(ModBlocks.railGunTurret.getRegistryName(), "inventory"));
    }
    ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.leverBlock), 0, LeverTileEntity.class);
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.leverBlock), 0, new ModelResourceLocation(ModBlocks.leverBlock.getRegistryName(), "inventory"));
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)320 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)129 ResourceLocation (net.minecraft.util.ResourceLocation)101 Item (net.minecraft.item.Item)55 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)52 IBlockState (net.minecraft.block.state.IBlockState)48 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)26 ArrayList (java.util.ArrayList)25 Block (net.minecraft.block.Block)21 StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)20 ItemStack (net.minecraft.item.ItemStack)16 EnumFacing (net.minecraft.util.EnumFacing)13 Map (java.util.Map)12 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)11 IModel (net.minecraftforge.client.model.IModel)11 Nonnull (javax.annotation.Nonnull)10 IProperty (net.minecraft.block.properties.IProperty)9 Side (net.minecraftforge.fml.relauncher.Side)9 DefaultStateMapper (net.minecraft.client.renderer.block.statemap.DefaultStateMapper)8 RenderItem (net.minecraft.client.renderer.RenderItem)7