Search in sources :

Example 81 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Hypnotic-Client by Hypnotic-Development.

the class GameRendererMixin method onRenderWorld.

@Inject(method = "renderWorld", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = { "ldc=hand" }), locals = LocalCapture.CAPTURE_FAILSOFT)
private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
    MinecraftClient mc = MinecraftClient.getInstance();
    if (mc == null || mc.world == null || mc.player == null)
        return;
    mc.getProfiler().push("hypnotic-client_render");
    EventRender3D event = new EventRender3D(matrices, tickDelta, mc.getCameraEntity().getPos().x, mc.getCameraEntity().getPos().y, mc.getCameraEntity().getPos().z);
    event.call();
    RenderSystem.applyModelViewMatrix();
    mc.getProfiler().pop();
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) EventRender3D(dev.hypnotic.event.events.EventRender3D) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 82 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Hypnotic-Client by Hypnotic-Development.

the class WorldUtils method getSideBlock.

public static BlockPos getSideBlock(double length, boolean direction) {
    MinecraftClient mc = MinecraftClient.getInstance();
    final double yaw = Math.toRadians(mc.player.getYaw() + (direction ? 45 : 90));
    BlockPos fPos = new BlockPos(mc.player.getX() + (-Math.sin(yaw) * length), mc.player.getY(), mc.player.getZ() + (Math.cos(yaw) * length));
    return fPos;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) BlockPos(net.minecraft.util.math.BlockPos)

Example 83 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project wtf by HerraVp.

the class MixinInGameHud method render.

