Advertisement
Morok

EntityOtherPlayerMP

May 19th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.81 KB | None | 0 0
  1. package net.minecraft.client.entity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.ChunkCoordinates;
  10. import net.minecraft.util.DamageSource;
  11. import net.minecraft.util.MathHelper;
  12. import net.minecraft.util.StringUtils;
  13. import net.minecraft.world.World;
  14.  
  15. @SideOnly(Side.CLIENT)
  16. public class EntityOtherPlayerMP extends EntityPlayer
  17. {
  18. private boolean isItemInUse = false;
  19. private int otherPlayerMPPosRotationIncrements;
  20. private double otherPlayerMPX;
  21. private double otherPlayerMPY;
  22. private double otherPlayerMPZ;
  23. private double otherPlayerMPYaw;
  24. private double otherPlayerMPPitch;
  25.  
  26. public EntityOtherPlayerMP(World par1World, String par2Str)
  27. {
  28. super(par1World);
  29. this.username = par2Str;
  30. this.yOffset = 0.0F;
  31. this.stepHeight = 0.0F;
  32.  
  33. if (par2Str != null && par2Str.length() > 0)
  34. {
  35. this.skinUrl = "http://skins.minecraft.net/MinecraftSkins/" + StringUtils.stripControlCodes(par2Str) + ".png";
  36. }
  37.  
  38. this.noClip = true;
  39. this.field_71082_cx = 0.25F;
  40. this.renderDistanceWeight = 10.0D;
  41. }
  42.  
  43. /**
  44. * sets the players height back to normal after doing things like sleeping and dieing
  45. */
  46. protected void resetHeight()
  47. {
  48. this.yOffset = 0.0F;
  49. }
  50.  
  51. /**
  52. * Called when the entity is attacked.
  53. */
  54. public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
  55. {
  56. return true;
  57. }
  58.  
  59. /**
  60. * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
  61. * posY, posZ, yaw, pitch
  62. */
  63. public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
  64. {
  65. this.otherPlayerMPX = par1;
  66. this.otherPlayerMPY = par3;
  67. this.otherPlayerMPZ = par5;
  68. this.otherPlayerMPYaw = (double)par7;
  69. this.otherPlayerMPPitch = (double)par8;
  70. this.otherPlayerMPPosRotationIncrements = par9;
  71. }
  72.  
  73. public void updateCloak()
  74. {
  75. this.cloakUrl = "http://skins.minecraft.net/MinecraftCloaks/" + StringUtils.stripControlCodes(this.username) + ".png";
  76. }
  77.  
  78. /**
  79. * Called to update the entity's position/logic.
  80. */
  81. public void onUpdate()
  82. {
  83. this.field_71082_cx = 0.0F;
  84. super.onUpdate();
  85. this.prevLimbYaw = this.limbYaw;
  86. double d0 = this.posX - this.prevPosX;
  87. double d1 = this.posZ - this.prevPosZ;
  88. float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F;
  89.  
  90. if (f > 1.0F)
  91. {
  92. f = 1.0F;
  93. }
  94.  
  95. this.limbYaw += (f - this.limbYaw) * 0.4F;
  96. this.limbSwing += this.limbYaw;
  97.  
  98. if (!this.isItemInUse && this.isEating() && this.inventory.mainInventory[this.inventory.currentItem] != null)
  99. {
  100. ItemStack itemstack = this.inventory.mainInventory[this.inventory.currentItem];
  101. this.setItemInUse(this.inventory.mainInventory[this.inventory.currentItem], Item.itemsList[itemstack.itemID].getMaxItemUseDuration(itemstack));
  102. this.isItemInUse = true;
  103. }
  104. else if (this.isItemInUse && !this.isEating())
  105. {
  106. this.clearItemInUse();
  107. this.isItemInUse = false;
  108. }
  109. }
  110.  
  111. public float getShadowSize()
  112. {
  113. return 0.0F;
  114. }
  115.  
  116. /**
  117. * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  118. * use this to react to sunlight and start to burn.
  119. */
  120. public void onLivingUpdate()
  121. {
  122. super.updateEntityActionState();
  123.  
  124. if (this.otherPlayerMPPosRotationIncrements > 0)
  125. {
  126. double d0 = this.posX + (this.otherPlayerMPX - this.posX) / (double)this.otherPlayerMPPosRotationIncrements;
  127. double d1 = this.posY + (this.otherPlayerMPY - this.posY) / (double)this.otherPlayerMPPosRotationIncrements;
  128. double d2 = this.posZ + (this.otherPlayerMPZ - this.posZ) / (double)this.otherPlayerMPPosRotationIncrements;
  129. double d3;
  130.  
  131. for (d3 = this.otherPlayerMPYaw - (double)this.rotationYaw; d3 < -180.0D; d3 += 360.0D)
  132. {
  133. ;
  134. }
  135.  
  136. while (d3 >= 180.0D)
  137. {
  138. d3 -= 360.0D;
  139. }
  140.  
  141. this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.otherPlayerMPPosRotationIncrements);
  142. this.rotationPitch = (float)((double)this.rotationPitch + (this.otherPlayerMPPitch - (double)this.rotationPitch) / (double)this.otherPlayerMPPosRotationIncrements);
  143. --this.otherPlayerMPPosRotationIncrements;
  144. this.setPosition(d0, d1, d2);
  145. this.setRotation(this.rotationYaw, this.rotationPitch);
  146. }
  147.  
  148. this.prevCameraYaw = this.cameraYaw;
  149. float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
  150. float f1 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
  151.  
  152. if (f > 0.1F)
  153. {
  154. f = 0.1F;
  155. }
  156.  
  157. if (!this.onGround || this.getHealth() <= 0)
  158. {
  159. f = 0.0F;
  160. }
  161.  
  162. if (this.onGround || this.getHealth() <= 0)
  163. {
  164. f1 = 0.0F;
  165. }
  166.  
  167. this.cameraYaw += (f - this.cameraYaw) * 0.4F;
  168. this.cameraPitch += (f1 - this.cameraPitch) * 0.8F;
  169. }
  170.  
  171. /**
  172. * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
  173. */
  174. public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack)
  175. {
  176. if (par1 == 0)
  177. {
  178. this.inventory.mainInventory[this.inventory.currentItem] = par2ItemStack;
  179. }
  180. else
  181. {
  182. this.inventory.armorInventory[par1 - 1] = par2ItemStack;
  183. }
  184. }
  185.  
  186. public float getEyeHeight()
  187. {
  188. return 1.82F;
  189. }
  190.  
  191. public void sendChatToPlayer(String par1Str)
  192. {
  193. Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1Str);
  194. }
  195.  
  196. /**
  197. * Returns true if the command sender is allowed to use the given command.
  198. */
  199. public boolean canCommandSenderUseCommand(int par1, String par2Str)
  200. {
  201. return false;
  202. }
  203.  
  204. /**
  205. * Return the position for this command sender.
  206. */
  207. public ChunkCoordinates getPlayerCoordinates()
  208. {
  209. return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D));
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement