Search in sources :

Example 46 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project ImmersiveEngineering by BluSunrize.

the class TileRenderSheetmetalTank method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntitySheetmetalTank tile, double x, double y, double z, float f, int destroyStage) {
    if (!tile.formed || tile.pos != 4 || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
        return;
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y, z + .5);
    FluidStack fs = tile.tank.getFluid();
    GlStateManager.translate(0, 3.5f, 0);
    float baseScale = .0625f;
    GlStateManager.scale(baseScale, -baseScale, baseScale);
    float xx = -.5f;
    float zz = 1.5f - .004f;
    xx /= baseScale;
    zz /= baseScale;
    for (int i = 0; i < 4; i++) {
        GlStateManager.translate(xx, 0, zz);
        GlStateManager.disableTexture2D();
        GlStateManager.enableBlend();
        GlStateManager.disableAlpha();
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
        GlStateManager.disableLighting();
        VertexBuffer worldrenderer = ClientUtils.tes().getBuffer();
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-4, -4, 0).color(0x22, 0x22, 0x22, 0xff).endVertex();
        worldrenderer.pos(-4, 20, 0).color(0x22, 0x22, 0x22, 0xff).endVertex();
        worldrenderer.pos(20, 20, 0).color(0x22, 0x22, 0x22, 0xff).endVertex();
        worldrenderer.pos(20, -4, 0).color(0x22, 0x22, 0x22, 0xff).endVertex();
        ClientUtils.tes().draw();
        GlStateManager.shadeModel(GL11.GL_FLAT);
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
        GlStateManager.enableTexture2D();
        if (fs != null) {
            float h = fs.amount / (float) tile.tank.getCapacity();
            GlStateManager.depthMask(false);
            GlStateManager.translate(0, 0, .004f);
            ClientUtils.drawRepeatedFluidSprite(fs, 0, 0 + (1 - h) * 16, 16, h * 16);
            GlStateManager.translate(0, 0, -.004f);
            GlStateManager.depthMask(true);
        }
        GlStateManager.translate(-xx, 0, -zz);
        GlStateManager.rotate(90, 0, 1, 0);
        GlStateManager.enableAlpha();
        GlStateManager.alphaFunc(516, 0.1F);
        GlStateManager.enableBlend();
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    }
    GlStateManager.popMatrix();
}
Also used : VertexBuffer(net.minecraft.client.renderer.VertexBuffer) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 47 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.

the class RenderTools method renderString.

public static void renderString(String name, double xOffset, double yOffset, double zOffset) {
    RenderManager rm = Minecraft.getMinecraft().getRenderManager();
    FontRenderer fontrenderer = rm.getFontRenderer();
    float f = 1.6F;
    float f1 = 1 / 60F * f;
    OpenGL.glPushMatrix();
    OpenGL.glTranslatef((float) xOffset, (float) yOffset, (float) zOffset);
    OpenGL.glNormal3f(0.0F, 1.0F, 0.0F);
    OpenGL.glRotatef(-rm.playerViewY, 0.0F, 1.0F, 0.0F);
    OpenGL.glRotatef(rm.playerViewX, 1.0F, 0.0F, 0.0F);
    OpenGL.glScalef(-f1, -f1, f1);
    OpenGL.glDisable(GL11.GL_LIGHTING);
    OpenGL.glDepthMask(false);
    OpenGL.glDisable(GL11.GL_DEPTH_TEST);
    OpenGL.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexBuffer = tessellator.getBuffer();
    OpenGL.glDisable(GL11.GL_TEXTURE_2D);
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    int j = fontrenderer.getStringWidth(name) / 2;
    float r = 0, g = 0, b = 0;
    float a = 0.25F;
    vertexBuffer.pos((double) (-j - 1), (double) -1, 0.0D).color(r, g, b, a).endVertex();
    vertexBuffer.pos((double) (-j - 1), (double) 8, 0.0D).color(r, g, b, a).endVertex();
    vertexBuffer.pos((double) (j + 1), (double) 8, 0.0D).color(r, g, b, a).endVertex();
    vertexBuffer.pos((double) (j + 1), (double) -1, 0.0D).color(r, g, b, a).endVertex();
    tessellator.draw();
    OpenGL.glEnable(GL11.GL_TEXTURE_2D);
    fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, 0, 553648127);
    OpenGL.glEnable(GL11.GL_DEPTH_TEST);
    OpenGL.glDepthMask(true);
    fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, 0, -1);
    OpenGL.glEnable(GL11.GL_LIGHTING);
    OpenGL.glDisable(GL11.GL_BLEND);
    OpenGL.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    OpenGL.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) FontRenderer(net.minecraft.client.gui.FontRenderer) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 48 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Witchworks by Um-Mitternacht.

