NetworkPlayerInfo .java

net.minecraft.client.network.NetworkPlayerInfo (class): members: playerTexturesLoaded, loadPlayerTextures, getResponseTime, hasLocationSkin, func_178835_l.

net.minecraft.client.networkclass210 linesclient5.6 KB

API Surface (24)

GameProfile getGameProfile()
WorldSettings.GameType getGameType()
int getResponseTime()
void setGameType(WorldSettings.GameType p_178839_1_)
void setResponseTime(int p_178838_1_)
boolean hasLocationSkin()
String getSkinType()
ResourceLocation getLocationSkin()
ResourceLocation getLocationCape()
ScorePlayerTeam getPlayerTeam()
void loadPlayerTextures()
void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture)
void setDisplayName(IChatComponent displayNameIn)
IChatComponent getDisplayName()
int func_178835_l()
void func_178836_b(int p_178836_1_)
int func_178860_m()
void func_178857_c(int p_178857_1_)
long func_178847_n()
void func_178846_a(long p_178846_1_)
long func_178858_o()
void func_178844_b(long p_178844_1_)
long func_178855_p()
void func_178843_c(long p_178843_1_)

Fields & Constants (13)

gameProfile
gameType
responseTime
playerTexturesLoaded
locationSkin
locationCape
skinType
displayName
field_178873_i
field_178870_j
field_178871_k
field_178868_l
field_178869_m

String literals (2)

"model"
"default"

Full Source

NetworkPlayerInfo.java210 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.network;
2
3
import com.google.common.base.Objects;
4
import com.mojang.authlib.GameProfile;
5
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
6
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
7
import net.minecraft.client.Minecraft;
8
import net.minecraft.client.resources.DefaultPlayerSkin;
9
import net.minecraft.client.resources.SkinManager;
10
import net.minecraft.network.play.server.S38PacketPlayerListItem;
11
import net.minecraft.scoreboard.ScorePlayerTeam;
12
import net.minecraft.util.IChatComponent;
13
import net.minecraft.util.ResourceLocation;
14
import net.minecraft.world.WorldSettings;
15
16
public class NetworkPlayerInfo
17
{
18
    /**
19
     * The GameProfile for the player represented by this NetworkPlayerInfo instance
20
     */
21
    private final GameProfile gameProfile;
22
    private WorldSettings.GameType gameType;
23
24
    /** Player response time to server in milliseconds */
25
    private int responseTime;
26
    private boolean playerTexturesLoaded = false;
27
    private ResourceLocation locationSkin;
28
    private ResourceLocation locationCape;
29
    private String skinType;
30
31
    /**
32
     * When this is non-null, it is displayed instead of the player's real name
33
     */
34
    private IChatComponent displayName;
35
    private int field_178873_i = 0;
36
    private int field_178870_j = 0;
37
    private long field_178871_k = 0L;
38
    private long field_178868_l = 0L;
39
    private long field_178869_m = 0L;
40
41
    public NetworkPlayerInfo(GameProfile p_i46294_1_)
42
    {
43
        this.gameProfile = p_i46294_1_;
44
    }
45
46
    public NetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData p_i46295_1_)
47
    {
48
        this.gameProfile = p_i46295_1_.getProfile();
49
        this.gameType = p_i46295_1_.getGameMode();
50
        this.responseTime = p_i46295_1_.getPing();
51
        this.displayName = p_i46295_1_.getDisplayName();
52
    }
53
54
    /**
55
     * Returns the GameProfile for the player represented by this NetworkPlayerInfo instance
56
     */
57
    public GameProfile getGameProfile()
58
    {
59
        return this.gameProfile;
60
    }
61
62
    public WorldSettings.GameType getGameType()
63
    {
64
        return this.gameType;
65
    }
66
67
    public int getResponseTime()
68
    {
69
        return this.responseTime;
70
    }
71
72
    protected void setGameType(WorldSettings.GameType p_178839_1_)
