net.minecraft.client.network.NetworkPlayerInfo Java Examples
The following examples show how to use
net.minecraft.client.network.NetworkPlayerInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NameProtect.java From LiquidBounce with GNU General Public License v3.0 | 7 votes |
@EventTarget(ignoreCondition = true) public void onText(final TextEvent event) { if(mc.thePlayer == null || event.getText().contains("§8[§9§l" + LiquidBounce.CLIENT_NAME + "§8] §3")) return; for (final FriendsConfig.Friend friend : LiquidBounce.fileManager.friendsConfig.getFriends()) event.setText(StringUtils.replace(event.getText(), friend.getPlayerName(), ColorUtils.translateAlternateColorCodes(friend.getAlias()) + "§f")); if(!getState()) return; event.setText(StringUtils.replace(event.getText(), mc.thePlayer.getName(), ColorUtils.translateAlternateColorCodes(fakeNameValue.get()) + "§f")); if(allPlayersValue.get()) for(final NetworkPlayerInfo playerInfo : mc.getNetHandler().getPlayerInfoMap()) event.setText(StringUtils.replace(event.getText(), playerInfo.getGameProfile().getName(), "Protected User")); }
Example #2
Source File: LevelheadGui.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
private void drawPing(int x, int y, NetworkPlayerInfo playerInfo) { GlStateManager.color(1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(icons); int i = 0; int j; if (playerInfo.getResponseTime() < 0) { j = 5; } else if (playerInfo.getResponseTime() < 300) { j = 1; } else if (playerInfo.getResponseTime() < 600) { j = 2; } else if (playerInfo.getResponseTime() < 1000) { j = 3; } else { j = 4; } zLevel += 100.0F; drawTexturedModalRect(x - 11, y, i * 10, 176 + j * 8, 10, 8); zLevel -= 100.0F; }
Example #3
Source File: ChatIdentifierService.java From ForgeHax with MIT License | 6 votes |
private static boolean extract( String message, Pattern[] patterns, BiConsumer<GameProfile, String> callback) { for (Pattern pattern : patterns) { Matcher matcher = pattern.matcher(message); if (matcher.find()) { final String messageSender = matcher.group(1); final String messageOnly = matcher.group(2); if (!Strings.isNullOrEmpty(messageSender)) { for (NetworkPlayerInfo data : getLocalPlayer().connection.getPlayerInfoMap()) { if ( String.CASE_INSENSITIVE_ORDER .compare(messageSender, data.getGameProfile().getName()) == 0) { callback.accept(data.getGameProfile(), messageOnly); return true; } } } } } return false; }
Example #4
Source File: AutoLog.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onPacketRecieved(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketSpawnPlayer) { if (disconnectOnNewPlayer.getAsBoolean()) { AutoReconnectMod.hasAutoLogged = true; // dont automatically reconnect UUID id = ((SPacketSpawnPlayer) event.getPacket()).getUniqueId(); NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(id); String name = info != null ? info.getGameProfile().getName() : "(Failed) " + id.toString(); getNetworkManager() .closeChannel(new TextComponentString(name + " entered render distance")); disable(); } } }
Example #5
Source File: NickHider.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@InvokeEvent public void profileCheck(TickEvent event) { if (nickHiderConfig.isMasterEnabled()) { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player == null) return; NetHandlerPlayClient sendQueue = player.sendQueue; if (sendQueue == null) return; sendQueue.getPlayerInfoMap().stream().map(NetworkPlayerInfo::getGameProfile).forEach(gameProfile -> { if (gameProfile.getId() != null && gameProfile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId())) { if (!gameProfile.getName().equalsIgnoreCase(Minecraft.getMinecraft().getSession().getProfile().getName())) { remap(gameProfile.getName(), override == null ? Minecraft.getMinecraft().getSession().getProfile().getName() : override); } } else if (nickHiderConfig.isHideOtherNames()) { remap(gameProfile.getName(), getPseudo(gameProfile.getName())); } }); } }
Example #6
Source File: LevelheadGui.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
public static int getLevelheadWidth(NetworkPlayerInfo playerInfo) { if (!Levelhead.getInstance().getDisplayManager().getMasterConfig().isEnabled()) { return 0; } Levelhead instance = Levelhead.getInstance(); LevelheadDisplay tab = instance.getDisplayManager().getTab(); if (tab != null) { if (!tab.getConfig().isEnabled()) return 0; if (instance.getLevelheadPurchaseStates().isTab()) { String s = tab.getTrueValueCache().get(playerInfo.getGameProfile().getId()); if (s != null) return Minecraft.getMinecraft().fontRendererObj.getStringWidth(s) + 2; } } return 0; }
Example #7
Source File: PingDisplay.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void draw(int starX, double startY, boolean isConfig) { if (Minecraft.getMinecraft().theWorld != null && !Minecraft.getMinecraft().theWorld.isRemote && !isConfig) { return; } EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; if (thePlayer != null) { NetworkPlayerInfo playerInfo = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()); String string = "Ping: " + (playerInfo == null ? "error" : playerInfo.getResponseTime()); ElementRenderer.draw(starX, startY, string); width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(string); } }
Example #8
Source File: ThisModIsDedicatedToUfoCrossing.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onPacketReceived(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketSpawnPlayer) { final SPacketSpawnPlayer packet = event.getPacket(); final UUID id = packet.getUniqueId(); Optional.ofNullable(MC.getConnection().getPlayerInfo(id)) .map(NetworkPlayerInfo::getGameProfile) .map(GameProfile::getName) .ifPresent(name -> { MC.player.sendChatMessage("/w " + name + " " + message.get()); }); } }
Example #9
Source File: AtAllProvider.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@EventTarget public void onPacket(final PacketEvent event) { if(event.getPacket() instanceof C01PacketChatMessage) { final C01PacketChatMessage packetChatMessage = (C01PacketChatMessage) event.getPacket(); final String message = packetChatMessage.getMessage(); if(message.contains("@a")) { synchronized(sendQueue) { for(final NetworkPlayerInfo playerInfo : mc.getNetHandler().getPlayerInfoMap()) { final String playerName = playerInfo.getGameProfile().getName(); if(playerName.equals(mc.thePlayer.getName())) continue; sendQueue.add(message.replace("@a", playerName)); } if(retryValue.get()) { synchronized(retryQueue) { retryQueue.clear(); retryQueue.addAll(Arrays.asList(sendQueue.toArray(new String[0]))); } } } event.cancelEvent(); } } }
Example #10
Source File: MixinRenderGlobal.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "onEntityRemoved", at = @At("HEAD")) private void removeEntity(Entity entityIn, CallbackInfo ci) { if (entityIn instanceof AbstractClientPlayer) { MemoryHelper.INSTANCE.queueDelete(((AbstractClientPlayer) entityIn).getLocationCape()); MemoryHelper.INSTANCE.queueDelete(((AbstractClientPlayer) entityIn).getLocationSkin()); NetworkPlayerInfo info = ((IMixinAbstractClientPlayer) entityIn).callGetPlayerInfo(); if (info == null) return; ((IMixinNetworkPlayerInfo) info).setPlayerTexturesLoaded(false); ((IMixinNetworkPlayerInfo) info).setLocationCape(null); ((IMixinNetworkPlayerInfo) info).setLocationSkin(null); } }
Example #11
Source File: EntityUtils.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
public static int getPing(final EntityPlayer entityPlayer) { if(entityPlayer == null) return 0; final NetworkPlayerInfo networkPlayerInfo = mc.getNetHandler().getPlayerInfo(entityPlayer.getUniqueID()); return networkPlayerInfo == null ? 0 : networkPlayerInfo.getResponseTime(); }
Example #12
Source File: ClientProxy.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void onPlayerRender(RenderPlayerEvent.Pre event) { AbstractClientPlayer clientPlayer = (AbstractClientPlayer) event.getEntityPlayer(); if (capeHoldersUUIDs.contains(clientPlayer.getUniqueID()) && clientPlayer.hasPlayerInfo() && clientPlayer.getLocationCape() == null) { NetworkPlayerInfo playerInfo = ObfuscationReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clientPlayer, 0); Map<Type, ResourceLocation> playerTextures = ObfuscationReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, playerInfo, 1); playerTextures.put(Type.CAPE, GREGTECH_CAPE_TEXTURE); } }
Example #13
Source File: LevelheadGui.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public static void drawPingHook(int i, int x, int y, NetworkPlayerInfo playerInfo) { if (!Levelhead.getInstance().getDisplayManager().getMasterConfig().isEnabled()) { return; } Levelhead instance = Levelhead.getInstance(); LevelheadDisplay tab = instance.getDisplayManager().getTab(); if (tab != null) { if (!tab.getConfig().isEnabled()) return; if (instance.getLevelheadPurchaseStates().isTab()) { String s = tab.getTrueValueCache().get(playerInfo.getGameProfile().getId()); if (s != null) { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; int x1 = i + x - 12 - fontRenderer.getStringWidth(s); Scoreboard board = Minecraft.getMinecraft().theWorld.getScoreboard(); ScoreObjective objective = board.getObjectiveInDisplaySlot(0); if (objective != null) { int score = board.getValueFromObjective(playerInfo.getGameProfile().getName(), objective).getScorePoints(); int extraWidth = fontRenderer.getStringWidth(" " + score); x1 -= extraWidth; } DisplayConfig config = tab.getConfig(); if (config.isFooterChroma()) { fontRenderer.drawString(s, x1, y, instance.getRGBColor()); } else if (config.isFooterRgb()) { fontRenderer.drawString(s, x1, y, new Color(config.getFooterRed(), config.getFooterGreen(), config.getFooterBlue()).getRGB()); } else { fontRenderer.drawString(config.getFooterColor() + s, x1, y, -1); } } } } }
Example #14
Source File: PingComponent.java From seppuku with GNU General Public License v3.0 | 4 votes |
@Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); final Minecraft mc = Minecraft.getMinecraft(); if (mc.world == null || mc.player == null || mc.player.getUniqueID() == null) return; final NetworkPlayerInfo playerInfo = mc.getConnection().getPlayerInfo(mc.player.getUniqueID()); if (playerInfo == null) return; final String ping = "MS: " + playerInfo.getResponseTime(); this.setW(Minecraft.getMinecraft().fontRenderer.getStringWidth(ping)); this.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT); Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(ping, this.getX(), this.getY(), -1); }
Example #15
Source File: LevelheadGui.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
private void doTab(Levelhead instance) { EntityPlayerSP player = mc.thePlayer; NetworkPlayerInfo playerInfo = mc.getNetHandler().getPlayerInfo(player.getUniqueID()); LevelheadDisplay tab = instance.getDisplayManager().getTab(); if (tab != null) { String formattedText = player.getDisplayName().getFormattedText(); int totalTabWidth = 9 + fontRendererObj.getStringWidth(formattedText) + getLevelheadWidth(playerInfo) + 15; int fakeTabTop = height - 200; int centerOn = width / 3; int leftStart = centerOn - totalTabWidth / 2; drawRect(leftStart, fakeTabTop, centerOn + totalTabWidth / 2, fakeTabTop + 8, Integer.MIN_VALUE); drawRect(leftStart, fakeTabTop, centerOn + totalTabWidth / 2, fakeTabTop + 8, 553648127); fontRendererObj.drawString(formattedText, leftStart + 9, fakeTabTop, -1, true); mc.getTextureManager().bindTexture(player.getLocationSkin()); int l2 = 8; int i3 = 8; Gui.drawScaledCustomSizeModalRect(leftStart, fakeTabTop, 8.0F, (float) l2, 8, i3, 8, 8, 64.0F, 64.0F); if (player.isWearing(EnumPlayerModelParts.HAT)) { int j3 = 8; int k3 = 8; Gui.drawScaledCustomSizeModalRect(leftStart, fakeTabTop, 40.0F, (float) j3, 8, k3, 8, 8, 64.0F, 64.0F); } drawPing(leftStart + totalTabWidth, fakeTabTop, playerInfo); drawPingHook(0, leftStart + totalTabWidth, fakeTabTop, playerInfo); LevelheadPurchaseStates purchaseStates = instance.getLevelheadPurchaseStates(); if (!purchaseStates.isTab()) { String text = "Levelhead tab display not purchased!\nPlease purchase to activate and configure."; int i = 1; for (String s : text.split("\n")) { int offset = i * 10; int stringWidth = fontRendererObj.getStringWidth(s); int tmpLeft = width / 3 - stringWidth / 2; fakeTabTop = height - 180; drawRect(tmpLeft, fakeTabTop + offset, tmpLeft + stringWidth, fakeTabTop + offset + 8, Integer.MIN_VALUE); fontRendererObj.drawString(s, tmpLeft, fakeTabTop + offset, Color.YELLOW.getRGB(), true); i++; } reg(new GuiButton(++currentID, centerOn - 60, height - 140, 120, 20, YELLOW + "Purchase Tab Display"), button -> attemptPurchase("tab")); } } }
Example #16
Source File: NetworkInfo.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void printPing(final String name) { NetworkPlayerInfo info = getPlayerInfo(name); GeneralChatHandler.instance().sendMessage(info == null || info.getResponseTime() < 0 ? ChatColor.RED + "No info about " + name : ChatColor.WHITE.toString() + ChatColor.BOLD + info.getGameProfile().getName() + ChatColor.WHITE + ": " + info.getResponseTime() + "ms"); }
Example #17
Source File: WrapperNetworkPlayerInfo.java From ClientBase with MIT License | 4 votes |
public WrapperNetworkPlayerInfo(NetworkPlayerInfo var1) { this.real = var1; }
Example #18
Source File: NetworkInfo.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public int getPing(final String ign) { NetworkPlayerInfo networkInfo = getPlayerInfo(ign); return networkInfo == null ? -1 : networkInfo.getResponseTime(); }
Example #19
Source File: NetworkInfo.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
private NetworkPlayerInfo getPlayerInfo(final String ign) { Collection<NetworkPlayerInfo> map = mc.getNetHandler().getPlayerInfoMap(); return map.stream().filter(playerInfo -> playerInfo.getGameProfile().getName().equalsIgnoreCase(ign)).findFirst().orElse(null); }
Example #20
Source File: MixinGuiPlayerTabOverlay.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * @author boomboompower * @reason Numbered ping in tab */ @Overwrite protected void drawPing(int p_175245_1_, int p_175245_2_, int yIn, NetworkPlayerInfo networkPlayerInfoIn) { hyperiumGuiPlayerTabOverlay.drawPing(p_175245_1_, p_175245_2_, yIn, networkPlayerInfoIn, zLevel, mc); }
Example #21
Source File: EntityUtils.java From LiquidBounce with GNU General Public License v3.0 | 4 votes |
public static String getName(final NetworkPlayerInfo networkPlayerInfoIn) { return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); }
Example #22
Source File: HyperiumGuiPlayerTabOverlay.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void drawPing(int p_175245_1_, int p_175245_2_, int yIn, NetworkPlayerInfo networkPlayerInfoIn, float zLevel, Minecraft mc) { LevelheadGui.drawPingHook(p_175245_1_, p_175245_2_, yIn, networkPlayerInfoIn); final int ping = networkPlayerInfoIn.getResponseTime(); final int x = p_175245_2_ + p_175245_1_ - (mc.fontRendererObj.getStringWidth(ping + "") >> 1) - 2; final int y = yIn + (mc.fontRendererObj.FONT_HEIGHT >> 2); if (Settings.NUMBER_PING) { int colour; if (ping > 500) { colour = 11141120; } else if (ping > 300) { colour = 11184640; } else if (ping > 200) { colour = 11193344; } else if (ping > 135) { colour = 2128640; } else if (ping > 70) { colour = 39168; } else if (ping >= 0) { colour = 47872; } else { colour = 11141120; } if (ping >= 0 && ping < 10000) { GlStateManager.pushMatrix(); GlStateManager.scale(0.5f, 0.5f, 0.5f); mc.fontRendererObj.drawString(" " + ping + "", (2 * x) - 10, (2 * y), colour); GlStateManager.scale(2.0f, 2.0f, 2.0f); GlStateManager.popMatrix(); } return; } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(Gui.icons); int i = 0; int j; if (ping < 0) { j = 5; } else if (ping < 150) { j = 0; } else if (ping < 300) { j = 1; } else if (ping < 600) { j = 2; } else if (ping < 1000) { j = 3; } else { j = 4; } ((IMixinGui) parent).setZLevel(zLevel + 100.0F); parent.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 5, yIn, i * 10, 176 + j * 8, 10, 8); ((IMixinGui) parent).setZLevel(zLevel - 100.0F); }
Example #23
Source File: WrapperNetworkPlayerInfo.java From ClientBase with MIT License | 4 votes |
public NetworkPlayerInfo unwrap() { return this.real; }
Example #24
Source File: IMixinAbstractClientPlayer.java From Hyperium with GNU Lesser General Public License v3.0 | votes |
@Invoker NetworkPlayerInfo callGetPlayerInfo();
Example #25
Source File: IMixinGuiPlayerTabOverlay.java From Hyperium with GNU Lesser General Public License v3.0 | votes |
@Invoker void callDrawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info);
Example #26
Source File: IMixinGuiPlayerTabOverlay.java From Hyperium with GNU Lesser General Public License v3.0 | votes |
@Invoker void callDrawPing(int p_175245_1_, int p_175245_2_, int yIn, NetworkPlayerInfo networkPlayerInfoIn);