summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/PlayerAbilities.java
blob: 7acea6e9a474cbedc47d2664eeeb7a6ae933e3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package net.minecraft.server;

public class PlayerAbilities {

    public boolean isInvulnerable;
    public boolean isFlying;
    public boolean canFly;
    public boolean canInstantlyBuild;
    public boolean mayBuild = true;
    public float flySpeed = 0.05F; // CraftBukkit private -> public
    public float walkSpeed = 0.1F; // CraftBukkit private -> public

    public PlayerAbilities() {}

    public void a(NBTTagCompound nbttagcompound) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();

        nbttagcompound1.setBoolean("invulnerable", this.isInvulnerable);
        nbttagcompound1.setBoolean("flying", this.isFlying);
        nbttagcompound1.setBoolean("mayfly", this.canFly);
        nbttagcompound1.setBoolean("instabuild", this.canInstantlyBuild);
        nbttagcompound1.setBoolean("mayBuild", this.mayBuild);
        nbttagcompound1.setFloat("flySpeed", this.flySpeed);
        nbttagcompound1.setFloat("walkSpeed", this.walkSpeed);
        nbttagcompound.set("abilities", nbttagcompound1);
    }

    public void b(NBTTagCompound nbttagcompound) {
        if (nbttagcompound.hasKey("abilities")) {
            NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("abilities");

            this.isInvulnerable = nbttagcompound1.getBoolean("invulnerable");
            this.isFlying = nbttagcompound1.getBoolean("flying");
            this.canFly = nbttagcompound1.getBoolean("mayfly");
            this.canInstantlyBuild = nbttagcompound1.getBoolean("instabuild");
            if (nbttagcompound1.hasKey("flySpeed")) {
                this.flySpeed = nbttagcompound1.getFloat("flySpeed");
                this.walkSpeed = nbttagcompound1.getFloat("walkSpeed");
            }

            if (nbttagcompound1.hasKey("mayBuild")) {
                this.mayBuild = nbttagcompound1.getBoolean("mayBuild");
            }
        }
    }

    public float a() {
        return this.flySpeed;
    }

    public float b() {
        return this.walkSpeed;
    }
}