Search in sources :

Example 21 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project KiwiClient by TangyKiwi.

the class RenderUtils method matrixFrom.

public static MatrixStack matrixFrom(double x, double y, double z) {
    MatrixStack matrices = new MatrixStack();
    Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
    matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
    matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
    return matrices;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack)

Example 22 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project KiwiClient by TangyKiwi.

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 : MatrixStack(net.minecraft.client.util.math.MatrixStack)

Example 23 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project KiwiClient by TangyKiwi.

the class KiwiClient method onInitialize.

@Override
public void onInitialize() {
    mc = MinecraftClient.getInstance();
    Utils.mc = mc;
    CustomMatrix.begin(new MatrixStack());
    moduleManager = new ModuleManager();
    moduleManager.init();
    commandManager = new CommandManager();
    commandManager.init();
    discordRPC = new DiscordRP();
    discordRPC.start();
    EChestMemory eChestMemory = new EChestMemory();
    TickRate tickRate = new TickRate();
    eventBus.register(eChestMemory);
    eventBus.register(tickRate);
    eventBus.register(moduleManager);
    ClickGui.clickGui.initWindows();
    FabricLoader.getInstance().getModContainer("kiwiclient").ifPresent(modContainer -> {
        ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("kiwiclient:kiwitweaks"), "resourcepacks/kiwitweaks", modContainer, true);
    });
    UseItemCallback.EVENT.register((player, world, hand) -> {
        MinecraftClient mc = MinecraftClient.getInstance();
        ClientPlayerInteractionManager interactionManager = mc.interactionManager;
        if (mc.mouse.wasRightButtonClicked() && moduleManager.getModule(ArmorSwap.class).isEnabled()) {
            ItemStack stack = player.getMainHandStack();
            int currentItemIndex = player.getInventory().main.indexOf(stack);
            EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
            int armorIndexSlot = determineIndex(equipmentSlot);
            if (hand == Hand.MAIN_HAND && armorIndexSlot != -1) {
                SoundEvent sound = determineSound(stack.getItem());
                player.playSound(sound, 1.0F, 1.0F);
                interactionManager.clickSlot(player.playerScreenHandler.syncId, armorIndexSlot, currentItemIndex, SlotActionType.SWAP, player);
                return TypedActionResult.success(stack);
            }
        }
        return TypedActionResult.pass(ItemStack.EMPTY);
    });
    KeyBindingHelper.registerKeyBinding(zoomKey);
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) MatrixStack(net.minecraft.client.util.math.MatrixStack) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ModuleManager(com.tangykiwi.kiwiclient.modules.ModuleManager) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) SoundEvent(net.minecraft.sound.SoundEvent) CommandManager(com.tangykiwi.kiwiclient.command.CommandManager) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Example 24 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project isometric-renders by gliscowo.

the class IsometricRenderHelper method renderIntoImage.

public static NativeImage renderIntoImage(int size, RenderCallback renderCallback) {
    Framebuffer framebuffer = new Framebuffer(size, size, true, MinecraftClient.IS_SYSTEM_MAC);
    RenderSystem.pushMatrix();
    RenderSystem.enableBlend();
    RenderSystem.clear(16640, MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.setClearColor(0, 0, 0, 0);
    framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.beginWrite(true);
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    RenderSystem.ortho(-1, 1, 1, -1, -100.0, 100.0);
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    setupLighting();
    VertexConsumerProvider.Immediate vertexConsumers = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    MatrixStack matrixStack = new MatrixStack();
    renderCallback.render(matrixStack, vertexConsumers, ((MinecraftClientAccessor) MinecraftClient.getInstance()).getRenderTickCounter().tickDelta);
    vertexConsumers.draw();
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.popMatrix();
    framebuffer.endWrite();
    return takeKeyedSnapshot(framebuffer, RuntimeConfig.backgroundColor, false, false);
}
Also used : MinecraftClientAccessor(com.glisco.isometricrenders.mixin.MinecraftClientAccessor) Framebuffer(net.minecraft.client.gl.Framebuffer) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 25 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project isometric-renders by gliscowo.

the class IsometricRenderScreen method drawContent.

@Override
protected void drawContent(MatrixStack matrices) {
    float scale = renderScale * height / 515f;
    RenderSystem.pushMatrix();
    RenderSystem.translatef(115, (float) Math.round(renderHeight * 1f + (height - 515f) / 10f), 1500);
    RenderSystem.scalef(1, 1, -1);
    MatrixStack matrixStack = new MatrixStack();
    matrixStack.translate(0, 0, 1000);
    matrixStack.scale(scale, scale, 1);
    Quaternion flip = Vector3f.POSITIVE_Z.getDegreesQuaternion(180);
    flip.hamiltonProduct(Vector3f.POSITIVE_X.getDegreesQuaternion(-angle));
    Quaternion rotation = Vector3f.POSITIVE_Y.getDegreesQuaternion(RuntimeConfig.rotation);
    matrixStack.multiply(flip);
    matrixStack.multiply(rotation);
    EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher();
    entityRenderDispatcher.setRenderShadows(false);
    VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    renderCallback.render(matrixStack, immediate, playAnimations ? ((MinecraftClientAccessor) client).getRenderTickCounter().tickDelta : 0);
    immediate.draw();
    entityRenderDispatcher.setRenderShadows(true);
    RenderSystem.popMatrix();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) MatrixStack(net.minecraft.client.util.math.MatrixStack) EntityRenderDispatcher(net.minecraft.client.render.entity.EntityRenderDispatcher) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Aggregations

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