tcr/java/src/game/tileentity/TileEntityLockable.java

51 lines
1.2 KiB
Java
Raw Normal View History

2025-03-11 00:23:54 +01:00
package game.tileentity;
import game.nbt.NBTTagCompound;
public abstract class TileEntityLockable extends TileEntity implements IInteractionObject, ILockableContainer
{
private LockCode code = LockCode.EMPTY_CODE;
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.code = LockCode.fromNBT(compound);
}
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
if (this.code != null)
{
this.code.toNBT(compound);
}
}
public boolean isLocked()
{
return this.code != null && !this.code.isEmpty();
}
public LockCode getLockCode()
{
return this.code;
}
public void setLockCode(LockCode code)
{
this.code = code;
}
public abstract String getName();
public abstract boolean hasCustomName();
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
}