the class IBrew method render.

@SideOnly(Side.CLIENT)
default default void render(int x, int y, net.minecraft.client.Minecraft mc, int index) {
    mc.renderEngine.bindTexture(ResourceLocations.BREW_TEXTURES);
    final Tessellator tessellator = Tessellator.getInstance();
    final VertexBuffer buf = tessellator.getBuffer();
    GlStateManager.color(1F, 1F, 1F, 1F);
    final float f = 0.00390625F;
    buf.begin(7, DefaultVertexFormats.POSITION_TEX);
    buf.pos(x, y + 20, 0).tex(236 * f, (236 + 20) * f).endVertex();
    buf.pos(x + 20, y + 20, 0).tex((236 + 20) * f, (236 + 20) * f).endVertex();
    buf.pos(x + 20, y, 0).tex((236 + 20) * f, 236 * f).endVertex();
    buf.pos(x, y, 0).tex(236 * f, 236 * f).endVertex();
    tessellator.draw();
    int textureX = index % 8 * 18;
    int textureY = index / 8 * 18;
    x += 1;
    y += 1;
    buf.begin(7, DefaultVertexFormats.POSITION_TEX);
    buf.pos(x, y + 18, 0).tex(textureX * f, (textureY + 18) * f).endVertex();
    buf.pos(x + 18, y + 18, 0).tex((textureX + 18) * f, (textureY + 18) * f).endVertex();
    buf.pos(x + 18, y, 0).tex((textureX + 18) * f, textureY * f).endVertex();
    buf.pos(x, y, 0).tex(textureX * f, textureY * f).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 49 with VertexBuffer

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

the class EntityCannonBasicRender method renderBase.

private void renderBase(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(baseState), baseState, 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 50 with VertexBuffer

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

the class EventsClient method onDrawBlockHighlightEventLast.

@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onDrawBlockHighlightEventLast(DrawBlockHighlightEvent event) {
    BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
    if (pos != null) {
        PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
        if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null && wrapper.wrapping.centerCoord != null) {
            float partialTicks = event.getPartialTicks();
            Entity player = Minecraft.getMinecraft().thePlayer;
            wrapper.wrapping.renderer.inverseTransform(partialTicks);
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            double xOff = (player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getX();
            double yOff = (player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getY();
            double zOff = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getZ();
            vertexbuffer.xOffset -= xOff;
            vertexbuffer.yOffset -= yOff;
            vertexbuffer.zOffset -= zOff;
        //				GL11.glPopMatrix();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

VertexBuffer (net.minecraft.client.renderer.VertexBuffer)52 Tessellator (net.minecraft.client.renderer.Tessellator)50 BlockPos (net.minecraft.util.math.BlockPos)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 EnumFacing (net.minecraft.util.EnumFacing)5 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)3 Minecraft (net.minecraft.client.Minecraft)3 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)3 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 Entity (net.minecraft.entity.Entity)3 Vec3i (net.minecraft.util.math.Vec3i)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 FontRenderer (net.minecraft.client.gui.FontRenderer)2 RenderManager (net.minecraft.client.renderer.entity.RenderManager)2 Vec3d (net.minecraft.util.math.Vec3d)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 NotNull (org.jetbrains.annotations.NotNull)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)1