Search in sources :

Example 6 with Matrix4f

use of net.minecraft.util.math.vector.Matrix4f in project AgriCraft by AgriCraft.

the class MagnifyingGlassSoilInspector method drawSoilPropertyTexture.

@SuppressWarnings("deprecation")
protected void drawSoilPropertyTexture(MatrixStack transforms, ResourceLocation texture, float x, float w, float u1, float u2) {
    this.bindTexture(texture);
    BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer();
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
    Matrix4f matrix = transforms.getLast().getMatrix();
    float x1 = x * ICON_SCALE;
    float y1 = 0;
    float x2 = x1 + w * ICON_SCALE;
    float y2 = y1 + 12 * ICON_SCALE;
    float v1 = 0.0F;
    float v2 = 1.0F;
    bufferbuilder.pos(matrix, x1, y2, 0).tex(u1, v2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
    bufferbuilder.pos(matrix, x2, y2, 0).tex(u2, v2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
    bufferbuilder.pos(matrix, x2, y1, 0).tex(u2, v1).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
    bufferbuilder.pos(matrix, x1, y1, 0).tex(u1, v1).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
    bufferbuilder.finishDrawing();
    RenderSystem.enableAlphaTest();
    WorldVertexBufferUploader.draw(bufferbuilder);
}
Also used : Matrix4f(net.minecraft.util.math.vector.Matrix4f) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 7 with Matrix4f

use of net.minecraft.util.math.vector.Matrix4f in project BluePower by Qmunity.

the class RenderHelper method drawColoredCube.

/**
 * Draws a colored cube with the size of vector. All faces have the specified color. This uses OpenGL
 *
 * @author Koen Beckers (K4Unl) and Amadornes
 * @param vector
 */
public static void drawColoredCube(AxisAlignedBB vector, IVertexBuilder vertexBuilder, MatrixStack matrixStack, int r, int g, int b, int a, int light, boolean... renderFaces) {
    MatrixStack.Entry entry = matrixStack.last();
    Matrix4f positionMatrix = entry.pose();
    Matrix3f normalMatrix = entry.normal();
    TextureAtlasSprite sprite = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation("minecraft:white_concrete", "")).getParticleIcon();
    float minU = sprite.getU0();
    float maxU = sprite.getU1();
    float minV = sprite.getV0();
    float maxV = sprite.getV1();
    // Top side
    if (renderFaces.length < 1 || renderFaces[0]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
    }
    // Bottom side
    if (renderFaces.length < 2 || renderFaces[1]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
    }
    // Draw west side:
    if (renderFaces.length < 3 || renderFaces[5]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
    }
    // Draw east side:
    if (renderFaces.length < 4 || renderFaces[4]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
    }
    // Draw north side
    if (renderFaces.length < 5 || renderFaces[3]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
    }
    // Draw south side
    if (renderFaces.length < 6 || renderFaces[2]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
    }
}
Also used : Matrix4f(net.minecraft.util.math.vector.Matrix4f) Matrix3f(net.minecraft.util.math.vector.Matrix3f) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation)

Aggregations

Matrix4f (net.minecraft.util.math.vector.Matrix4f)7 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)3 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 BlockBPMultipart (com.bluepowermod.block.BlockBPMultipart)1 BlockGreenHouseAir (com.infinityraider.agricraft.content.world.BlockGreenHouseAir)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 BlockState (net.minecraft.block.BlockState)1 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)1 ModelResourceLocation (net.minecraft.client.renderer.model.ModelResourceLocation)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)1 Matrix3f (net.minecraft.util.math.vector.Matrix3f)1 Quaternion (net.minecraft.util.math.vector.Quaternion)1 World (net.minecraft.world.World)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1