Search in sources :

Example 11 with Tessellator

use of net.minecraft.client.render.Tessellator in project StationAPI by ModificationStation.

the class MixinWorldRenderer method endSky.

@Inject(method = "renderSky(F)V", at = @At("HEAD"), cancellable = true)
private void endSky(float f, CallbackInfo ci) {
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    // RenderHelper.disableLighting();
    GL11.glDepthMask(false);
    this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky6.png"));
    Tessellator var21 = Tessellator.INSTANCE;
    for (int var22 = 0; var22 < 6; ++var22) {
        GL11.glPushMatrix();
        if (var22 == 1) {
            this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky1.png"));
            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        }
        if (var22 == 2) {
            this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky4.png"));
            GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
        }
        if (var22 == 3) {
            // this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky2.png"));
            // this.textureManager.bindTexture(this.textureManager.getTextureId(ExpandableTextureAtlas.STATION_GUI_ITEMS.spritesheet));
            // ((CustomAtlasProvider) ItemListener.testItem).getAtlas().of(ItemListener.testItem.getTexturePosition(0)).bindAtlas();
            // Atlases.getStationJsonModels().bindAtlas();
            this.textureManager.bindTexture(StationRenderAPI.getBakedModelManager().getAtlas(Atlases.GAME_ATLAS_TEXTURE).getGlId());
            GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
        }
        if (var22 == 4) {
            this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky3.png"));
            GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
        }
        if (var22 == 5) {
            this.textureManager.bindTexture(this.textureManager.getTextureId("/assets/sltest/textures/skybox/sky5.png"));
            GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
        }
        var21.start();
        // var21.colour(2631720);
        // var21.colour(0xffffff);
        /*Vec3f light = level.method_279(client.viewEntity, f);
            float l = (float) ((light.x + light.y + light.z) / 3);
            var21.colour(l, l, l);*/
        float light = level.dimension.lightTable[15 - level.field_202];
        var21.colour(light, light, light);
        if (var22 == 2) {
            var21.vertex(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
            var21.vertex(-100.0D, -100.0D, 100.0D, 0.0D, -1.0D);
            var21.vertex(100.0D, -100.0D, 100.0D, -1.0D, -1.0D);
            var21.vertex(100.0D, -100.0D, -100.0D, -1.0D, 0.0D);
        } else if (var22 == 3 || var22 == 5) {
            var21.vertex(-100.0D, -100.0D, -100.0D, 1.0D, 0.0D);
            var21.vertex(-100.0D, -100.0D, 100.0D, 0.0D, 0.0D);
            var21.vertex(100.0D, -100.0D, 100.0D, 0.0D, 1.0D);
            var21.vertex(100.0D, -100.0D, -100.0D, 1.0D, 1.0D);
        } else if (var22 == 4) {
            var21.vertex(-100.0D, -100.0D, -100.0D, 0.0D, 1.0D);
            var21.vertex(-100.0D, -100.0D, 100.0D, 1.0D, 1.0D);
            var21.vertex(100.0D, -100.0D, 100.0D, 1.0D, 0.0D);
            var21.vertex(100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
        } else {
            var21.vertex(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
            var21.vertex(-100.0D, -100.0D, 100.0D, 0.0D, 1.0D);
            var21.vertex(100.0D, -100.0D, 100.0D, 1.0D, 1.0D);
            var21.vertex(100.0D, -100.0D, -100.0D, 1.0D, 0.0D);
        }
        // var21.pos(-100.0D, -100.0D, -100.0D);
        // var21.pos(-100.0D, -100.0D, 100.0D);
        // var21.pos(100.0D, -100.0D, 100.0D);
        // var21.pos(100.0D, -100.0D, -100.0D);
        var21.draw();
        GL11.glPopMatrix();
    }
    GL11.glEnable(GL11.GL_FOG);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    ci.cancel();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 12 with Tessellator

use of net.minecraft.client.render.Tessellator in project StationAPI by ModificationStation.

the class ArsenicOverlayRenderer method renderItem3D.

public void renderItem3D(Living entity, ItemInstance item) {
    GL11.glPushMatrix();
    if (item.itemId < BlockBase.BY_ID.length && BlockRenderer.method_42(BlockBase.BY_ID[item.itemId].getRenderType()))
        overlayRendererAccessor.stationapi$getField_2405().method_48(BlockBase.BY_ID[item.itemId], item.getDamage(), entity.getBrightnessAtEyes(1.0F));
    else {
        Tessellator var3 = Tessellator.INSTANCE;
        int var4 = entity.method_917(item);
        SpriteAtlasTexture atlas = StationRenderAPI.getBakedModelManager().getAtlas(Atlases.GAME_ATLAS_TEXTURE);
        atlas.bindTexture();
        Sprite texture = atlas.getSprite(((CustomAtlasProvider) item.getType()).getAtlas().getTexture(var4).getId());
        float var5 = texture.getMinU() + (texture.getMaxU() - texture.getMinU()) * 0.000625F;
        float var6 = texture.getMaxU();
        float var7 = texture.getMinV() + (texture.getMaxV() - texture.getMinV()) * 0.000625F;
        float var8 = texture.getMaxV();
        float var9 = 1.0F;
        float var10 = 0.0F;
        float var11 = 0.3F;
        GL11.glEnable(32826);
        GL11.glTranslatef(-var10, -var11, 0.0F);
        float var12 = 1.5F;
        GL11.glScalef(var12, var12, var12);
        GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
        GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
        float var13 = 0.0625F;
        var3.start();
        var3.setNormal(0.0F, 0.0F, 1.0F);
        var3.vertex(0.0D, 0.0D, 0.0D, var6, var8);
        var3.vertex(var9, 0.0D, 0.0D, var5, var8);
        var3.vertex(var9, 1.0D, 0.0D, var5, var7);
        var3.vertex(0.0D, 1.0D, 0.0D, var6, var7);
        var3.draw();
        var3.start();
        var3.setNormal(0.0F, 0.0F, -1.0F);
        var3.vertex(0.0D, 1.0D, 0.0F - var13, var6, var7);
        var3.vertex(var9, 1.0D, 0.0F - var13, var5, var7);
        var3.vertex(var9, 0.0D, 0.0F - var13, var5, var8);
        var3.vertex(0.0D, 0.0D, 0.0F - var13, var6, var8);
        var3.draw();
        var3.start();
        var3.setNormal(-1.0F, 0.0F, 0.0F);
        for (int var14 = 0; var14 < texture.getHeight(); ++var14) {
            float var15 = (float) var14 / texture.getHeight();
            float var16 = var6 + (var5 - var6) * var15 - 1F / (texture.getHeight() * texture.getHeight() * 2);
            float var17 = var9 * var15;
            var3.vertex(var17, 0.0D, 0.0F - var13, var16, var8);
            var3.vertex(var17, 0.0D, 0.0D, var16, var8);
            var3.vertex(var17, 1.0D, 0.0D, var16, var7);
            var3.vertex(var17, 1.0D, 0.0F - var13, var16, var7);
        }
        var3.draw();
        var3.start();
        var3.setNormal(1.0F, 0.0F, 0.0F);
        for (int var18 = 0; var18 < texture.getHeight(); ++var18) {
            float var21 = (float) var18 / texture.getHeight();
            float var24 = var6 + (var5 - var6) * var21 - 1F / (texture.getHeight() * texture.getHeight() * 2);
            float var27 = var9 * var21 + 1F / texture.getHeight();
            var3.vertex(var27, 1.0D, 0.0F - var13, var24, var7);
            var3.vertex(var27, 1.0D, 0.0D, var24, var7);
            var3.vertex(var27, 0.0D, 0.0D, var24, var8);
            var3.vertex(var27, 0.0D, 0.0F - var13, var24, var8);
        }
        var3.draw();
        var3.start();
        var3.setNormal(0.0F, 1.0F, 0.0F);
        for (int var19 = 0; var19 < texture.getWidth(); ++var19) {
            float var22 = (float) var19 / texture.getWidth();
            float var25 = var8 + (var7 - var8) * var22 - 1F / (texture.getWidth() * texture.getWidth() * 2);
            float var28 = var9 * var22 + 1F / texture.getWidth();
            var3.vertex(0.0D, var28, 0.0D, var6, var25);
            var3.vertex(var9, var28, 0.0D, var5, var25);
            var3.vertex(var9, var28, 0.0F - var13, var5, var25);
            var3.vertex(0.0D, var28, 0.0F - var13, var6, var25);
        }
        var3.draw();
        var3.start();
        var3.setNormal(0.0F, -1.0F, 0.0F);
        for (int var20 = 0; var20 < texture.getWidth(); ++var20) {
            float var23 = (float) var20 / texture.getWidth();
            float var26 = var8 + (var7 - var8) * var23 - 1F / (texture.getWidth() * texture.getWidth() * 2);
            float var29 = var9 * var23;
            var3.vertex(var9, var29, 0.0D, var5, var26);
            var3.vertex(0.0D, var29, 0.0D, var6, var26);
            var3.vertex(0.0D, var29, 0.0F - var13, var6, var26);
            var3.vertex(var9, var29, 0.0F - var13, var5, var26);
        }
        var3.draw();
        GL11.glDisable(32826);
    }
    GL11.glPopMatrix();
}
Also used : SpriteAtlasTexture(net.modificationstation.stationapi.api.client.texture.SpriteAtlasTexture) Tessellator(net.minecraft.client.render.Tessellator) Sprite(net.modificationstation.stationapi.api.client.texture.Sprite)

Example 13 with Tessellator

use of net.minecraft.client.render.Tessellator in project StationAPI by ModificationStation.

the class BakedModelRendererImpl method renderWorld.

@Override
public boolean renderWorld(BlockState state, BakedModel model, BlockView blockView, int x, int y, int z, int textureOverride) {
    posAccessor.stationapi$setX(x);
    posAccessor.stationapi$setY(y);
    posAccessor.stationapi$setZ(z);
    long seed = state.getRenderingSeed(pos);
    if (!model.isVanillaAdapter()) {
        BlockRenderContext context = CONTEXTS.get();
        return context.render(blockView, model, state, pos, random, seed);
    }
    BlockBase block = state.getBlock();
    if (textureOverride >= 0)
        return true;
    Tessellator t = Tessellator.INSTANCE;
    StationTessellator fastT = StationTessellator.get(t);
    light.initialize(block, blockView, x, y, z, Minecraft.isSmoothLightingEnabled() && model.useAmbientOcclusion());
    boolean rendered = false;
    ImmutableList<BakedQuad> qs;
    BakedQuad q;
    float[] qlight = light.light;
    for (int quadSet = 0, size = DIRECTIONS.length; quadSet < size; quadSet++) {
        Direction face = DIRECTIONS[quadSet];
        random.setSeed(seed);
        qs = model.getQuads(state, face, random);
        if (!qs.isEmpty() && (face == null || block.isSideRendered(blockView, x + face.vector.x, y + face.vector.y, z + face.vector.z, quadSet))) {
            rendered = true;
            for (int j = 0, quadSize = qs.size(); j < quadSize; j++) {
                q = qs.get(j);
                light.calculateForQuad(q);
                if (q.hasColour()) {
                    int i = StationRenderAPI.getBlockColours().getColour(state, blockView, pos, q.getColorIndex());
                    float r = redI2F(i);
                    float g = greenI2F(i);
                    float b = blueI2F(i);
                    if (GameRenderer.anaglyph3d) {
                        float colourMultiplierGreenTmp = (r * 30F + g * 70F) / 100F, colourMultiplierBlueTmp = (r * 30F + b * 70F) / 100F;
                        r = (r * 30F + g * 59F + b * 11F) / 100F;
                        g = colourMultiplierGreenTmp;
                        b = colourMultiplierBlueTmp;
                    }
                    fastT.quad(q.getVertexData(), x, y, z, colourF2I(r * qlight[0], g * qlight[0], b * qlight[0]), colourF2I(r * qlight[1], g * qlight[1], b * qlight[1]), colourF2I(r * qlight[2], g * qlight[2], b * qlight[2]), colourF2I(r * qlight[3], g * qlight[3], b * qlight[3]));
                } else
                    fastT.quad(q.getVertexData(), x, y, z, colourF2I(qlight[0], qlight[0], qlight[0]), colourF2I(qlight[1], qlight[1], qlight[1]), colourF2I(qlight[2], qlight[2], qlight[2]), colourF2I(qlight[3], qlight[3], qlight[3]));
            }
        }
    }
    return rendered;
}
Also used : BakedQuad(net.modificationstation.stationapi.api.client.render.model.BakedQuad) Tessellator(net.minecraft.client.render.Tessellator) StationTessellator(net.modificationstation.stationapi.api.client.render.StationTessellator) BlockBase(net.minecraft.block.BlockBase) StationTessellator(net.modificationstation.stationapi.api.client.render.StationTessellator) Direction(net.modificationstation.stationapi.api.util.math.Direction)

Example 14 with Tessellator

use of net.minecraft.client.render.Tessellator in project KiwiClient by TangyKiwi.

the class ColorUtil method fillGradient.

public static void fillGradient(MatrixStack matrixStack, int xStart, int yStart, int xEnd, int yEnd, int colorStart, int colorEnd) {
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    // RenderSystem.disableAlphaTest();
    RenderSystem.defaultBlendFunc();
    // RenderSystem.shadeModel(7425);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    float f = (float) (colorStart >> 24 & 255) / 255.0F;
    float g = (float) (colorStart >> 16 & 255) / 255.0F;
    float h = (float) (colorStart >> 8 & 255) / 255.0F;
    float i = (float) (colorStart & 255) / 255.0F;
    float j = (float) (colorEnd >> 24 & 255) / 255.0F;
    float k = (float) (colorEnd >> 16 & 255) / 255.0F;
    float l = (float) (colorEnd >> 8 & 255) / 255.0F;
    float m = (float) (colorEnd & 255) / 255.0F;
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xEnd, (float) yStart, (float) 0).color(g, h, i, f).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xStart, (float) yStart, (float) 0).color(g, h, i, f).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xStart, (float) yEnd, (float) 0).color(k, l, m, j).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xEnd, (float) yEnd, (float) 0).color(k, l, m, j).next();
    tessellator.draw();
    // RenderSystem.shadeModel(7424);
    RenderSystem.disableBlend();
    // RenderSystem.enableAlphaTest();
    RenderSystem.enableTexture();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 15 with Tessellator

use of net.minecraft.client.render.Tessellator in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method myDrawFrameBuffer.

/**
 * {@link GlFramebuffer#draw(int, int)}
 */
public static void myDrawFrameBuffer(GlFramebuffer textureProvider, boolean doEnableAlphaTest, boolean doEnableModifyAlpha) {
    Helper.checkGlError();
    Validate.isTrue(GLX.isUsingFBOs());
    if (doEnableModifyAlpha) {
        GlStateManager.colorMask(true, true, true, true);
    } else {
        GlStateManager.colorMask(true, true, true, false);
    }
    GlStateManager.disableDepthTest();
    GlStateManager.depthMask(false);
    GlStateManager.matrixMode(5889);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0.0D, (double) textureProvider.viewWidth, (double) textureProvider.viewHeight, 0.0D, 1000.0D, 3000.0D);
    GlStateManager.matrixMode(5888);
    GlStateManager.loadIdentity();
    GlStateManager.translatef(0.0F, 0.0F, -2000.0F);
    GlStateManager.viewport(0, 0, textureProvider.viewWidth, textureProvider.viewHeight);
    GlStateManager.enableTexture();
    GlStateManager.disableLighting();
    if (doEnableAlphaTest) {
        GlStateManager.enableAlphaTest();
    } else {
        GlStateManager.disableAlphaTest();
    }
    GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    textureProvider.beginRead();
    float float_1 = (float) textureProvider.viewWidth;
    float float_2 = (float) textureProvider.viewHeight;
    float float_3 = (float) textureProvider.viewWidth / (float) textureProvider.texWidth;
    float float_4 = (float) textureProvider.viewHeight / (float) textureProvider.texHeight;
    Tessellator tessellator_1 = Tessellator.getInstance();
    BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder();
    bufferBuilder_1.begin(7, VertexFormats.POSITION_UV_COLOR);
    bufferBuilder_1.vertex(0.0D, (double) float_2, 0.0D).texture(0.0D, 0.0D).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex((double) float_1, (double) float_2, 0.0D).texture((double) float_3, 0.0D).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex((double) float_1, 0.0D, 0.0D).texture((double) float_3, (double) float_4).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex(0.0D, 0.0D, 0.0D).texture(0.0D, (double) float_4).color(255, 255, 255, 255).next();
    tessellator_1.draw();
    textureProvider.endRead();
    GlStateManager.depthMask(true);
    GlStateManager.colorMask(true, true, true, true);
    Helper.checkGlError();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Aggregations

Tessellator (net.minecraft.client.render.Tessellator)45 BufferBuilder (net.minecraft.client.render.BufferBuilder)41 GameRenderer (net.minecraft.client.render.GameRenderer)29 MatrixStack (net.minecraft.client.util.math.MatrixStack)12 Color (java.awt.Color)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 Matrix4f (net.minecraft.util.math.Matrix4f)3 Framebuffer (net.minecraft.client.gl.Framebuffer)2 Shader (net.minecraft.client.render.Shader)2 Box (net.minecraft.util.math.Box)2 Vec3d (net.minecraft.util.math.Vec3d)2 Mirror (com.qouteall.immersive_portals.portal.Mirror)1 Random (java.util.Random)1 BlockBase (net.minecraft.block.BlockBase)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 VertexBuffer (net.minecraft.client.gl.VertexBuffer)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 StationTessellator (net.modificationstation.stationapi.api.client.render.StationTessellator)1