Search in sources :

Example 6 with VertexFormat

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

the class YetaWrenchOverlayRenderer method doRenderOverlay.

private void doRenderOverlay(@Nonnull RenderGameOverlayEvent event, @Nonnull ItemStack equippedWrench) {
    ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(equippedWrench);
    if (mode != cachedMode) {
        cachedMode = mode;
        displayTickCount = 20;
        lastTick = ClientHandler.getTicksElapsed();
    }
    ScaledResolution res = event.getResolution();
    int modeCount = ConduitDisplayMode.registrySize();
    Iterable<ConduitDisplayMode> renderable = ConduitDisplayMode.getRenderableModes();
    switch(PersonalConfig.yetaOverlayMode.get()) {
        case 0:
            if (displayTickCount > 0) {
                if (lastTick < ClientHandler.getTicksElapsed()) {
                    lastTick++;
                    displayTickCount--;
                }
                int x = res.getScaledWidth() / 2 - 8;
                int y = res.getScaledHeight() / 2 - 24;
                IWidgetIcon widget = mode.getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
                int size = 12;
                widget = mode.previous().getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x - 18 + (16 - size), y + (16 - size), size, size, 0, true);
                widget = mode.next().getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x + 18, y + (16 - size), size, size, 0, true);
            } else {
                int x = res.getScaledWidth() - 20;
                int y = res.getScaledHeight() - 20;
                IWidgetIcon widget = mode.getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
            }
            break;
        case 1:
            int size = 16;
            int padding = 2;
            int inset = (int) (size / 1.5);
            int offsetX = res.getScaledWidth() - inset - 1;
            int offsetY = res.getScaledHeight() - modeCount * (size + padding) - padding;
            inset = size - inset;
            int x = offsetX + 2;
            int y = offsetY - (padding * 2);
            int height = (modeCount * (size + padding)) + (padding * 3);
            // FIXME
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glShadeModel(GL11.GL_SMOOTH);
            VertexFormat vf = DefaultVertexFormats.POSITION_COLOR;
            Tessellator tess = Tessellator.getInstance();
            BufferBuilder wr = tess.getBuffer();
            wr.begin(GL11.GL_QUADS, vf);
            wr.pos(x, y, -5).color(0, 0, 0, 0.2f).endVertex();
            ;
            wr.pos(x, y + height, -5).color(0, 0, 0, 0.2f).endVertex();
            ;
            Vector4f color = new Vector4f(0, 0, 0, 1);
            wr.pos(x + size, y + height, -5).color(color.x, color.y, color.z, color.w).endVertex();
            wr.pos(x + size, y, -5).color(color.x, color.y, color.z, color.w).endVertex();
            tess.draw();
            GlStateManager.color(1, 1, 1);
            GL11.glShadeModel(GL11.GL_FLAT);
            y += padding * 2;
            x -= 2;
            if (mode == ConduitDisplayMode.ALL) {
                x -= inset;
            }
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            for (ConduitDisplayMode toRender : renderable) {
                IWidgetIcon widget = mode == ConduitDisplayMode.ALL ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                if (toRender == mode) {
                    widget = toRender.getWidgetSelected();
                    widget.getMap().render(widget, x - inset, y, true);
                } else {
                    widget.getMap().render(widget, x, y, true);
                }
                y += size + padding;
            }
            break;
        case 2:
            offsetX = res.getScaledWidth() - (modeCount * 8) - 16;
            y = res.getScaledHeight() - 40;
            x = offsetX;
            if (modeCount % 2 == 1) {
                x += 8;
            }
            int count = 0;
            for (ConduitDisplayMode toRender : renderable) {
                IWidgetIcon widget = mode == ConduitDisplayMode.ALL || toRender == mode ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
                x += 16;
                if (count == modeCount / 2 - 1) {
                    x = offsetX;
                    y += 16;
                }
                count++;
            }
    }
}
Also used : ConduitDisplayMode(crazypants.enderio.base.conduit.ConduitDisplayMode) ScaledResolution(net.minecraft.client.gui.ScaledResolution) IWidgetIcon(com.enderio.core.api.client.render.IWidgetIcon) Tessellator(net.minecraft.client.renderer.Tessellator) Vector4f(com.enderio.core.common.vecmath.Vector4f) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 7 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project BuildCraft by BuildCraft.

the class LensPluggableModel method create.

public static PerspAwareModelBase create(ItemLens lensItem, int meta) {
    LensPluggable lens = new LensPluggable(new ItemStack(lensItem, 1, meta));
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(lens.isFilter, EnumFacing.EAST, format));
    quads.addAll(INSTANCE.bakeTransclucent(lens.dyeColor, lens.isFilter, EnumFacing.EAST, format));
    return new PerspAwareModelBase(format, quads.build(), spriteLensCutout, getBlockTransforms());
}
Also used : LensPluggable(buildcraft.transport.pluggable.LensPluggable) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) ItemStack(net.minecraft.item.ItemStack) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 8 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project BuildCraft by BuildCraft.

the class ModelPowerAdapter method create.

public static PerspAwareModelBase create() {
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(EnumFacing.EAST, format));
    return new PerspAwareModelBase(format, quads.build(), spritePowerAdapter, getBlockTransforms());
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 9 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project BuildCraft by BuildCraft.

the class PlugPluggableModel method create.

public static PerspAwareModelBase create() {
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(EnumFacing.SOUTH, format));
    return new PerspAwareModelBase(format, quads.build(), spritePlug, getPluggableTransforms());
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 10 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project BuildCraft by BuildCraft.

the class PipeWireRenderer method renderQuads.

private static void renderQuads(MutableQuad[] quads, ISprite sprite, int level) {
    VertexFormat vf = DefaultVertexFormats.POSITION_TEX_COLOR;
    Tessellator tessellator = new Tessellator(quads.length * vf.getNextOffset());
    BufferBuilder bb = tessellator.getBuffer();
    bb.begin(GL11.GL_QUADS, vf);
    float vOffset = (level & 0xF) / 16f;
    for (MutableQuad q : quads) {
        if (q.getFace() != EnumFacing.UP && level != 15) {
            q = new MutableQuad(q);
            float shade = 1 - q.getCalculatedDiffuse();
            shade = shade * (15 - level) / 15;
            shade = 1 - shade;
            q.multColourd(shade);
        }
        renderVertex(bb, q.vertex_0, sprite, vOffset);
        renderVertex(bb, q.vertex_1, sprite, vOffset);
        renderVertex(bb, q.vertex_2, sprite, vOffset);
        renderVertex(bb, q.vertex_3, sprite, vOffset);
    }
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Aggregations

VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)23 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)10 PerspAwareModelBase (buildcraft.core.lib.client.model.PerspAwareModelBase)4 ImmutableList (com.google.common.collect.ImmutableList)4 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)4 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 VertexFormatElement (net.minecraft.client.renderer.vertex.VertexFormatElement)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 MutableQuad (buildcraft.lib.client.model.MutableQuad)1 LensPluggable (buildcraft.transport.pluggable.LensPluggable)1 IWidgetIcon (com.enderio.core.api.client.render.IWidgetIcon)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 Lists (com.google.common.collect.Lists)1 ConduitDisplayMode (crazypants.enderio.base.conduit.ConduitDisplayMode)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1