Advertisement
CraftLifeGaming

AbstractClientPlayer.java

Oct 25th, 2016
1,521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 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.IImageBuffer;
  8. import net.minecraft.client.renderer.ImageBufferDownload;
  9. import net.minecraft.client.renderer.ThreadDownloadImageData;
  10. import net.minecraft.client.renderer.texture.ITextureObject;
  11. import net.minecraft.client.renderer.texture.TextureManager;
  12. import net.minecraft.client.resources.DefaultPlayerSkin;
  13. import net.minecraft.entity.SharedMonsterAttributes;
  14. import net.minecraft.entity.ai.attributes.IAttributeInstance;
  15. import net.minecraft.entity.player.EntityPlayer;
  16. import net.minecraft.init.Items;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraft.util.StringUtils;
  19. import net.minecraft.world.World;
  20. import net.minecraft.world.WorldSettings;
  21.  
  22. public abstract class AbstractClientPlayer extends EntityPlayer
  23. {
  24. private NetworkPlayerInfo field_175157_a;
  25. private static final String __OBFID = "CL_00000935";
  26.  
  27. public static final ResourceLocation locationStevePng = new ResourceLocation("textures/entity/steve.png");
  28. private ThreadDownloadImageData downloadImageSkin;
  29. private ThreadDownloadImageData downloadImageCape;
  30. private ResourceLocation locationSkin;
  31. private ResourceLocation locationCape;
  32.  
  33. public AbstractClientPlayer(World worldIn, GameProfile p_i45074_2_)
  34. {
  35. super(worldIn, p_i45074_2_);
  36. this.setupCustomSkin();
  37. }
  38.  
  39. protected void setupCustomSkin()
  40. {
  41. System.out.println("Loading ExtremeMinecraftCapes");
  42.  
  43. if (this.getName() != null && !this.getName().isEmpty())
  44. {
  45. this.locationSkin = getLocationSkin(this.getName());
  46. this.locationCape = getLocationCape(this.getName());
  47. this.downloadImageSkin = getDownloadImageSkin(this.locationSkin, this.getName());
  48. this.downloadImageCape = getDownloadImageCape(this.locationCape, this.getName());
  49. }
  50. }
  51.  
  52. public ThreadDownloadImageData getTextureSkin()
  53. {
  54. return this.downloadImageSkin;
  55. }
  56.  
  57. public ThreadDownloadImageData getTextureCape()
  58. {
  59. return this.downloadImageCape;
  60. }
  61.  
  62. public ResourceLocation getLocationSkin()
  63. {
  64. return this.locationSkin;
  65. }
  66.  
  67. public ResourceLocation getLocationCape()
  68. {
  69. return this.locationCape;
  70. }
  71.  
  72. public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation par0ResourceLocation, String par1Str)
  73. {
  74. return getDownloadImage(par0ResourceLocation, getSkinUrl(par1Str), locationStevePng, new ImageBufferDownload());
  75. }
  76.  
  77. public static ThreadDownloadImageData getDownloadImageCape(ResourceLocation par0ResourceLocation, String par1Str)
  78. {
  79. return getDownloadImage(par0ResourceLocation, getCapeUrl(par1Str), (ResourceLocation)null, (IImageBuffer)null);
  80. }
  81.  
  82. private static ThreadDownloadImageData getDownloadImage(ResourceLocation par0ResourceLocation, String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
  83. {
  84. TextureManager var4 = Minecraft.getMinecraft().getTextureManager();
  85. Object var5 = var4.getTexture(par0ResourceLocation);
  86.  
  87. if (var5 == null)
  88. {
  89. var5 = new ThreadDownloadImageData(null, par1Str, par2ResourceLocation, par3IImageBuffer);
  90. var4.loadTexture(par0ResourceLocation, (ITextureObject)var5);
  91. }
  92.  
  93. return (ThreadDownloadImageData)var5;
  94. }
  95.  
  96. public static String getSkinUrl(String username)
  97. {
  98. return String.format("http://skins.minecraft.net/MinecraftSkins/" + username + ".png");
  99. }
  100.  
  101. public static String getCapeUrl(String username)
  102. {
  103. return String.format("http://s.craftlifegaming.com/capes/" + username + ".png");
  104.  
  105. }
  106.  
  107. public static ResourceLocation getLocationSkin(String username)
  108. {
  109. return new ResourceLocation("skins/" + StringUtils.stripControlCodes(username));
  110. }
  111.  
  112. public static ResourceLocation getLocationCape(String username)
  113. {
  114. return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(username));
  115. }
  116.  
  117. public static ResourceLocation getLocationSkull(String par0Str)
  118. {
  119. return new ResourceLocation("skull/" + StringUtils.stripControlCodes(par0Str));
  120. }
  121.  
  122. public boolean func_175149_v()
  123. {
  124. NetworkPlayerInfo var1 = Minecraft.getMinecraft().getNetHandler().func_175102_a(this.getGameProfile().getId());
  125. return var1 != null && var1.getGameType() == WorldSettings.GameType.SPECTATOR;
  126. }
  127.  
  128. public boolean hasCape()
  129. {
  130. return this.func_175155_b() != null;
  131. }
  132.  
  133. protected NetworkPlayerInfo func_175155_b()
  134. {
  135. if (this.field_175157_a == null)
  136. {
  137. this.field_175157_a = Minecraft.getMinecraft().getNetHandler().func_175102_a(this.getUniqueID());
  138. }
  139.  
  140. return this.field_175157_a;
  141. }
  142.  
  143. public boolean hasSkin()
  144. {
  145. NetworkPlayerInfo var1 = this.func_175155_b();
  146. return var1 != null && var1.func_178856_e();
  147. }
  148.  
  149. public ResourceLocation getLocationSkinOG()
  150. {
  151. NetworkPlayerInfo var1 = this.func_175155_b();
  152. return var1 == null ? DefaultPlayerSkin.func_177334_a(this.getUniqueID()) : var1.func_178837_g();
  153. }
  154.  
  155. public ResourceLocation getLocationCapeOG()
  156. {
  157. NetworkPlayerInfo var1 = this.func_175155_b();
  158. return var1 == null ? null : var1.func_178861_h();
  159. }
  160.  
  161. public String func_175154_l()
  162. {
  163. NetworkPlayerInfo var1 = this.func_175155_b();
  164. return var1 == null ? DefaultPlayerSkin.func_177332_b(this.getUniqueID()) : var1.func_178851_f();
  165. }
  166.  
  167. public float func_175156_o()
  168. {
  169. float var1 = 1.0F;
  170.  
  171. if (this.capabilities.isFlying)
  172. {
  173. var1 *= 1.1F;
  174. }
  175.  
  176. IAttributeInstance var2 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
  177. var1 = (float)((double)var1 * ((var2.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));
  178.  
  179. if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(var1) || Float.isInfinite(var1))
  180. {
  181. var1 = 1.0F;
  182. }
  183.  
  184. if (this.isUsingItem() && this.getItemInUse().getItem() == Items.bow)
  185. {
  186. int var3 = this.getItemInUseDuration();
  187. float var4 = (float)var3 / 20.0F;
  188.  
  189. if (var4 > 1.0F)
  190. {
  191. var4 = 1.0F;
  192. }
  193. else
  194. {
  195. var4 *= var4;
  196. }
  197.  
  198. var1 *= 1.0F - var4 * 0.15F;
  199. }
  200.  
  201. return var1;
  202. }
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement