Search in sources :

Example 16 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project Client by MatHax.

the class LogoutSpots method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.getNetworkHandler().getPlayerList().size() != lastPlayerList.size()) {
        for (PlayerListEntry entry : lastPlayerList) {
            if (mc.getNetworkHandler().getPlayerList().stream().anyMatch(playerListEntry -> playerListEntry.getProfile().equals(entry.getProfile())))
                continue;
            for (PlayerEntity player : lastPlayers) {
                if (player.getUuid().equals(entry.getProfile().getId())) {
                    add(new Entry(player));
                }
            }
        }
        lastPlayerList.clear();
        lastPlayerList.addAll(mc.getNetworkHandler().getPlayerList());
        updateLastPlayers();
    }
    if (timer <= 0) {
        updateLastPlayers();
        timer = 10;
    } else {
        timer--;
    }
    Dimension dimension = PlayerUtils.getDimension();
    if (dimension != lastDimension)
        players.clear();
    lastDimension = dimension;
}
Also used : PlayerListEntry(net.minecraft.client.network.PlayerListEntry) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) Dimension(mathax.client.utils.world.Dimension) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventHandler(mathax.client.eventbus.EventHandler)

Example 17 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project Client by MatHax.

the class FakeClientPlayer method getPlayerListEntry.

public static PlayerListEntry getPlayerListEntry() {
    if (playerListEntry == null || needsNewEntry) {
        playerListEntry = new PlayerListEntry(PlayerListEntryFactory.create(mc.getSession().getProfile(), 0, GameMode.SURVIVAL, new LiteralText(mc.getSession().getProfile().getName())));
        needsNewEntry = false;
    }
    return playerListEntry;
}
Also used : PlayerListEntry(net.minecraft.client.network.PlayerListEntry) LiteralText(net.minecraft.text.LiteralText)

Example 18 with PlayerListEntry

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

the class Nametags method drawNametags.

public void drawNametags(Entity playerEntity, EventRenderGUI eventRender2D) {
    Vec3d vec = positions.get(playerEntity);
    if (RenderUtils.isOnScreen2d(vec)) {
        float x = (float) vec.x;
        float y = (float) vec.y - (playerEntity instanceof PlayerEntity ? 18 : 0);
        String nameString = getNameString(playerEntity);
        float length = font.getStringWidth(nameString) + 0;
        eventRender2D.getMatrices().push();
        eventRender2D.getMatrices().translate(x, y, 0);
        float scaleDist = mc.player.distanceTo(playerEntity) < 60 ? 60 : (mc.player.distanceTo(playerEntity) > 100 ? 100 : mc.player.distanceTo(playerEntity));
        float scaleFactor = ((scaleDist) * 0.05f) * (float) scale.getValue() * 0.2f;
        eventRender2D.getMatrices().scale(scaleFactor, scaleFactor, 0);
        if (playerEntity instanceof LivingEntity && healthbar.isEnabled()) {
            float percent = ((LivingEntity) playerEntity).getHealth() / ((LivingEntity) playerEntity).getMaxHealth();
            float barLength = (int) (((length) + 6) * percent);
            RenderUtils.fill(eventRender2D.getMatrices(), -(length / 2) - (playerEntity instanceof PlayerEntity ? (head.isEnabled() ? 18 : 2) : 2), -1, 0 + barLength - length / 2, 0, getHealthColor(((LivingEntity) playerEntity)));
        }
        if (bg.isEnabled())
            RenderUtils.fill(eventRender2D.getMatrices(), -(length / 2) - 2 - (head.isEnabled() ? (playerEntity instanceof PlayerEntity ? 16 : 0) : 0), -17, (length / 2) + 6, -1, new Color(0, 0, 0, 175).getRGB());
        if (!font.mcFont)
            font.drawCenteredString(eventRender2D.getMatrices(), nameString, 2, -18, -1, true);
        else
            font.drawCenteredString(eventRender2D.getMatrices(), nameString, 2, -15, -1, true);
        if (playerEntity instanceof PlayerEntity) {
            PlayerListEntry playerListEntry = mc.getNetworkHandler().getPlayerListEntry(playerEntity.getUuid());
            if (playerListEntry != null && head.isEnabled()) {
                RenderUtils.drawFace(eventRender2D.getMatrices(), -length / 2 - 18, -17, (int) 2, playerListEntry.getSkinTexture());
            }
        }
        eventRender2D.getMatrices().pop();
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Color(java.awt.Color) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 19 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry 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 20 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project Wurst7 by Wurst-Imperium.

the class AltRenderer method bindSkinTexture.

private static void bindSkinTexture(String name) {
    if (name.isEmpty())
        name = "Steve";
    if (loadedSkins.get(name) == null) {
        UUID uuid = PlayerEntity.getUuidFromProfile(new GameProfile((UUID) null, name));
        PlayerListEntry entry = new PlayerListEntry(new PlayerListS2CPacket.Entry(new GameProfile(uuid, name), 0, GameMode.CREATIVE, new LiteralText(name)));
        loadedSkins.put(name, entry.getSkinTexture());
    }
    RenderSystem.setShaderTexture(0, loadedSkins.get(name));
}
Also used : PlayerListS2CPacket(net.minecraft.network.packet.s2c.play.PlayerListS2CPacket) GameProfile(com.mojang.authlib.GameProfile) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) UUID(java.util.UUID) LiteralText(net.minecraft.text.LiteralText)

Aggregations

PlayerListEntry (net.minecraft.client.network.PlayerListEntry)23 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 LiteralText (net.minecraft.text.LiteralText)5 MinecraftClient (net.minecraft.client.MinecraftClient)4 GameProfile (com.mojang.authlib.GameProfile)3 Entity (net.minecraft.entity.Entity)3 Vec3d (net.minecraft.util.math.Vec3d)3 IEPlayerListEntry (com.qouteall.immersive_portals.ducks.IEPlayerListEntry)2 IEWorldRenderer (com.qouteall.immersive_portals.ducks.IEWorldRenderer)2 List (java.util.List)2 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)2 LivingEntity (net.minecraft.entity.LivingEntity)2 NbtCompound (net.minecraft.nbt.NbtCompound)2 Identifier (net.minecraft.util.Identifier)2 GameMode (net.minecraft.world.GameMode)2 IEChunkRenderList (com.qouteall.immersive_portals.ducks.IEChunkRenderList)1 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 Gender (com.wildfire.main.GenderPlayer.Gender)1 WildfireGender (com.wildfire.main.WildfireGender)1 fzmm.zailer.me.utils (fzmm.zailer.me.utils)1