73
    {
74
        this.gameType = p_178839_1_;
75
    }
76
77
    protected void setResponseTime(int p_178838_1_)
78
    {
79
        this.responseTime = p_178838_1_;
80
    }
81
82
    public boolean hasLocationSkin()
83
    {
84
        return this.locationSkin != null;
85
    }
86
87
    public String getSkinType()
88
    {
89
        return this.skinType == null ? DefaultPlayerSkin.getSkinType(this.gameProfile.getId()) : this.skinType;
90
    }
91
92
    public ResourceLocation getLocationSkin()
93
    {
94
        if (this.locationSkin == null)
95
        {
96
            this.loadPlayerTextures();
97
        }
98
99
        return (ResourceLocation)Objects.firstNonNull(this.locationSkin, DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId()));
100
    }
101
102
    public ResourceLocation getLocationCape()
103
    {
104
        if (this.locationCape == null)
105
        {
106
            this.loadPlayerTextures();
107
        }
108
109
        return this.locationCape;
110
    }
111
112
    public ScorePlayerTeam getPlayerTeam()
113
    {
114
        return Minecraft.getMinecraft().theWorld.getScoreboard().getPlayersTeam(this.getGameProfile().getName());
115
    }
116
117
    protected void loadPlayerTextures()
118
    {
119
        synchronized (this)
120
        {
121
            if (!this.playerTexturesLoaded)
122
            {
123
                this.playerTexturesLoaded = true;
124
                Minecraft.getMinecraft().getSkinManager().loadProfileTextures(this.gameProfile, new SkinManager.SkinAvailableCallback()
125
                {
126
                    public void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture)
127
                    {
128
                        switch (p_180521_1_)
129
                        {
130
                            case SKIN:
131
                                NetworkPlayerInfo.this.locationSkin = location;
132
                                NetworkPlayerInfo.this.skinType = profileTexture.getMetadata("model");
133
134
                                if (NetworkPlayerInfo.this.skinType == null)
135
                                {
136
                                    NetworkPlayerInfo.this.skinType = "default";
137
                                }
138
139
                                break;
140
141
                            case CAPE:
142
                                NetworkPlayerInfo.this.locationCape = location;
143
                        }
144
                    }
145
                }, true);
146
            }
147
        }
148
    }
149
150
    public void setDisplayName(IChatComponent displayNameIn)
151
    {
152
        this.displayName = displayNameIn;
153
    }
154
155
    public IChatComponent getDisplayName()
156
    {
157
        return this.displayName;
158
    }
159
160
    public int func_178835_l()
161
    {
162
        return this.field_178873_i;
163
    }
164
165
    public void func_178836_b(int p_178836_1_)
166
    {
167
        this.field_178873_i = p_178836_1_;
168
    }
169
170
    public int func_178860_m()
171
    {
172
        return this.field_178870_j;
173
    }
174
175
    public void func_178857_c(int p_178857_1_)
176
    {
177
        this.field_178870_j = p_178857_1_;
178
    }
179
180
    public long func_178847_n()
181
    {
182
        return this.field_178871_k;
183
    }
184
185
    public void func_178846_a(long p_178846_1_)
186
    {
187
        this.field_178871_k = p_178846_1_;
188
    }
189
190
    public long func_178858_o()
191
    {
192
        return this.field_178868_l;
193
    }
194
195
    public void func_178844_b(long p_178844_1_)
196
    {
197
        this.field_178868_l = p_178844_1_;
198
    }
199
200
    public long func_178855_p()
201
    {
202
        return this.field_178869_m;
203
    }
204
205
    public void func_178843_c(long p_178843_1_)
206
    {
207
        this.field_178869_m = p_178843_1_;
208
    }
209
}
210

Deobfuscated MCP 1.8.9 source of NetworkPlayerInfo from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/network/NetworkPlayerInfo.java), stored verbatim.