Search in sources :

Example 46 with IBakedModel

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

the class TileEntityHPBaseRenderer method renderBlockDamage.

public void renderBlockDamage(IBlockState state, BlockPos pos, TextureAtlasSprite texture, IBlockAccess blockAccess) {
    state = state.getActualState(blockAccess, pos);
    IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
    IBakedModel ibakedmodel1 = net.minecraftforge.client.ForgeHooksClient.getDamageModel(ibakedmodel, texture, state, blockAccess, pos);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(blockAccess, ibakedmodel1, state, pos, Tessellator.getInstance().getBuffer(), true);
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 47 with IBakedModel

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

the class TileEntityHandGrindstoneRender method render.

@Override
public void render(TileEntityHandGrindstone te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    IBlockState blockState = te.getWorld().getBlockState(te.getPos());
    if (!(blockState.getBlock() instanceof BlockHPBase))
        return;
    IBlockState centerState = blockState.withProperty(BlockHandGrindstone.PART, HandGrindstoneModels.CENTER);
    if (!(centerState.getBlock() instanceof BlockHPBase))
        return;
    IBakedModel centerModel = dispatcher.getBlockModelShapes().getModelForState(centerState);
    preDestroyRender(destroyStage);
    setRenderSettings();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    // The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
    // This makes the translations that follow much easier
    buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
    if (destroyStage >= 0) {
        buffer.noColor();
        renderBlockDamage(centerState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
    } else
        dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), centerModel, centerState, te.getPos(), buffer, false);
    buffer.setTranslation(0, 0, 0);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    // Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
    GlStateManager.translate(0.5, 0.5, 0.5);
    FacingToRotation.get(te.getForward()).glRotateCurrentMat();
    float rotation = te.getVisibleRotation();
    GlStateManager.rotate(rotation, 0, 1, 0);
    GlStateManager.translate(-0.5, -0.5, -0.5);
    tessellator.draw();
    GlStateManager.popMatrix();
    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    postDestroyRender(destroyStage);
    RenderHelper.enableStandardItemLighting();
    renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(0), x, y, z, 0.8F, 0.7F, 0.5F, 0.7F);
    renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(1), x, y, z, 0.2F, 0.7F, 0.5F, 0.7F);
    renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(2), x, y, z, 0.5F, 0.7F, 0.2F, 0.7F);
    super.render(te, x, y, z, partialTicks, destroyStage, alpha);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockHPBase(se.gory_moon.horsepower.blocks.BlockHPBase) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 48 with IBakedModel

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

the class TileEntityPressRender method render.

@Override
public void render(TileEntityPress te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    IBlockState blockState = te.getWorld().getBlockState(te.getPos());
    if (!(blockState.getBlock() instanceof BlockHPBase))
        return;
    IBlockState topState = blockState.withProperty(BlockPress.PART, PressModels.TOP);
    if (!(topState.getBlock() instanceof BlockHPBase))
        return;
    IBakedModel pressModel = dispatcher.getBlockModelShapes().getModelForState(topState);
    preDestroyRender(destroyStage);
    setRenderSettings();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    // The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
    // This makes the translations that follow much easier
    buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
    if (destroyStage >= 0) {
        buffer.noColor();
        renderBlockDamage(topState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
    } else
        dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), pressModel, blockState, te.getPos(), buffer, false);
    buffer.setTranslation(0, 0, 0);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    // Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
    float move = (te.getField(0) / (float) (Configs.general.pointsForPress > 0 ? Configs.general.pointsForPress : 1));
    GlStateManager.translate(0.5, 0.5, 0.5);
    GlStateManager.translate(0, -(0.58 * move), 0);
    GlStateManager.translate(-0.5, -0.5, -0.5);
    tessellator.draw();
    GlStateManager.popMatrix();
    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    postDestroyRender(destroyStage);
    RenderHelper.enableStandardItemLighting();
    if (!(blockState.getBlock() instanceof BlockHPBase))
        return;
    if (te.hasWorker())
        renderLeash(te.getWorker(), x, y, z, 0D, 0.4D, 0D, partialTicks, te.getPos());
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    if (!te.getStackInSlot(0).isEmpty() && move <= 0.25) {
        renderItem(te, te.getStackInSlot(0), 0.5F, 0.5F, 0.5F, 1F);
        drawString(te, String.valueOf(te.getStackInSlot(0).getCount()), 0, 0.35, 0);
    }
    if (!te.getStackInSlot(1).isEmpty() && move <= 0.25) {
        renderItem(te, te.getStackInSlot(1), 0.5F, 0.5F, 0.5F, 1F);
        drawString(te, String.valueOf(te.getStackInSlot(1).getCount()), 0, 0.35, 0);
    }
    GlStateManager.popMatrix();
    super.render(te, x, y + 1, z, partialTicks, destroyStage, alpha);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockHPBase(se.gory_moon.horsepower.blocks.BlockHPBase) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 49 with IBakedModel

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

the class ModModelManager method replaceChoppingModel.

public static void replaceChoppingModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
    try {
        IModel model = ModelLoaderRegistry.getModel(modelLocation);
        IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
        if (standard != null) {
            IBakedModel finalModel = new BakedChopperModel(standard, model, DefaultVertexFormats.BLOCK);
            event.getModelRegistry().putObject(modelVariantLocation, finalModel);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IModel(net.minecraftforge.client.model.IModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BakedChopperModel(se.gory_moon.horsepower.client.model.BakedChopperModel)

Example 50 with IBakedModel

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

the class EnchanterModelRenderer method renderBase.

private void renderBase() {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
    IBakedModel bakedModel = modelShapes.getModelForState(MachineObject.block_enchanter.getBlockNN().getDefaultState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT));
    RenderUtil.bindBlockTexture();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    for (EnumFacing enumfacing : EnumFacing.values()) {
        this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, enumfacing, 0L));
    }
    this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, (EnumFacing) null, 0L));
    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

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