Search in sources :

Example 1 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityCannonBallRenderer method doRender.

@Override
public void doRender(EntityCannonBall entity, double x, double y, double z, float entityYaw, float partialTicks) {
    IBlockState iblockstate = ValkyrienWarfareCombatMod.instance.fakecannonblock.getStateFromMeta(2);
    double renderX = (entity.posX - entity.lastTickPosX) * partialTicks + entity.lastTickPosX;
    double renderY = (entity.posY - entity.lastTickPosY) * partialTicks + entity.lastTickPosY;
    double renderZ = (entity.posZ - entity.lastTickPosZ) * partialTicks + entity.lastTickPosZ;
    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.worldObj;
        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }
            vertexbuffer.begin(7, DefaultVertexFormats.BLOCK);
            // BlockPos blockpos = new BlockPos(renderX, renderY, renderZ);
            GlStateManager.translate((float) (x - renderX + .25D), (float) (y - renderY - .07D), (float) (z - renderZ + .778D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            vertexbuffer.setTranslation(renderX - .5D, renderY, renderZ - .5D);
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, BlockPos.ORIGIN, vertexbuffer, false, 0);
            tessellator.draw();
            vertexbuffer.setTranslation(0, 0, 0);
            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }
            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 2 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityCannonBasicRender method renderHead.

private void renderHead(EntityCannonBasic entity, double x, double y, double z, float entityYaw, float partialTicks) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(7, DefaultVertexFormats.BLOCK);
    BlockPos blockpos = new BlockPos(entity.posX, entity.posY, entity.posZ);
    // GlStateManager.translate((float)(x - (double)blockpos.getX() - 0.5D), (float)(y - (double)blockpos.getY()), (float)(z - (double)blockpos.getZ() - 0.5D));
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    blockrendererdispatcher.getBlockModelRenderer().renderModel(entity.worldObj, blockrendererdispatcher.getModelForState(headState), headState, blockpos, vertexbuffer, false, 0);
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) BlockPos(net.minecraft.util.math.BlockPos) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 3 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project TechReborn by TechReborn.

the class SlotConfigPopupElement method draw.

@Override
public void draw(GuiBase gui) {
    drawDefaultBackground(gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
    super.draw(gui);
    TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile);
    IBlockAccess blockAccess = machine.getWorld();
    BlockPos pos = machine.getPos();
    IBlockState state = blockAccess.getBlockState(pos);
    IBlockState actualState = state.getBlock().getDefaultState().getActualState(blockAccess, pos);
    BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
    IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.getBlock().getDefaultState());
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    // left
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23);
    // top
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F);
    // centre
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F);
    // bottom
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F);
    // right
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F);
    // back
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F);
    drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
}
Also used : TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) IBlockState(net.minecraft.block.state.IBlockState) IBlockAccess(net.minecraft.world.IBlockAccess) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 4 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Tropicraft by Tropicraft.

the class RenderBambooItemFrame method doRender.

/**
 * Renders the desired {@code T} type Entity.
 */
@Override
public void doRender(EntityBambooItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    BlockPos blockpos = entity.getHangingPosition();
    double d0 = (double) blockpos.getX() - entity.posX + x;
    double d1 = (double) blockpos.getY() - entity.posY + y;
    double d2 = (double) blockpos.getZ() - entity.posZ + z;
    GlStateManager.translate(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D);
    GlStateManager.rotate(180.0F - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
    this.renderManager.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
    ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
    IBakedModel ibakedmodel;
    if (entity.getDisplayedItem() != null && entity.getDisplayedItem().getItem() == Items.FILLED_MAP) {
        ibakedmodel = modelmanager.getModel(this.mapModel);
    } else {
        ibakedmodel = modelmanager.getModel(this.itemFrameModel);
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(-0.5F, -0.5F, -0.5F);
    if (this.renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }
    blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
    if (this.renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }
    GlStateManager.popMatrix();
    GlStateManager.translate(0.0F, 0.0F, 0.4375F);
    this.renderItem(entity);
    GlStateManager.popMatrix();
    this.renderName(entity, x + (double) ((float) entity.facingDirection.getFrontOffsetX() * 0.3F), y - 0.25D, z + (double) ((float) entity.facingDirection.getFrontOffsetZ() * 0.3F));
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 5 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project EnderIO by SleepyTrousers.

the class TelePadSpecialRenderer method render.

public void render(@Nonnull TileEntity tileEntity, @Nonnull final IBlockState state) {
    final BlockPos pos = tileEntity.getPos();
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder vertexBuffer = tessellator.getBuffer();
    final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    final IBakedModel ibakedmodel = blockrendererdispatcher.getBlockModelShapes().getModelForState(state);
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    vertexBuffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    blockrendererdispatcher.getBlockModelRenderer().renderModel(tileEntity.getWorld(), ibakedmodel, state, pos, vertexBuffer, false);
    vertexBuffer.setTranslation(0, 0, 0);
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Aggregations

BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)42 IBlockState (net.minecraft.block.state.IBlockState)20 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)15 BlockPos (net.minecraft.util.math.BlockPos)13 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)12 Tessellator (net.minecraft.client.renderer.Tessellator)11 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 World (net.minecraft.world.World)5 Block (net.minecraft.block.Block)4 BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)4 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)3 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IBlockAccess (net.minecraft.world.IBlockAccess)3 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 Nullable (javax.annotation.Nullable)2 BlockChest (net.minecraft.block.BlockChest)2 BlockEnderChest (net.minecraft.block.BlockEnderChest)2 BlockSign (net.minecraft.block.BlockSign)2