Search in sources :

Example 1 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project Skyblocker by LifeIsAParadox.

the class RenderUtils method drawBoxOutline.

public static void drawBoxOutline(Box box, QuadColor color, float lineWidth, Direction... excludeDirs) {
    if (!FrustumUtils.isBoxVisible(box)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Outline
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(lineWidth);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexBoxLines(matrices, buffer, Boxes.moveToZero(box), color, excludeDirs);
    tessellator.draw();
    RenderSystem.enableCull();
    cleanup();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 2 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project MCDoom by AzureDoom.

the class ChaingunMobRender method render.

@Override
public void render(ChaingunMobEntity persistentProjectileEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, persistentProjectileEntity.prevYaw, persistentProjectileEntity.getYaw()) - 90.0F));
    matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, persistentProjectileEntity.prevPitch, persistentProjectileEntity.getPitch())));
    matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(45.0F));
    matrixStack.scale(0.05625F, 0.05625F, 0.05625F);
    matrixStack.translate(-4.0D, 0.0D, 0.0D);
    VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(this.getTexture(persistentProjectileEntity)));
    MatrixStack.Entry entry = matrixStack.peek();
    Matrix4f matrix4f = entry.getPositionMatrix();
    Matrix3f matrix3f = entry.getNormalMatrix();
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, -2, 0.0F, 0.15625F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, 2, 0.15625F, 0.15625F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, 2, 0.15625F, 0.3125F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, -2, 0.0F, 0.3125F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, -2, 0.0F, 0.15625F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, 2, 0.15625F, 0.15625F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, 2, 0.15625F, 0.3125F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, -2, 0.0F, 0.3125F, 1, 0, 0, i);
    for (int u = 0; u < 4; ++u) {
        matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
        this.method_23153(matrix4f, matrix3f, vertexConsumer, -8, -2, 0, 0.0F, 0.0F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, 8, -2, 0, 0.5F, 0.0F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, 8, 2, 0, 0.5F, 0.15625F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, -8, 2, 0, 0.0F, 0.15625F, 0, 1, 0, i);
    }
    matrixStack.pop();
    super.render(persistentProjectileEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Example 3 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project MCDoom by AzureDoom.

the class DroneBoltRender method render.

@Override
public void render(DroneBoltEntity persistentProjectileEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, persistentProjectileEntity.prevYaw, persistentProjectileEntity.getYaw()) - 90.0F));
    matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, persistentProjectileEntity.prevPitch, persistentProjectileEntity.getPitch())));
    matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(45.0F));
    matrixStack.scale(0.05625F, 0.05625F, 0.05625F);
    matrixStack.translate(-4.0D, 0.0D, 0.0D);
    VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(this.getTexture(persistentProjectileEntity)));
    MatrixStack.Entry entry = matrixStack.peek();
    Matrix4f matrix4f = entry.getPositionMatrix();
    Matrix3f matrix3f = entry.getNormalMatrix();
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, -2, 0.0F, 0.15625F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, 2, 0.15625F, 0.15625F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, 2, 0.15625F, 0.3125F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, -2, 0.0F, 0.3125F, -1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, -2, 0.0F, 0.15625F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, 2, 2, 0.15625F, 0.15625F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, 2, 0.15625F, 0.3125F, 1, 0, 0, i);
    this.method_23153(matrix4f, matrix3f, vertexConsumer, -7, -2, -2, 0.0F, 0.3125F, 1, 0, 0, i);
    for (int u = 0; u < 4; ++u) {
        matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
        this.method_23153(matrix4f, matrix3f, vertexConsumer, -8, -2, 0, 0.0F, 0.0F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, 8, -2, 0, 0.5F, 0.0F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, 8, 2, 0, 0.5F, 0.15625F, 0, 1, 0, i);
        this.method_23153(matrix4f, matrix3f, vertexConsumer, -8, 2, 0, 0.0F, 0.15625F, 0, 1, 0, i);
    }
    matrixStack.pop();
    super.render(persistentProjectileEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Example 4 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project MCDoom by AzureDoom.

the class BFGCellRender method renderCrystalBeam.

public static void renderCrystalBeam(float dx, float dy, float dz, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
    float f = MathHelper.sqrt(dx * dx + dz * dz);
    float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
    matrices.push();
    matrices.translate(0.0D, 1.0D, 0.0D);
    matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion((float) (-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
    matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion((float) (-Math.atan2((double) f, (double) dy)) - 1.5707964F));
    VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
    float h = 0.0F - ((float) age + tickDelta) * 0.01F;
    float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float) age + tickDelta) * 0.01F;
    float k = 0.0F;
    float l = 0.75F;
    float m = 0.0F;
    MatrixStack.Entry entry = matrices.peek();
    Matrix4f matrix4f = entry.getPositionMatrix();
    Matrix3f matrix3f = entry.getNormalMatrix();
    for (int n = 1; n <= 8; ++n) {
        float o = MathHelper.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
        float p = MathHelper.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
        float q = (float) n / 8.0F;
        vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
        vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
        vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
        vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
        k = o;
        l = p;
        m = q;
    }
    matrices.pop();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Example 5 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class StorageESP method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    if (getSetting(0).asMode().getMode() == 0) {
        // Manually render blockentities because of culling
        for (BlockEntity be : WorldUtils.getBlockEntities()) {
            int[] color = getColorForBlock(be);
            if (color != null) {
                BlockEntityRenderer<BlockEntity> renderer = mc.getBlockEntityRenderDispatcher().get(be);
                MatrixStack matrices = Renderer.matrixFrom(be.getPos().getX(), be.getPos().getY(), be.getPos().getZ());
                if (renderer != null) {
                    renderer.render(be, mc.getTickDelta(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()), LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV);
                } else {
                    BlockState state = be.getCachedState();
                    mc.getBlockRenderManager().getModelRenderer().renderFlat(mc.world, mc.getBlockRenderManager().getModel(state), state, be.getPos(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()).getBuffer(RenderLayers.getMovingBlockLayer(state)), false, new Random(), 0L, OverlayTexture.DEFAULT_UV);
                }
            }
        }
        colorVertexer.draw();
        shader.render();
        shader.drawFramebufferToMain("main");
    } else {
        float width = getSetting(2).asSlider().getValueFloat();
        int fill = getSetting(3).asSlider().getValueInt();
        for (Entity e : mc.world.getEntities()) {
            int[] color = getColorForEntity(e);
            Box box = e.getBoundingBox();
            if (e instanceof ItemFrameEntity && ((ItemFrameEntity) e).getHeldItemStack().getItem() == Items.FILLED_MAP) {
                Axis axis = e.getHorizontalFacing().getAxis();
                box = box.expand(axis == Axis.X ? 0 : 0.125, axis == Axis.Y ? 0 : 0.125, axis == Axis.Z ? 0 : 0.125);
            }
            if (color != null) {
                if (width != 0)
                    Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
                if (fill != 0)
                    Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
            }
        }
        Set<BlockPos> skip = new HashSet<>();
        for (BlockEntity be : WorldUtils.getBlockEntities()) {
            if (skip.contains(be.getPos()))
                continue;
            int[] color = getColorForBlock(be);
            Box box = be.getCachedState().getOutlineShape(mc.world, be.getPos()).getBoundingBox().offset(be.getPos());
            Direction dir = getChestDirection(be);
            if (dir != null) {
                box = Boxes.stretch(box, dir, 0.94);
                skip.add(be.getPos().offset(dir));
            }
            if (color != null) {
                if (width != 0)
                    Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
                if (fill != 0)
                    Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
            }
        }
    }
}
Also used : ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) FurnaceMinecartEntity(net.minecraft.entity.vehicle.FurnaceMinecartEntity) Entity(net.minecraft.entity.Entity) HopperMinecartEntity(net.minecraft.entity.vehicle.HopperMinecartEntity) ChestMinecartEntity(net.minecraft.entity.vehicle.ChestMinecartEntity) MatrixStack(net.minecraft.client.util.math.MatrixStack) Box(net.minecraft.util.math.Box) Direction(net.minecraft.util.math.Direction) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) BlockPos(net.minecraft.util.math.BlockPos) Axis(net.minecraft.util.math.Direction.Axis) HashSet(java.util.HashSet) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

MatrixStack (net.minecraft.client.util.math.MatrixStack)83 BufferBuilder (net.minecraft.client.render.BufferBuilder)14 GameRenderer (net.minecraft.client.render.GameRenderer)12 Tessellator (net.minecraft.client.render.Tessellator)12 Camera (net.minecraft.client.render.Camera)11 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)10 MinecraftClient (net.minecraft.client.MinecraftClient)8 BlockPos (net.minecraft.util.math.BlockPos)8 ItemStack (net.minecraft.item.ItemStack)7 Vec3d (net.minecraft.util.math.Vec3d)7 Color (java.awt.Color)6 Random (java.util.Random)6 BlockState (net.minecraft.block.BlockState)6 Identifier (net.minecraft.util.Identifier)6 Matrix4f (net.minecraft.util.math.Matrix4f)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 LiteralText (net.minecraft.text.LiteralText)5 Box (net.minecraft.util.math.Box)5 Inject (org.spongepowered.asm.mixin.injection.Inject)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4