Package net.minecraft.inventory
Class ContainerLock
java.lang.Object
net.minecraft.inventory.ContainerLock
@Immutable public class ContainerLock extends Object
-
Field Summary
Fields Modifier and Type Field Description static ContainerLock
EMPTY
An empty container lock that can always be opened.private String
key
-
Constructor Summary
Constructors Constructor Description ContainerLock(String key)
-
Method Summary
Modifier and Type Method Description boolean
canOpen(ItemStack stack)
Returns true if this lock can be opened with the key item stack.static ContainerLock
fromTag(CompoundTag tag)
Creates a newContainerLock
from theLock
key of the compound tag.void
toTag(CompoundTag tag)
Inserts the key string of this lock into theLock
key of the compound tag.
-
Field Details
-
EMPTY
An empty container lock that can always be opened. -
key
-
-
Constructor Details
-
ContainerLock
-
-
Method Details
-
canOpen
Returns true if this lock can be opened with the key item stack.An item stack is a valid key if the stack name matches the key string of this lock, or if the key string is empty.
- Parameters:
stack
- the key item stack
-
toTag
Inserts the key string of this lock into theLock
key of the compound tag. -
fromTag
Creates a newContainerLock
from theLock
key of the compound tag.If the
Lock
key is not present, returns an empty lock.
-