codechicken.lib.render.RenderUtils Java Examples

The following examples show how to use codechicken.lib.render.RenderUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SubscribeEvent
public void renderLastEvent(RenderWorldLastEvent event) {
    if (NEIClientConfig.isEnabled()) {
        GlStateManager.pushMatrix();
        GlStateTracker.pushState();

        Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
        RenderUtils.translateToWorldCoords(entity, event.getPartialTicks());

        renderChunkBounds(entity);
        renderMobSpawnOverlay(entity);

        GlStateTracker.popState();
        GlStateManager.popMatrix();
    }

}
 
Example #2
Source File: TankLayerRenderer.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, AbstractClientPlayerEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    if (UUIDS.contains(entity.getUniqueID())) {
        CCRenderState ccrs = CCRenderState.instance();
        ccrs.brightness = packedLight;
        ccrs.overlay = OverlayTexture.NO_OVERLAY;
        Matrix4 mat = new Matrix4(mStack);
        mat.rotate(MathHelper.torad * 180, Vector3.X_POS);
        mat.scale(0.5);
        if (entity.isShiftKeyDown()) {
            mat.translate(0, -0.5, 0);
        }
        if (entity.isElytraFlying()) {
            headPitch = -45;
        }
        mat.rotate(netHeadYaw * MathHelper.torad, Vector3.Y_NEG);
        mat.rotate(headPitch * MathHelper.torad, Vector3.X_POS);
        mat.translate(-0.5, 1, -0.5);
        RenderTileEnderTank.renderTank(ccrs, mat, getter, 0, (float) (MathHelper.torad * 90F), 0, BLANK, 0);

        FluidStack stack = FluidUtils.water.copy();
        float bob = 0.45F + RenderUtils.getPearlBob(ClientUtils.getRenderTime()) * 2;
        stack.setAmount((int) MathHelper.map(bob, 0.2, 0.6, 1000, 14000));
        mat.translate(-0.5, 0, -0.5);
        RenderTileEnderTank.renderFluid(ccrs, mat, getter, stack);

    }
}
 
Example #3
Source File: RenderTileEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void render(TileEnderChest enderChest, float partialTicks, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) {
    CCRenderState ccrs = CCRenderState.instance();
    ccrs.brightness = packedLight;
    ccrs.overlay = packedOverlay;
    double yToCamera = enderChest.getPos().getY() - renderDispatcher.renderInfo.getProjectedView().y;
    renderChest(ccrs, mStack, getter, enderChest.rotation, yToCamera, enderChest.getFrequency(), (float) enderChest.getRadianLidAngle(partialTicks), RenderUtils.getTimeOffset(enderChest.getPos()));
}
 
Example #4
Source File: RenderTileEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
public static void renderChest(CCRenderState ccrs, MatrixStack mStack, IRenderTypeBuffer getter, int rotation, double yToCamera, Frequency freq, float lidAngle, int pearlOffset) {
    Matrix4 mat = new Matrix4(mStack);
    if (lidAngle != 0) {//Micro optimization, lid closed, dont render starfield.
        renderEndPortal.render(mat, getter, yToCamera);
    }
    ccrs.reset();
    mStack.push();
    mStack.translate(0, 1.0, 1.0);
    mStack.scale(1.0F, -1.0F, -1.0F);
    mStack.translate(0.5, 0.5, 0.5);
    mStack.rotate(new Quaternion(0, rotation * 90, 0, true));
    mStack.translate(-0.5, -0.5, -0.5);
    model.chestLid.rotateAngleX = lidAngle;
    model.render(mStack, getter.getBuffer(chestType), ccrs.brightness, ccrs.overlay, freq.hasOwner());
    mStack.pop();

    //Buttons
    ccrs.bind(buttonType, getter);
    EnumColour[] colours = freq.toArray();
    for (int i = 0; i < 3; i++) {
        CCModel button = ButtonModelLibrary.button.copy();
        button.apply(BlockEnderChest.buttonT[i]);
        button.apply(new Translation(0.5, 0, 0.5));
        button.apply(new Rotation(lidAngle, 1, 0, 0).at(new Vector3(0, 9D / 16D, 1 / 16D)));
        button.apply(new Rotation((-90 * (rotation)) * MathHelper.torad, Vector3.Y_POS).at(new Vector3(0.5, 0, 0.5)));
        button.render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4)));
    }
    mat.translate(0.5, 0, 0.5);

    //Pearl
    if (lidAngle != 0) {//Micro optimization, lid closed, dont render pearl.
        double time = ClientUtils.getRenderTime() + pearlOffset;
        Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.2 + lidAngle * -0.5 + RenderUtils.getPearlBob(time), 0), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04);
        ccrs.brightness = 15728880;
        ccrs.bind(pearlType, getter);
        CCModelLibrary.icosahedron4.render(ccrs, pearlMat);
    }
    ccrs.reset();
}
 
