Search in sources :

Example 1 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project GregTech by GregTechCE.

the class TextureArea method draw.

@SideOnly(Side.CLIENT)
public void draw(int x, int y, int width, int height) {
    Minecraft.getMinecraft().renderEngine.bindTexture(imageLocation);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferbuilder.pos(x, y + height, 0.0D).tex(offsetX, offsetY + imageHeight).endVertex();
    bufferbuilder.pos(x + width, y + height, 0.0D).tex(offsetX + imageWidth, offsetY + imageHeight).endVertex();
    bufferbuilder.pos(x + width, y, 0.0D).tex(offsetX + imageWidth, offsetY).endVertex();
    bufferbuilder.pos(x, y, 0.0D).tex(offsetX, offsetY).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project MorePlanets by SteveKunG.

the class GuiChangeLogSlot method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    if (this.visible) {
        this.mouseX = mouseX;
        this.mouseY = mouseY;
        this.drawBackground();
        int i = this.getScrollBarX();
        int j = i + 6;
        this.bindAmountScrolled();
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder vertexbuffer = tessellator.getBuffer();
        this.drawContainerBackground(tessellator);
        int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
        int l = this.top + 4 - (int) this.amountScrolled;
        if (this.hasListHeader) {
            this.drawListHeader(k, l, tessellator);
        }
        this.drawSelectionBox(k, l, mouseX, mouseY, partialTicks);
        GlStateManager.disableDepth();
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.height, 255, 255);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
        GlStateManager.disableAlpha();
        GlStateManager.shadeModel(7425);
        GlStateManager.disableTexture2D();
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        vertexbuffer.pos(this.left, this.top + 4, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
        vertexbuffer.pos(this.right, this.top + 4, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
        vertexbuffer.pos(this.right, this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 100).endVertex();
        vertexbuffer.pos(this.left, this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 100).endVertex();
        tessellator.draw();
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        vertexbuffer.pos(this.left, this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 100).endVertex();
        vertexbuffer.pos(this.right, this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 100).endVertex();
        vertexbuffer.pos(this.right, this.bottom - 4, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
        vertexbuffer.pos(this.left, this.bottom - 4, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
        tessellator.draw();
        int j1 = this.getMaxScroll();
        if (j1 > 0) {
            int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
            k1 = MathHelper.clamp(k1, 32, this.bottom - this.top - 8);
            int l1 = (int) this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;
            if (l1 < this.top) {
                l1 = this.top;
            }
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            vertexbuffer.pos(i, l1 + k1, 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(j, l1 + k1, 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(j, l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(i, l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 100).endVertex();
            tessellator.draw();
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            vertexbuffer.pos(i, l1 + k1 - 1, 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(j - 1, l1 + k1 - 1, 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(j - 1, l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 100).endVertex();
            vertexbuffer.pos(i, l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 100).endVertex();
            tessellator.draw();
        }
        this.renderDecorations(mouseX, mouseY);
        GlStateManager.enableTexture2D();
        GlStateManager.shadeModel(7424);
        GlStateManager.enableAlpha();
        GlStateManager.disableBlend();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 3 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project MorePlanets by SteveKunG.

the class GuiChangeLogSlot method overlayBackground.

@Override
protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha) {
    this.parent.drawCenteredString(this.mc.fontRenderer, "More Planets " + MorePlanetsCore.VERSION + " Change Log", this.width / 2, 16, 16777215);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    this.mc.getTextureManager().bindTexture(this.textureType ? GuiChangeLogSlot.POLISHED_TIN : GuiChangeLogSlot.POLISHED_ALUMINUM);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    float size = 32.0F;
    int color = 150;
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
    vertexbuffer.pos(this.left, endY, 0.0D).tex(0.0D, endY / size).color(color, color, color, endAlpha).endVertex();
    vertexbuffer.pos(this.left + this.width, endY, 0.0D).tex(this.width / size, endY / size).color(color, color, color, endAlpha).endVertex();
    vertexbuffer.pos(this.left + this.width, startY, 0.0D).tex(this.width / size, startY / size).color(color, color, color, startAlpha).endVertex();
    vertexbuffer.pos(this.left, startY, 0.0D).tex(0.0D, startY / size).color(color, color, color, startAlpha).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 4 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project MorePlanets by SteveKunG.

the class LayerVeinFloaterDeath method doRenderLayer.

@Override
public void doRenderLayer(EntityVeinFloater entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    if (entity.deathTicks > 0) {
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder worldrenderer = tessellator.getBuffer();
        float f = (entity.deathTicks + partialTicks) / 200.0F;
        float f1 = 0.0F;
        if (f > 0.8F) {
            f1 = (f - 0.8F) / 0.2F;
        }
        Random random = new Random(432L);
        GlStateManager.disableTexture2D();
        GlStateManager.shadeModel(7425);
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(770, 1);
        GlStateManager.disableAlpha();
        GlStateManager.enableCull();
        GlStateManager.depthMask(false);
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.0F, -0.15F, 0.0F);
        for (int i = 0; i < (f + f * f) / 2.0F * 60.0F; ++i) {
            GlStateManager.rotate(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
            GlStateManager.rotate(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate(random.nextFloat() * 360.0F + f * 90.0F, 0.0F, 0.0F, 1.0F);
            float f2 = random.nextFloat() * 20.0F + 5.0F + f1 * 10.0F;
            float f3 = random.nextFloat() * 2.0F + 1.0F + f1 * 2.0F;
            worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
            worldrenderer.pos(0.0D, 0.0D, 0.0D).color(110, 60, 10, (int) (255.0F * (1.0F - f1))).endVertex();
            worldrenderer.pos(-0.866D * f3, f2, -0.5F * f3).color(110, 60, 10, 0).endVertex();
            worldrenderer.pos(0.866D * f3, f2, -0.5F * f3).color(110, 60, 10, 0).endVertex();
            worldrenderer.pos(0.0D, f2, 1.0F * f3).color(110, 60, 10, 0).endVertex();
            worldrenderer.pos(-0.866D * f3, f2, -0.5F * f3).color(110, 60, 10, 0).endVertex();
            tessellator.draw();
        }
        GlStateManager.popMatrix();
        GlStateManager.depthMask(true);
        GlStateManager.disableCull();
        GlStateManager.disableBlend();
        GlStateManager.shadeModel(7424);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.enableTexture2D();
        GlStateManager.enableAlpha();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Random(java.util.Random) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 5 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project MorePlanets by SteveKunG.

the class SkyProviderNibiru method renderPlanetInSky.

@Override
protected void renderPlanetInSky(float partialTicks, WorldClient world, Minecraft mc) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldrenderer = tessellator.getBuffer();
    float red;
    float green;
    float blue;
    float scale;
    float starBrightness = world.getStarBrightness(partialTicks);
    float[] color = new float[4];
    float rainStrength = this.getRainStrength(world, partialTicks);
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(7425);
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    color[0] = 232 / 255.0F;
    color[1] = 120 / 255.0F;
    color[2] = 32 / 255.0F;
    color[3] = 0.3F - (rainStrength - 0.1F);
    red = color[0];
    green = color[1];
    blue = color[2];
    starBrightness = 1.0F - starBrightness;
    float sunAura = color[3];
    float baseValue = world.isThundering() ? 0.1F : 0.2F;
    if (sunAura < baseValue) {
        sunAura = baseValue;
    }
    sunAura = sunAura * 2 / starBrightness;
    worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(0.0D, 100.0D, 0.0D).color(red * starBrightness, green * starBrightness, blue * starBrightness, sunAura).endVertex();
    // Render sun aura
    scale = 10.0F;
    worldrenderer.pos(-scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(0, 100.0D, (double) -scale * 1.5F).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos((double) scale * 1.5F, 100.0D, 0).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(scale, 100.0D, scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(0, 100.0D, (double) scale * 1.5F).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(-scale, 100.0D, scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos((double) -scale * 1.5F, 100.0D, 0).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(-scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    sunAura = sunAura * starBrightness;
    tessellator.draw();
    worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(0.0D, 100.0D, 0.0D).color(red * starBrightness, green * starBrightness, blue * starBrightness, sunAura).endVertex();
    // Render larger sun aura
    scale = 25.0F;
    worldrenderer.pos(-scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(0, 100.0D, (double) -scale * 1.5F).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos((double) scale * 1.5F, 100.0D, 0).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(scale, 100.0D, scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(0, 100.0D, (double) scale * 1.5F).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(-scale, 100.0D, scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos((double) -scale * 1.5F, 100.0D, 0).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    worldrenderer.pos(-scale, 100.0D, -scale).color(color[0] * starBrightness, color[1] * starBrightness, color[2] * starBrightness, 0.0F).endVertex();
    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.shadeModel(7424);
    GlStateManager.enableTexture2D();
    GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.0F, 0.0F);
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.blendFunc(770, 771);
    GlStateManager.disableTexture2D();
    GlStateManager.color(0.0F, 0.0F, 0.0F, 1.0F);
    scale = 10.0F / Float.MAX_VALUE;
    worldrenderer.begin(7, DefaultVertexFormats.POSITION);
    worldrenderer.pos(-scale, 99.9D, -scale).endVertex();
    worldrenderer.pos(scale, 99.9D, -scale).endVertex();
    worldrenderer.pos(scale, 99.9D, scale).endVertex();
    worldrenderer.pos(-scale, 99.9D, scale).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    // Sirius
    GlStateManager.disableTexture2D();
    GlStateManager.blendFunc(770, 1);
    GlStateManager.color(0.0F, 0.0F, 0.0F, 1.0F);
    // Some blanking to conceal the stars
    scale = this.sunSize / 3.5F;
    worldrenderer.begin(7, DefaultVertexFormats.POSITION);
    worldrenderer.pos(-scale, 99.9D, -scale).endVertex();
    worldrenderer.pos(scale, 99.9D, -scale).endVertex();
    worldrenderer.pos(scale, 99.9D, scale).endVertex();
    worldrenderer.pos(-scale, 99.9D, scale).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F - (rainStrength - 0.1F));
    scale = this.sunSize + 3.5F;
    mc.getTextureManager().bindTexture(this.lazendusTexture);
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
    worldrenderer.pos(-scale, 100.0D, -scale).tex(0.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, -scale).tex(1.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, scale).tex(1.0D, 1.0D).endVertex();
    worldrenderer.pos(-scale, 100.0D, scale).tex(0.0D, 1.0D).endVertex();
    tessellator.draw();
    // Render chalos
    scale = 1.2F;
    GlStateManager.scale(0.6F, 0.6F, 0.6F);
    GlStateManager.rotate(80.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.rotate(200F, 1.0F, 0.0F, 0.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F - (rainStrength - 0.1F));
    mc.getTextureManager().bindTexture(this.chalosTexture);
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
    worldrenderer.pos(-scale, 100.0D, -scale).tex(0.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, -scale).tex(1.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, scale).tex(1.0D, 1.0D).endVertex();
    worldrenderer.pos(-scale, 100.0D, scale).tex(0.0D, 1.0D).endVertex();
    tessellator.draw();
    // Render diona
    scale = 1.25F;
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(0.6F, 0.6F, 0.6F);
    GlStateManager.rotate(40.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.rotate(0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F - (rainStrength - 0.1F));
    mc.getTextureManager().bindTexture(this.dionaTexture);
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
    worldrenderer.pos(-scale, 100.0D, -scale).tex(0.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, -scale).tex(1.0D, 0.0D).endVertex();
    worldrenderer.pos(scale, 100.0D, scale).tex(1.0D, 1.0D).endVertex();
    worldrenderer.pos(-scale, 100.0D, scale).tex(0.0D, 1.0D).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Aggregations

BufferBuilder (net.minecraft.client.renderer.BufferBuilder)358 Tessellator (net.minecraft.client.renderer.Tessellator)292 BlockPos (net.minecraft.util.math.BlockPos)37 Vec3d (net.minecraft.util.math.Vec3d)33 ResourceLocation (net.minecraft.util.ResourceLocation)25 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 IBlockState (net.minecraft.block.state.IBlockState)21 EnumFacing (net.minecraft.util.EnumFacing)21 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)17 Random (java.util.Random)14 Minecraft (net.minecraft.client.Minecraft)13 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)12 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)11 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 World (net.minecraft.world.World)11 ArrayList (java.util.ArrayList)10 ItemStack (net.minecraft.item.ItemStack)10 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)10 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)9