    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.client.Minecraft;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class EntityOtherPlayerMP extends EntityPlayer
    009    {
    010        private boolean isItemInUse = false;
    011        private int otherPlayerMPPosRotationIncrements;
    012        private double otherPlayerMPX;
    013        private double otherPlayerMPY;
    014        private double otherPlayerMPZ;
    015        private double otherPlayerMPYaw;
    016        private double otherPlayerMPPitch;
    017
    018        public EntityOtherPlayerMP(World par1World, String par2Str)
    019        {
    020            super(par1World);
    021            this.username = par2Str;
    022            this.yOffset = 0.0F;
    023            this.stepHeight = 0.0F;
    024
    025            if (par2Str != null && par2Str.length() > 0)
    026            {
    027                this.skinUrl = "http://skins.minecraft.net/MinecraftSkins/" + StringUtils.stripControlCodes(par2Str) + ".png";
    028            }
    029
    030            this.noClip = true;
    031            this.field_71082_cx = 0.25F;
    032            this.renderDistanceWeight = 10.0D;
    033        }
    034
    035        /**
    036         * sets the players height back to normal after doing things like sleeping and dieing
    037         */
    038        protected void resetHeight()
    039        {
    040            this.yOffset = 0.0F;
    041        }
    042
    043        /**
    044         * Called when the entity is attacked.
    045         */
    046        public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
    047        {
    048            return true;
    049        }
    050
    051        /**
    052         * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
    053         * posY, posZ, yaw, pitch
    054         */
    055        public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
    056        {
    057            this.otherPlayerMPX = par1;
    058            this.otherPlayerMPY = par3;
    059            this.otherPlayerMPZ = par5;
    060            this.otherPlayerMPYaw = (double)par7;
    061            this.otherPlayerMPPitch = (double)par8;
    062            this.otherPlayerMPPosRotationIncrements = par9;
    063        }
    064
    065        public void updateCloak()
    066        {
    067            this.playerCloakUrl = "http://skins.minecraft.net/MinecraftCloaks/" + StringUtils.stripControlCodes(this.username) + ".png";
    068            this.cloakUrl = this.playerCloakUrl;
    069        }
    070
    071        /**
    072         * Called to update the entity's position/logic.
    073         */
    074        public void onUpdate()
    075        {
    076            this.field_71082_cx = 0.0F;
    077            super.onUpdate();
    078            this.prevLegYaw = this.legYaw;
    079            double var1 = this.posX - this.prevPosX;
    080            double var3 = this.posZ - this.prevPosZ;
    081            float var5 = MathHelper.sqrt_double(var1 * var1 + var3 * var3) * 4.0F;
    082
    083            if (var5 > 1.0F)
    084            {
    085                var5 = 1.0F;
    086            }
    087
    088            this.legYaw += (var5 - this.legYaw) * 0.4F;
    089            this.legSwing += this.legYaw;
    090
    091            if (!this.isItemInUse && this.isEating() && this.inventory.mainInventory[this.inventory.currentItem] != null)
    092            {
    093                ItemStack var6 = this.inventory.mainInventory[this.inventory.currentItem];
    094                this.setItemInUse(this.inventory.mainInventory[this.inventory.currentItem], Item.itemsList[var6.itemID].getMaxItemUseDuration(var6));
    095                this.isItemInUse = true;
    096            }
    097            else if (this.isItemInUse && !this.isEating())
    098            {
    099                this.clearItemInUse();
    100                this.isItemInUse = false;
    101            }
    102        }
    103
    104        public float getShadowSize()
    105        {
    106            return 0.0F;
    107        }
    108
    109        /**
    110         * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
    111         * use this to react to sunlight and start to burn.
    112         */
    113        public void onLivingUpdate()
    114        {
    115            super.updateEntityActionState();
    116
    117            if (this.otherPlayerMPPosRotationIncrements > 0)
    118            {
    119                double var1 = this.posX + (this.otherPlayerMPX - this.posX) / (double)this.otherPlayerMPPosRotationIncrements;
    120                double var3 = this.posY + (this.otherPlayerMPY - this.posY) / (double)this.otherPlayerMPPosRotationIncrements;
    121                double var5 = this.posZ + (this.otherPlayerMPZ - this.posZ) / (double)this.otherPlayerMPPosRotationIncrements;
    122                double var7;
    123
    124                for (var7 = this.otherPlayerMPYaw - (double)this.rotationYaw; var7 < -180.0D; var7 += 360.0D)
    125                {
    126                    ;
    127                }
    128
    129                while (var7 >= 180.0D)
    130                {
    131                    var7 -= 360.0D;
    132                }
    133
    134                this.rotationYaw = (float)((double)this.rotationYaw + var7 / (double)this.otherPlayerMPPosRotationIncrements);
    135                this.rotationPitch = (float)((double)this.rotationPitch + (this.otherPlayerMPPitch - (double)this.rotationPitch) / (double)this.otherPlayerMPPosRotationIncrements);
    136                --this.otherPlayerMPPosRotationIncrements;
    137                this.setPosition(var1, var3, var5);
    138                this.setRotation(this.rotationYaw, this.rotationPitch);
    139            }
    140
    141            this.prevCameraYaw = this.cameraYaw;
    142            float var9 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    143            float var2 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
    144
    145            if (var9 > 0.1F)
    146            {
    147                var9 = 0.1F;
    148            }
    149
    150            if (!this.onGround || this.getHealth() <= 0)
    151            {
    152                var9 = 0.0F;
    153            }
    154
    155            if (this.onGround || this.getHealth() <= 0)
    156            {
    157                var2 = 0.0F;
    158            }
    159
    160            this.cameraYaw += (var9 - this.cameraYaw) * 0.4F;
    161            this.cameraPitch += (var2 - this.cameraPitch) * 0.8F;
    162        }
    163
    164        public void func_70062_b(int par1, ItemStack par2ItemStack)
    165        {
    166            if (par1 == 0)
    167            {
    168                this.inventory.mainInventory[this.inventory.currentItem] = par2ItemStack;
    169            }
    170            else
    171            {
    172                this.inventory.armorInventory[par1 - 1] = par2ItemStack;
    173            }
    174        }
    175
    176        public float getEyeHeight()
    177        {
    178            return 1.82F;
    179        }
    180
    181        public void sendChatToPlayer(String par1Str)
    182        {
    183            Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1Str);
    184        }
    185
    186        /**
    187         * Returns true if the command sender is allowed to use the given command.
    188         */
    189        public boolean canCommandSenderUseCommand(String par1Str)
    190        {
    191            return false;
    192        }
    193    }