@Inject(at = @At(value = "RETURN"), method = "render", cancellable = true)
public void render(MatrixStack matrices, float float_1, CallbackInfo info) {
    MinecraftClient mc = MinecraftClient.getInstance();
    if (mc.player == null || mc.world == null)
        return;
    if (mc.options.debugEnabled)
        return;
    // Durability
    if (!mc.player.getMainHandStack().isEmpty() && mc.player.getMainHandStack().isDamageable()) {
        int durability = (mc.player.getMainHandStack().getMaxDamage() - mc.player.getMainHandStack().getDamage());
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "Durability: " + Formatting.RESET + durability, 1, 150, 0xFFFFFF);
    }
    // FPS
    int fps = Integer.parseInt(Integer.toString(AccessorMinecraftClient.getFps()));
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "FPS: " + Formatting.RESET + fps, 1, 1, 0xFFFFFF);
    // TPS
    String tps = String.valueOf(getAverageTPS());
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "TPS: " + Formatting.RESET + tps, 1, 1 + mc.textRenderer.fontHeight + 1, 0xFFFFFF);
    // Ping
    PlayerListEntry playerEntry = mc.player.networkHandler.getPlayerListEntry(mc.player.getGameProfile().getId());
    int ping = playerEntry == null ? 0 : playerEntry.getLatency();
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "Ping: " + Formatting.RESET + ping + "ms", 1, 10 + mc.textRenderer.fontHeight + 1, 0xFFFFFF);
    // Players
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "Players Nearby: ", 1, 180 + mc.textRenderer.fontHeight + 1, 0xFFFFFF);
    int count = 1;
    for (Entity e : mc.world.getPlayers().stream().limit(10).filter(e -> e != mc.player).sorted(Comparator.comparing(mc.player::distanceTo)).toList()) {
        int dist = Math.round(mc.player.distanceTo(e));
        String text = e.getDisplayName().getString() + " \u00a77|\u00a7r " + e.getBlockPos().getX() + " " + e.getBlockPos().getY() + " " + e.getBlockPos().getZ() + " (" + dist + "m)";
        int playerColor = 0xff000000 | ((255 - (int) Math.min(dist * 2.1, 255) & 0xFF) << 16) | (((int) Math.min(dist * 4.28, 255) & 0xFF) << 8);
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + text, 1, 190 + count * 10, playerColor);
        count++;
    }
    /* // Biome
        String biome = mc.world.getBiome(mc.player.getBlockPos()).getKey().toString().toUpperCase();

        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer,
                Formatting.GREEN + "Biome: " + Formatting.RESET + biome, 1,
                30,
                0xFFFFFF);
        */
    // BPS
    DecimalFormat bpsFormat = new DecimalFormat("0.0");
    final double deltaX = Math.abs(mc.player.getPos().getX() - mc.player.prevX);
    final double deltaZ = Math.abs(mc.player.getPos().getZ() - mc.player.prevZ);
    String bps = bpsFormat.format((deltaX + deltaZ) * 20);
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + "BPS: " + Formatting.RESET + bps, 1, 485, 0xFFFFFF);
    // Coordinates
    final DecimalFormat decimalFormat = new DecimalFormat("###.#");
    double x = mc.player.getX();
    double y = mc.player.getY();
    double z = mc.player.getZ();
    if (mc.world.getDimension().isRespawnAnchorWorking()) {
        x *= 8;
        z *= 8;
    }
    final String overWorld = Formatting.GREEN + "XYZ: " + decimalFormat.format(x) + " " + decimalFormat.format(y) + " " + decimalFormat.format(z);
    final String nether = decimalFormat.format(x / 8) + " " + decimalFormat.format(y) + " " + decimalFormat.format(z / 8);
    DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, overWorld + Formatting.RESET + " | " + Formatting.RED + nether, 1, mc.getWindow().getScaledHeight() - 10, 0xFFFFFF);
    // DrawableHelper.fill(matrices, mc.textRenderer.getWidth(overWorld + Formatting.RESET + " | " + Formatting.RED + nether), mc.textRenderer.fontHeight + 10, mc.textRenderer.getWidth(overWorld + Formatting.RESET + " | " + Formatting.RED + nether), mc.textRenderer.fontHeight + 10, 0x70003030);
    // Movement info
    String movementInfo = "";
    if (mc.player.isSprinting() || mc.options.sprintKey.isPressed() && mc.player.isOnGround()) {
        movementInfo = "You are currently sprinting";
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + movementInfo, mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(movementInfo), mc.getWindow().getScaledHeight() - 10, 0xFFFFFF);
    } else if (mc.player.getAbilities().flying || mc.player.isFallFlying()) {
        movementInfo = "You are currently flying";
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + movementInfo, mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(movementInfo), mc.getWindow().getScaledHeight() - 10, 0xFFFFFF);
    } else if (mc.player.isSneaking() || mc.player.isInSneakingPose() && mc.player.isOnGround()) {
        movementInfo = "You are currently sneaking";
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + movementInfo, mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(movementInfo), mc.getWindow().getScaledHeight() - 10, 0xFFFFFF);
    } else {
        movementInfo = "";
        DrawableHelper.drawStringWithShadow(matrices, mc.textRenderer, Formatting.GREEN + movementInfo, mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(movementInfo), mc.getWindow().getScaledHeight() - 10, 0xFFFFFF);
    }
    // Player Model
    if (!(mc.player == null)) {
        float yaw = MathHelper.wrapDegrees(mc.player.prevYaw + (mc.player.getYaw() - mc.player.prevYaw) * mc.getTickDelta());
        float pitch = mc.player.getPitch();
        matrices.push();
        InventoryScreen.drawEntity(mc.getWindow().getScaledWidth() - 20, 50, 25, -yaw, -pitch, mc.player);
        RenderSystem.enableDepthTest();
        matrices.pop();
    }
}
Also used : Entity(net.minecraft.entity.Entity) AccessorMinecraftClient(me.vp.wtf.mixins.accessor.AccessorMinecraftClient) MinecraftClient(net.minecraft.client.MinecraftClient) DecimalFormat(java.text.DecimalFormat) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 84 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Merlin-GUI by Bubblie01.

the class MerlinWindow method windowInit.

public static void windowInit(Window window) {
    MinecraftClient client = MinecraftClient.getInstance();
    int width = window.getWidth();
    int height = window.getHeight();
    minecraftContext = window.getHandle();
    renderer = new NvgRenderer();
    renderer.initialize();
    frame = new Frame(width, height);
    callbackKeeper = new DefaultCallbackKeeper();
    Widget widget = new Widget("Regular Window", 200, 50, 200, 200);
    frame.getContainer().add(widget);
    context = new Context(minecraftContext);
    systemEventProcessor = new SystemEventProcessorImpl();
}
Also used : Context(com.spinyowl.legui.system.context.Context) Frame(com.spinyowl.legui.component.Frame) MinecraftClient(net.minecraft.client.MinecraftClient) DefaultCallbackKeeper(com.spinyowl.legui.system.context.DefaultCallbackKeeper) SystemEventProcessorImpl(com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl) Widget(com.spinyowl.legui.component.Widget) NvgRenderer(com.spinyowl.legui.system.renderer.nvg.NvgRenderer)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3