TileEntityLockable .java

net.minecraft.tileentity.TileEntityLockable (class, 54 lines): members: code, getLockCode, setLockCode, isLocked, getDisplayName, readFromNBT, writeToNBT.

net.minecraft.tileentityclass54 linescommonextends TileEntity1.4 KB

Implements

API Surface (6)

void readFromNBT(NBTTagCompound compound)
void writeToNBT(NBTTagCompound compound)
boolean isLocked()
LockCode getLockCode()
void setLockCode(LockCode code)
IChatComponent getDisplayName()

Fields & Constants (1)

code

Full Source

TileEntityLockable.java54 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.tileentity;
2
3
import net.minecraft.nbt.NBTTagCompound;
4
import net.minecraft.util.ChatComponentText;
5
import net.minecraft.util.ChatComponentTranslation;
6
import net.minecraft.util.IChatComponent;
7
import net.minecraft.world.IInteractionObject;
8
import net.minecraft.world.ILockableContainer;
9
import net.minecraft.world.LockCode;
10
11
public abstract class TileEntityLockable extends TileEntity implements IInteractionObject, ILockableContainer
12
{
13
    private LockCode code = LockCode.EMPTY_CODE;
14
15
    public void readFromNBT(NBTTagCompound compound)
16
    {
17
        super.readFromNBT(compound);
18
        this.code = LockCode.fromNBT(compound);
19
    }
20
21
    public void writeToNBT(NBTTagCompound compound)
22
    {
23
        super.writeToNBT(compound);
24
25
        if (this.code != null)
26
        {
27
            this.code.toNBT(compound);
28
        }
29
    }
30
31
    public boolean isLocked()
32
    {
33
        return this.code != null && !this.code.isEmpty();
34
    }
35
36
    public LockCode getLockCode()
37
    {
38
        return this.code;
39
    }
40
41
    public void setLockCode(LockCode code)
42
    {
43
        this.code = code;
44
    }
45
46
    /**
47
     * Get the formatted ChatComponent that will be used for the sender's username in chat
48
     */
49
    public IChatComponent getDisplayName()
50
    {
51
        return (IChatComponent)(this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName(), new Object[0]));
52
    }
53
}
54

Deobfuscated MCP 1.8.9 source of TileEntityLockable from Marcelektro/MavenMCP-1.8.9 (net/minecraft/tileentity/TileEntityLockable.java), stored verbatim.