Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. package net.minecraft.client.entity;
  2.  
  3. import com.mojang.authlib.GameProfile;
  4. import java.io.File;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.client.network.NetworkPlayerInfo;
  7. import net.minecraft.client.renderer.ImageBufferDownload;
  8. import net.minecraft.client.renderer.ThreadDownloadImageData;
  9. import net.minecraft.client.renderer.texture.ITextureObject;
  10. import net.minecraft.client.renderer.texture.TextureManager;
  11. import net.minecraft.client.resources.DefaultPlayerSkin;
  12. import net.minecraft.entity.SharedMonsterAttributes;
  13. import net.minecraft.entity.ai.attributes.IAttributeInstance;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.init.Items;
  16. import net.minecraft.util.ResourceLocation;
  17. import net.minecraft.util.StringUtils;
  18. import net.minecraft.world.World;
  19. import net.minecraft.world.WorldSettings;
  20. import optifine.CapeUtils;
  21. import optifine.Config;
  22. import optifine.PlayerConfigurations;
  23. import optifine.Reflector;
  24.  
  25. public abstract class AbstractClientPlayer extends EntityPlayer
  26. {
  27. private NetworkPlayerInfo playerInfo;
  28. private ResourceLocation locationOfCape = null;
  29. private String nameClear = null;
  30. private static final String __OBFID = "CL_00000935";
  31.  
  32. public AbstractClientPlayer(World worldIn, GameProfile playerProfile)
  33. {
  34. super(worldIn, playerProfile);
  35. this.nameClear = playerProfile.getName();
  36.  
  37. if (this.nameClear != null && !this.nameClear.isEmpty())
  38. {
  39. this.nameClear = StringUtils.stripControlCodes(this.nameClear);
  40. }
  41.  
  42. CapeUtils.downloadCape(this);
  43. PlayerConfigurations.getPlayerConfiguration(this);
  44. }
  45.  
  46. /**
  47. * Returns true if the player is in spectator mode.
  48. */
  49. public boolean isSpectator()
  50. {
  51. NetworkPlayerInfo networkplayerinfo = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.getGameProfile().getId());
  52. return networkplayerinfo != null && networkplayerinfo.getGameType() == WorldSettings.GameType.SPECTATOR;
  53. }
  54.  
  55. /**
  56. * Checks if this instance of AbstractClientPlayer has any associated player data.
  57. */
  58. public boolean hasPlayerInfo()
  59. {
  60. return this.getPlayerInfo() != null;
  61. }
  62.  
  63. protected NetworkPlayerInfo getPlayerInfo()
  64. {
  65. if (this.playerInfo == null)
  66. {
  67. this.playerInfo = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.getUniqueID());
  68. }
  69.  
  70. return this.playerInfo;
  71. }
  72.  
  73. /**
  74. * Returns true if the player has an associated skin.
  75. */
  76. public boolean hasSkin()
  77. {
  78. NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
  79. return networkplayerinfo != null && networkplayerinfo.hasLocationSkin();
  80. }
  81.  
  82. /**
  83. * Returns true if the player instance has an associated skin.
  84. */
  85. public ResourceLocation getLocationSkin()
  86. {
  87. NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
  88. return networkplayerinfo == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : networkplayerinfo.getLocationSkin();
  89. }
  90.  
  91. public ResourceLocation getLocationCape()
  92. {
  93. if (!Config.isShowCapes())
  94. {
  95. return null;
  96. }
  97. else if (this.locationOfCape != null)
  98. {
  99. return this.locationOfCape;
  100. }
  101. else
  102. {
  103. NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
  104. return networkplayerinfo == null ? null : networkplayerinfo.getLocationCape();
  105. }
  106. }
  107.  
  108. public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username)
  109. {
  110. TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
  111. Object object = texturemanager.getTexture(resourceLocationIn);
  112.  
  113. if (object == null)
  114. {
  115. object = new ThreadDownloadImageData((File)null, String.format("http://skins.minecraft.net/MinecraftSkins/%s.png", new Object[] {StringUtils.stripControlCodes(username)}), DefaultPlayerSkin.getDefaultSkin(getOfflineUUID(username)), new ImageBufferDownload());
  116. texturemanager.loadTexture(resourceLocationIn, (ITextureObject)object);
  117. }
  118.  
  119. return (ThreadDownloadImageData)object;
  120. }
  121.  
  122. /**
  123. * Returns true if the username has an associated skin.
  124. */
  125. public static ResourceLocation getLocationSkin(String username)
  126. {
  127. return new ResourceLocation("skins/" + StringUtils.stripControlCodes(username));
  128. }
  129.  
  130. public String getSkinType()
  131. {
  132. NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
  133. return networkplayerinfo == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : networkplayerinfo.getSkinType();
  134. }
  135.  
  136. public float getFovModifier()
  137. {
  138. float f = 1.0F;
  139.  
  140. if (this.capabilities.isFlying)
  141. {
  142. f *= 1.1F;
  143. }
  144.  
  145. IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
  146. f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));
  147.  
  148. if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
  149. {
  150. f = 1.0F;
  151. }
  152.  
  153. if (this.isUsingItem() && this.getItemInUse().getItem() == Items.bow)
  154. {
  155. int i = this.getItemInUseDuration();
  156. float f1 = (float)i / 20.0F;
  157.  
  158. if (f1 > 1.0F)
  159. {
  160. f1 = 1.0F;
  161. }
  162. else
  163. {
  164. f1 = f1 * f1;
  165. }
  166.  
  167. f *= 1.0F - f1 * 0.15F;
  168. }
  169.  
  170. return Reflector.ForgeHooksClient_getOffsetFOV.exists() ? Reflector.callFloat(Reflector.ForgeHooksClient_getOffsetFOV, new Object[] {this, Float.valueOf(f)}): f;
  171. }
  172.  
  173. public String getNameClear()
  174. {
  175. return this.nameClear;
  176. }
  177.  
  178. public ResourceLocation getLocationOfCape()
  179. {
  180. return this.locationOfCape;
  181. }
  182.  
  183. public void setLocationOfCape(ResourceLocation p_setLocationOfCape_1_)
  184. {
  185. this.locationOfCape = p_setLocationOfCape_1_;
  186. }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement