diff --git a/src/main/java/net/silentclient/client/mixin/mixins/NetHandlerPlayClientMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/NetHandlerPlayClientMixin.java index 45f5d69..528a329 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/NetHandlerPlayClientMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/NetHandlerPlayClientMixin.java @@ -9,6 +9,7 @@ import net.minecraft.network.play.server.S48PacketResourcePackSend; import net.minecraft.util.IChatComponent; import net.silentclient.client.event.impl.EntityDamageEvent; import net.silentclient.client.hooks.NetHandlerPlayClientHook; +import net.silentclient.client.utils.Players; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; @@ -31,6 +32,7 @@ public class NetHandlerPlayClientMixin { at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V") ) private GuiScreen skipTerrainScreen(GuiScreen original) { + Players.reload(); return null; } diff --git a/src/main/java/net/silentclient/client/utils/Players.java b/src/main/java/net/silentclient/client/utils/Players.java index d3d0029..b53dc83 100644 --- a/src/main/java/net/silentclient/client/utils/Players.java +++ b/src/main/java/net/silentclient/client/utils/Players.java @@ -19,7 +19,7 @@ public class Players { public static final Map playersCache = new WeakHashMap<>(); public static void reload() { -// playersCache.clear(); + playersCache.clear(); } public static String getPlayerStatus(boolean isMainPlayer, String name, UUID id, AbstractClientPlayer playerRow) { @@ -117,10 +117,28 @@ public class Players { Players.getPlayerStatus(false, ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getNameClear(), EntityPlayer.getUUID(Minecraft.getMinecraft().thePlayer.getGameProfile()), Minecraft.getMinecraft().thePlayer); } } - if(playersCache.containsKey(account.getUsername())) { - playersCache.remove(account.getUsername()); + if(Minecraft.getMinecraft().theWorld != null && getPlayerEntityByName(account.original_username) != null) { + Client.logger.info("Account processing: " + account.getUsername()); + if(playersCache.containsKey(account.getUsername())) { + playersCache.remove(account.getUsername()); + } + playersCache.put(account.getUsername(), account); } - playersCache.put(account.getUsername(), account); + } + + public static EntityPlayer getPlayerEntityByName(String name) + { + for (int i = 0; i < Minecraft.getMinecraft().theWorld.playerEntities.size(); ++i) + { + EntityPlayer entityplayer = (EntityPlayer)Minecraft.getMinecraft().theWorld.playerEntities.get(i); + + if (name.equalsIgnoreCase(entityplayer.getName())) + { + return entityplayer; + } + } + + return null; } public static PlayerResponse getAccount(String name) {