Class ContainerLock

java.lang.Object
net.minecraft.inventory.ContainerLock

@Immutable
public class ContainerLock
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • canOpen

      public boolean canOpen​(ItemStack stack)
      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

      public void toTag​(CompoundTag tag)
      Inserts the key string of this lock into the Lock key of the compound tag.
    • fromTag

      public static ContainerLock fromTag​(CompoundTag tag)
      Creates a new ContainerLock from the Lock key of the compound tag.

      If the Lock key is not present, returns an empty lock.