Search in sources :

Example 26 with IBakedModel

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

the class ModelBlockCustomCached method getModel.

@Override
protected IBakedModel getModel(IBlockState state) {
    K key = getWorldKey(state);
    IBakedModel model = worldCache.getIfPresent(key);
    if (model == null) {
        model = super.getModel(state);
        worldCache.put(key, model);
    }
    return model;
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 27 with IBakedModel

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

the class ModelBlockCustomCached method getModel.

@Override
protected IBakedModel getModel(ItemStack stack, World world) {
    K key = getInventoryKey(stack);
    IBakedModel model = inventoryCache.getIfPresent(key);
    if (model == null) {
        model = bakeModel(stack, world, key);
        inventoryCache.put(key, model);
    }
    return model;
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 28 with IBakedModel

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

the class ModelCrate method bakeModel.

/**
 * Bake the crate model.
 */
private List<IBakedModel> bakeModel(ItemCrated crateItem) {
    List<IBakedModel> models = new ArrayList<>();
    ItemStack contained = crateItem.getContained();
    if (!contained.isEmpty()) {
        IBakedModel containedModel = getCustomContentModel(crateItem);
        if (containedModel == null) {
            containedModel = ModelUtil.getModel(contained);
        }
        models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
        models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
    }
    return models;
}
Also used : TRSRBakedModel(forestry.core.models.TRSRBakedModel) ArrayList(java.util.ArrayList) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Example 29 with IBakedModel

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

the class ModelCamouflaged method addCamouflageModel.

private void addCamouflageModel(B block, IModelBaker baker, BlockRenderLayer layer, IBlockAccess world, BlockPos pos) {
    if (world == null || pos == null) {
        TextureAtlasSprite defaultSprite = block.getDefaultSprite();
        baker.addBlockModel(pos, defaultSprite, DEFAULT_COLOR_INDEX);
        baker.setParticleSprite(defaultSprite);
    } else {
        ItemStack camouflageStack = block.getCamouflageBlock(world, pos);
        if (camouflageStack.isEmpty()) {
            camouflageStack = GreenhouseController.createDefaultCamouflageBlock();
        }
        Block camouflageBlock = Block.getBlockFromItem(camouflageStack.getItem());
        ICamouflageItemHandler itemHandler = CamouflageManager.camouflageAccess.getHandler(camouflageStack);
        if (itemHandler != null) {
            Pair<IBlockState, IBakedModel> modelPair = itemHandler.getModel(camouflageStack);
            IBlockState blockState = modelPair.getLeft();
            if (camouflageBlock.canRenderInLayer(blockState, layer)) {
                IBakedModel bakedModel = modelPair.getRight();
                baker.addBakedModel(blockState, bakedModel);
                baker.setParticleSprite(bakedModel.getParticleTexture());
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) ICamouflageItemHandler(forestry.api.core.ICamouflageItemHandler)

Example 30 with IBakedModel

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

the class ModelCamouflaged method bakeBlock.

@Override
protected void bakeBlock(B block, Key key, IModelBaker baker, boolean inventory) {
    IBlockAccess world = key.world;
    BlockPos pos = key.pos;
    BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
    if (layer != BlockRenderLayer.CUTOUT) {
        addCamouflageModel(block, baker, layer, world, pos);
    }
    if (layer == BlockRenderLayer.CUTOUT || layer == null) {
        IBakedModel model;
        if (key.state != null) {
            model = overlayModel.getModel(key.state);
        } else {
            model = overlayModel.getModel(key.itemStack, Minecraft.getMinecraft().world);
        }
        baker.addBakedModelPost(key.state, model);
    }
}
Also used : IBlockAccess(net.minecraft.world.IBlockAccess) BlockPos(net.minecraft.util.math.BlockPos) UnlistedBlockPos(forestry.core.blocks.properties.UnlistedBlockPos) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)197 IBlockState (net.minecraft.block.state.IBlockState)94 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)42 BlockPos (net.minecraft.util.math.BlockPos)40 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)38 EnumFacing (net.minecraft.util.EnumFacing)38 ResourceLocation (net.minecraft.util.ResourceLocation)36 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 ItemStack (net.minecraft.item.ItemStack)27 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 Block (net.minecraft.block.Block)23 IModel (net.minecraftforge.client.model.IModel)22 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)22 ArrayList (java.util.ArrayList)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)15 List (java.util.List)14 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)14 ImmutableList (com.google.common.collect.ImmutableList)13