PlayerCapabilities .java

net.minecraft.entity.player.PlayerCapabilities (class, 82 lines): members: readCapabilitiesFromNBT, writeCapabilitiesToNBT, setPlayerWalkSpeed, allowEdit.

net.minecraft.entity.playerclass82 linescommon2.5 KB

API Surface (6)

void writeCapabilitiesToNBT(NBTTagCompound tagCompound)
void readCapabilitiesFromNBT(NBTTagCompound tagCompound)
float getFlySpeed()
void setFlySpeed(float speed)
float getWalkSpeed()
void setPlayerWalkSpeed(float speed)

Fields & Constants (7)

disableDamage
isFlying
allowFlying
isCreativeMode
allowEdit
flySpeed
walkSpeed

String literals (8)

"invulnerable"
"flying"
"mayfly"
"instabuild"
"mayBuild"
"flySpeed"
"walkSpeed"
"abilities"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PlayerCapabilities.java82 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.player;
2
3
import net.minecraft.nbt.NBTTagCompound;
4
5
public class PlayerCapabilities
6
{
7
    /** Disables player damage. */
8
    public boolean disableDamage;
9
10
    /** Sets/indicates whether the player is flying. */
11
    public boolean isFlying;
12
13
    /** whether or not to allow the player to fly when they double jump. */
14
    public boolean allowFlying;
15
16
    /**
17
     * Used to determine if creative mode is enabled, and therefore if items should be depleted on usage
18
     */
19
    public boolean isCreativeMode;
20
21
    /** Indicates whether the player is allowed to modify the surroundings */
22
    public boolean allowEdit = true;
23
    private float flySpeed = 0.05F;
24
    private float walkSpeed = 0.1F;
25
26
    public void writeCapabilitiesToNBT(NBTTagCompound tagCompound)
27
    {
28
        NBTTagCompound nbttagcompound = new NBTTagCompound();
29
        nbttagcompound.setBoolean("invulnerable", this.disableDamage);
30
        nbttagcompound.setBoolean("flying", this.isFlying);
31
        nbttagcompound.setBoolean("mayfly", this.allowFlying);
32
        nbttagcompound.setBoolean("instabuild", this.isCreativeMode);
33
        nbttagcompound.setBoolean("mayBuild", this.allowEdit);
34
        nbttagcompound.setFloat("flySpeed", this.flySpeed);
35
        nbttagcompound.setFloat("walkSpeed", this.walkSpeed);
36
        tagCompound.setTag("abilities", nbttagcompound);
37
    }
38
39
    public void readCapabilitiesFromNBT(NBTTagCompound tagCompound)
40
    {
41
        if (tagCompound.hasKey("abilities", 10))
42
        {
43
            NBTTagCompound nbttagcompound = tagCompound.getCompoundTag("abilities");
44
            this.disableDamage = nbttagcompound.getBoolean("invulnerable");
45
            this.isFlying = nbttagcompound.getBoolean("flying");
46
            this.allowFlying = nbttagcompound.getBoolean("mayfly");
47
            this.isCreativeMode = nbttagcompound.getBoolean("instabuild");
48
49
            if (nbttagcompound.hasKey("flySpeed", 99))
50
            {
51
                this.flySpeed = nbttagcompound.getFloat("flySpeed");
52
                this.walkSpeed = nbttagcompound.getFloat("walkSpeed");
53
            }
54
55
            if (nbttagcompound.hasKey("mayBuild", 1))
56
            {
57
                this.allowEdit = nbttagcompound.getBoolean("mayBuild");
58
            }
59
        }
60
    }
61
62
    public float getFlySpeed()
63
    {
64
        return this.flySpeed;
65
    }
66
67
    public void setFlySpeed(float speed)
68
    {
69
        this.flySpeed = speed;
70
    }
71
72
    public float getWalkSpeed()
73
    {
74
        return this.walkSpeed;
75
    }
76
77
    public void setPlayerWalkSpeed(float speed)
78
    {
79
        this.walkSpeed = speed;
80
    }
81
}
82

Deobfuscated MCP 1.8.9 source of PlayerCapabilities from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/player/PlayerCapabilities.java), stored verbatim.