Example #5
Source File: EnderTankRenderer.java    From EnderStorage with MIT License 5 votes vote down vote up
public static void renderLiquid(FluidStack liquid, double x, double y, double z)
{
    RenderUtils.renderFluidCuboid(liquid, 
            new Cuboid6(0.22, 0.12, 0.22, 0.78, 0.121+0.63, 0.78)
                .add(new Vector3(x, y, z)), 
            liquid.amount/(16D*FluidUtils.B), 0.75);
}
 
Example #6
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void render(float frame) {
    GlStateManager.pushMatrix();
    Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
    RenderUtils.translateToWorldCoords(entity, frame);

    renderChunkBounds(entity);
    renderMobSpawnOverlay(entity);
    GlStateManager.popMatrix();
}
 
Example #7
Source File: PartFrame.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean drawHighlight(MovingObjectPosition hit, EntityPlayer player, float frame) {

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4f(0, 0, 0, 0.4F);
    GL11.glLineWidth(2);
    GL11.glDepthMask(true);
    GL11.glPushMatrix();
    RenderUtils.translateToWorldCoords(player, frame);
    GL11.glTranslated(x(), y(), z());
    {
        double d = 0.002;

        if (!is2D()) {
            RenderUtils.drawCuboidOutline(new Cuboid6(2 / 16D + d, isSideHidden(ForgeDirection.DOWN) ? d * 2 : -d * 2, 2 / 16D + d,
                    14 / 16D - d, 1 + (isSideHidden(ForgeDirection.UP) ? -d * 2 : d * 2), 14 / 16D - d));
            RenderUtils.drawCuboidOutline(new Cuboid6(isSideHidden(ForgeDirection.WEST) ? d * 2 : -d * 2, 2 / 16D + d, 2 / 16D + d,
                    1 + (isSideHidden(ForgeDirection.EAST) ? -d * 2 : d * 2), 14 / 16D - d, 14 / 16D - d));
            RenderUtils.drawCuboidOutline(new Cuboid6(2 / 16D + d, 2 / 16D + d, isSideHidden(ForgeDirection.NORTH) ? d : -d,
                    14 / 16D - d, 14 / 16D - d, 1 + (isSideHidden(ForgeDirection.SOUTH) ? -d * 2 : d * 2)));
        }

        RenderUtils.drawCuboidOutline(new Cuboid6(0, 0, 0, 1, 1, 1).expand(d));
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}
 
Example #8
Source File: GuiModListScroll.java    From CodeChickenCore with MIT License 4 votes vote down vote up
private static void register(ModContainer mod) {
    if (!RenderUtils.checkEnableStencil())
        CodeChickenCorePlugin.logger.error("Unable to do mod description scrolling due to lack of stencil buffer");
    else
        scrollMods.add(mod);
}
 
Example #9
Source File: TileCraftingGridRenderer.java    From Translocators with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
{
    TileCraftingGrid tcraft = (TileCraftingGrid)tile;
    
    TextureUtils.bindAtlas(0);
    IIcon icon = Translocator.blockCraftingGrid.gridIcon;
    Tessellator t = Tessellator.instance;
    t.setTranslation(x, y+0.001, z);
    t.startDrawingQuads();
    t.setNormal(0, 1, 0);
    t.addVertexWithUV(1, 0, 0, icon.getMinU(), icon.getMinV());
    t.addVertexWithUV(0, 0, 0, icon.getMinU(), icon.getMaxV());
    t.addVertexWithUV(0, 0, 1, icon.getMaxU(), icon.getMaxV());
    t.addVertexWithUV(1, 0, 1, icon.getMaxU(), icon.getMinV());
    t.draw();
    t.setTranslation(0, 0, 0);

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glPushMatrix();
    GL11.glTranslated(x+0.5, y, z+0.5);
    Transformation orient = Rotation.quarterRotations[tcraft.rotation];

    for(int i = 0; i < 9; i++)
    {
        ItemStack item = tcraft.items[i];
        if(item == null)
            continue;
        
        int row = i/3;
        int col = i%3;

        Vector3 pos = new Vector3((col-1)*5/16D, 0.1+0.01*Math.sin(i*1.7+ClientUtils.getRenderTime()/5), (row-1)*5/16D).apply(orient);
        GL11.glPushMatrix();
        GL11.glTranslated(pos.x, pos.y, pos.z);
        GL11.glScaled(0.5, 0.5, 0.5);

        RenderUtils.renderItemUniform(item);

        GL11.glPopMatrix();
    }
    
    if(tcraft.result != null)
    {
        GL11.glPushMatrix();
        GL11.glTranslated(0, 0.6 + 0.02 * Math.sin(ClientUtils.getRenderTime() / 10), 0);
        GL11.glScaled(0.8, 0.8, 0.8);

        RenderUtils.renderItemUniform(tcraft.result, ClientUtils.getRenderTime());
        
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
 
Example #10
Source File: TileTranslocatorRenderer.java    From Translocators with MIT License 4 votes vote down vote up
private void drawLiquidSpiral(int src, int dst, FluidStack stack, double start, double end, double time, double theta0, double x, double y, double z)
{
    IIcon tex = RenderUtils.prepareFluidRender(stack, 255);
    
    CCRenderState.startDrawing(7);
    Tessellator t = Tessellator.instance;
    t.setTranslation(x, y, z);
    
    Vector3[] last = new Vector3[]{new Vector3(), new Vector3(), new Vector3(), new Vector3()};
    Vector3[] next = new Vector3[]{new Vector3(), new Vector3(), new Vector3(), new Vector3()};
    double tess = 0.05;

    Vector3 a = getPerp(src, dst);
    boolean rev = sum(a.copy().crossProduct(getPathNormal(src, dst, 0))) != sum(sideVec[src]);
    
    for(double di = end; di <= start; di+=tess)
    {
        Vector3 b = getPathNormal(src, dst, di);
        Vector3 c = getPath(src, dst, di);
        
        if(rev)
            b.negate();
        
        double r = (2*di-time/10+theta0+dst/6)*2*Math.PI;
        double sz = 0.1;
        Vector3 p = c.add(a.copy().multiply(MathHelper.sin(r)*sz)).add(b.copy().multiply(MathHelper.cos(r)*sz));

        double s1 = 0.02;
        double s2 =-0.02;
        next[0].set(p).add(a.x*s1+b.x*s1, a.y*s1+b.y*s1, a.z*s1+b.z*s1);
        next[1].set(p).add(a.x*s2+b.x*s1, a.y*s2+b.y*s1, a.z*s2+b.z*s1);
        next[2].set(p).add(a.x*s2+b.x*s2, a.y*s2+b.y*s2, a.z*s2+b.z*s2);
        next[3].set(p).add(a.x*s1+b.x*s2, a.y*s1+b.y*s2, a.z*s1+b.z*s2);
        
        if(di > end)
        {
            double u1 = tex.getInterpolatedU(Math.abs(di)*16);
            double u2 = tex.getInterpolatedU(Math.abs(di-tess)*16);
            for(int i = 0; i < 4; i++)
            {
                int j = (i+1)%4;
                Vector3 axis = next[j].copy().subtract(next[i]);
                double v1 = tex.getInterpolatedV(Math.abs(next[i].scalarProject(axis))*16);
                double v2 = tex.getInterpolatedV(Math.abs(next[j].scalarProject(axis))*16);
                t.addVertexWithUV(next[i].x, next[i].y, next[i].z, u1, v1);
                t.addVertexWithUV(next[j].x, next[j].y, next[j].z, u1, v2);
                t.addVertexWithUV(last[j].x, last[j].y, last[j].z, u2, v2);
                t.addVertexWithUV(last[i].x, last[i].y, last[i].z, u2, v1);
            }
        }
        
        Vector3[] tmp = last;
        last = next;
        next = tmp;
    }
    
    CCRenderState.draw();
    t.setTranslation(0, 0, 0);
    
    RenderUtils.postFluidRender();
}