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