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;
}
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;
}
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();
}
}
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();
}
}
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));
}
Aggregations