Search in sources :

Example 56 with IBakedModel

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

the class ModelManager method registerCustomModels.

public static void registerCustomModels(ModelBakeEvent event) {
    IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
    for (final BlockModelEntry entry : customBlockModels) {
        registry.putObject(entry.blockModelLocation, entry.model);
        if (entry.itemModelLocation != null) {
            registry.putObject(entry.itemModelLocation, entry.model);
        }
    }
    IModelState defaultBlockState = ModelUtil.loadModelState(new ResourceLocation("minecraft:models/block/block"));
    IModelState defaultFenceState = ModelUtil.loadModelState(new ResourceLocation("minecraft:models/block/fence_inventory"));
    ModelManager.defaultFenceState = mergeStates(defaultBlockState, defaultFenceState);
}
Also used : BlockModelEntry(forestry.core.models.BlockModelEntry) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) IModelState(net.minecraftforge.common.model.IModelState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 57 with IBakedModel

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

the class ControlLumbermillProgress method getWoodSprite.

@SideOnly(Side.CLIENT)
private TextureAtlasSprite getWoodSprite(ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    ItemModelMesher modelMesher = renderItem.getItemModelMesher();
    IBakedModel model = modelMesher.getItemModel(stack);
    TextureAtlasSprite sprite = model.getParticleTexture();
    if (sprite == mc.getTextureMapBlocks().getMissingSprite()) {
        return getWoodSprite(new ItemStack(Blocks.LOG));
    }
    return sprite;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 58 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Random-Things by lumien231.

the class ModelFluidDisplay method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    if (state == null) {
        return defaultModel.getQuads(state, side, rand);
    }
    IExtendedBlockState extendedState = (IExtendedBlockState) state;
    IBakedModel model = defaultModel;
    FluidStack fluidStack = extendedState.getValue(BlockFluidDisplay.FLUID);
    if (fluidStack != null) {
        boolean flowing = extendedState.getValue(BlockFluidDisplay.FLOWING);
        Rotation rotation = extendedState.getValue(BlockFluidDisplay.ROTATION);
        CacheEntry entry = new CacheEntry(fluidStack, rotation);
        HashMap<CacheEntry, ModelCubeAll> cache = flowing ? modelCacheFlowing : modelCache;
        if (cache.containsKey(entry)) {
            model = cache.get(entry);
        } else {
            Fluid fluid = fluidStack.getFluid();
            if (fluid != null) {
                TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
                cache.put(new CacheEntry(fluidStack, rotation), new ModelCubeAll(flowing ? textureMap.getAtlasSprite(fluid.getFlowing().toString()) : textureMap.getAtlasSprite(fluid.getStill().toString()), true, rotation));
                model = cache.get(entry);
            }
        }
    }
    return model.getQuads(extendedState, side, rand);
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Rotation(net.minecraft.util.Rotation)

Example 59 with IBakedModel

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

the class RenderTakumiCreepered method draw.

private void draw(T te, double x, double y, double z, IBlockState state, BlockPos pos, BufferBuilder buffer, Tessellator tessellator) {
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(7425);
    } else {
        GlStateManager.shadeModel(7424);
    }
    buffer.begin(7, DefaultVertexFormats.BLOCK);
    buffer.setTranslation((float) x - pos.getX(), (float) y - pos.getY(), (float) z - pos.getZ());
    World world = this.getWorld();
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    state = state.getBlock().getExtendedState(state, world, pos);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(world, model, state, pos, buffer, true);
    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) World(net.minecraft.world.World)

Example 60 with IBakedModel

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

the class RenderTakumiBlock method draw.

private void draw(T te, double x, double y, double z, IBlockState state, BlockPos pos, BufferBuilder buffer, Tessellator tessellator) {
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(7425);
    } else {
        GlStateManager.shadeModel(7424);
    }
    buffer.begin(7, DefaultVertexFormats.BLOCK);
    buffer.setTranslation((float) x - pos.getX(), (float) y - pos.getY(), (float) z - pos.getZ());
    World world = this.getWorld();
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    state = state.getBlock().getExtendedState(state, world, pos);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(world, model, state, pos, buffer, true);
    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) World(net.minecraft.world.World)

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