001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    
006    public class PlayerCapabilities
007    {
008        /** Disables player damage. */
009        public boolean disableDamage = false;
010    
011        /** Sets/indicates whether the player is flying. */
012        public boolean isFlying = false;
013    
014        /** whether or not to allow the player to fly when they double jump. */
015        public boolean allowFlying = false;
016    
017        /**
018         * Used to determine if creative mode is enabled, and therefore if items should be depleted on usage
019         */
020        public boolean isCreativeMode = false;
021    
022        /** Indicates whether the player is allowed to modify the surroundings */
023        public boolean allowEdit = true;
024        private float flySpeed = 0.05F;
025        private float walkSpeed = 0.1F;
026    
027        public void writeCapabilitiesToNBT(NBTTagCompound par1NBTTagCompound)
028        {
029            NBTTagCompound var2 = new NBTTagCompound();
030            var2.setBoolean("invulnerable", this.disableDamage);
031            var2.setBoolean("flying", this.isFlying);
032            var2.setBoolean("mayfly", this.allowFlying);
033            var2.setBoolean("instabuild", this.isCreativeMode);
034            var2.setBoolean("mayBuild", this.allowEdit);
035            var2.setFloat("flySpeed", this.flySpeed);
036            var2.setFloat("walkSpeed", this.walkSpeed);
037            par1NBTTagCompound.setTag("abilities", var2);
038        }
039    
040        public void readCapabilitiesFromNBT(NBTTagCompound par1NBTTagCompound)
041        {
042            if (par1NBTTagCompound.hasKey("abilities"))
043            {
044                NBTTagCompound var2 = par1NBTTagCompound.getCompoundTag("abilities");
045                this.disableDamage = var2.getBoolean("invulnerable");
046                this.isFlying = var2.getBoolean("flying");
047                this.allowFlying = var2.getBoolean("mayfly");
048                this.isCreativeMode = var2.getBoolean("instabuild");
049    
050                if (var2.hasKey("flySpeed"))
051                {
052                    this.flySpeed = var2.getFloat("flySpeed");
053                    this.walkSpeed = var2.getFloat("walkSpeed");
054                }
055    
056                if (var2.hasKey("mayBuild"))
057                {
058                    this.allowEdit = var2.getBoolean("mayBuild");
059                }
060            }
061        }
062    
063        public float getFlySpeed()
064        {
065            return this.flySpeed;
066        }
067    
068        @SideOnly(Side.CLIENT)
069        public void setFlySpeed(float par1)
070        {
071            this.flySpeed = par1;
072        }
073    
074        public float getWalkSpeed()
075        {
076            return this.walkSpeed;
077        }
078    
079        @SideOnly(Side.CLIENT)
080        public void func_82877_b(float par1)
081        {
082            this.walkSpeed = par1;
083        }
084    }