Search in sources :

Example 71 with ModelResourceLocation

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

the class ProxyArboricultureClient method retextureItemModel.

private void retextureItemModel(IRegistry<ModelResourceLocation, IBakedModel> registry, ImmutableMap<String, String> textures, IWoodType woodType, WoodBlockKind woodKind, ItemStack itemStack, IWoodItemMeshDefinition woodDefinition) {
    if (woodKind != WoodBlockKind.DOOR) {
        ResourceLocation defaultModelLocation = woodDefinition.getDefaultModelLocation(itemStack);
        IModel basicItemModel = ModelLoaderRegistry.getModelOrMissing(defaultModelLocation);
        ModelResourceLocation basicItemLocation = woodDefinition.getModelLocation(itemStack);
        IModel retextureModel = woodKind.retextureModel(basicItemModel, woodType, textures);
        registry.putObject(basicItemLocation, new SimpleRetexturedModel(retextureModel));
    }
}
Also used : IModel(net.minecraftforge.client.model.IModel) SimpleRetexturedModel(forestry.core.models.SimpleRetexturedModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 72 with ModelResourceLocation

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

the class PlanterStateMapper method putStateModelLocations.

@Override
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
    for (EnumFacing facing : EnumFacing.values()) {
        if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) {
            continue;
        }
        for (boolean manual : new boolean[] { false, true }) {
            IBlockState state = block.getDefaultState().withProperty(BlockBase.FACING, facing).withProperty(BlockPlanter.MANUAL, manual);
            LinkedHashMap<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
            properties.remove(BlockPlanter.MANUAL);
            ResourceLocation blockLocation = Block.REGISTRY.getNameForObject(block);
            String s = String.format("%s:%s", blockLocation.getResourceDomain(), blockLocation.getResourcePath());
            mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(properties)));
        }
    }
    return this.mapStateModelLocations;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) EnumFacing(net.minecraft.util.EnumFacing) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 73 with ModelResourceLocation

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

the class ProxyGreenhouseClient method initializeModels.

@Override
public void initializeModels() {
    BlockRegistryGreenhouse blocks = ModuleGreenhouse.getBlocks();
    Preconditions.checkState(blocks != null);
    ModelManager modelManager = ModelManager.getInstance();
    Block greenhouseBlock = blocks.greenhouseBlock;
    if (greenhouseBlock != null) {
        ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:greenhouse");
        ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:greenhouse", "inventory");
        BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelCamouflaged(BlockGreenhouse.class), greenhouseBlock);
        modelManager.registerCustomBlockModel(blockModelIndex);
    }
    Block climatiserBlock = blocks.climatiserBlock;
    if (climatiserBlock != null) {
        ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:climatiser");
        ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:climatiser", "inventory");
        BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelCamouflaged(BlockClimatiser.class), climatiserBlock);
        modelManager.registerCustomBlockModel(blockModelIndex);
    }
    {
        ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:greenhouse.window");
        ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:greenhouse_window", "inventory");
        BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelGreenhouseWindow(), ModuleGreenhouse.getBlocks().window);
        modelManager.registerCustomBlockModel(blockModelIndex);
    }
    {
        ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:greenhouse.window_up");
        ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:greenhouse_window_up", "inventory");
        BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelGreenhouseWindow(), ModuleGreenhouse.getBlocks().roofWindow);
        modelManager.registerCustomBlockModel(blockModelIndex);
    }
    {
        ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:camouflage_spray_can", "inventory");
        ModelEntry itemModelIndex = new ModelEntry(modelLocation, new ModelCamouflageSprayCan());
        modelManager.registerCustomModel(itemModelIndex);
    }
}
Also used : ModelEntry(forestry.core.models.ModelEntry) BlockModelEntry(forestry.core.models.BlockModelEntry) BlockModelEntry(forestry.core.models.BlockModelEntry) ModelCamouflaged(forestry.greenhouse.models.ModelCamouflaged) BlockClimatiser(forestry.greenhouse.blocks.BlockClimatiser) ModelCamouflageSprayCan(forestry.greenhouse.models.ModelCamouflageSprayCan) BlockGreenhouse(forestry.greenhouse.blocks.BlockGreenhouse) Block(net.minecraft.block.Block) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock) BlockRegistryGreenhouse(forestry.greenhouse.blocks.BlockRegistryGreenhouse) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ModelManager(forestry.core.models.ModelManager) ModelGreenhouseWindow(forestry.greenhouse.models.ModelGreenhouseWindow)

Example 74 with ModelResourceLocation

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

the class ProxyLepidopterologyClient method preInitializeRendering.

@Override
public void preInitializeRendering() {
    RenderingRegistry.registerEntityRenderingHandler(EntityButterfly.class, new RenderButterflyEntity.Factory());
    ModelManager modelManager = ModelManager.getInstance();
    ModelResourceLocation butterflyGE = modelManager.getModelLocation("butterflyGE");
    ModelEntry modelEntry = new ModelEntry(butterflyGE, new ModelButterflyItem());
    modelManager.registerCustomModel(modelEntry);
}
Also used : ModelEntry(forestry.core.models.ModelEntry) ModelButterflyItem(forestry.lepidopterology.render.ModelButterflyItem) RenderButterflyEntity(forestry.lepidopterology.render.RenderButterflyEntity) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ModelManager(forestry.core.models.ModelManager)

Example 75 with ModelResourceLocation

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

the class ItemPipette method registerModel.

/* Models */
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
    models = new ModelResourceLocation[2];
    models[0] = manager.getModelLocation("pipette.0");
    models[1] = manager.getModelLocation("pipette.1");
    ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:pipette.0"));
    ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:pipette.1"));
    manager.registerItemModel(item, new PipetteMeshDefinition());
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) 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