Record Class ContainerLock

java.lang.Object
java.lang.Record
net.minecraft.inventory.ContainerLock
Record Components:
key -

public record ContainerLock(String key) extends Record
Mappings:
Namespace Name
named net/minecraft/inventory/ContainerLock
intermediary net/minecraft/class_1273
official bqu
named key
intermediary comp_2371
official d
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<ContainerLock>
     
    static final ContainerLock
    An empty container lock that can always be opened.
    private final String
    The field for the key record component.
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a ContainerLock record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this lock can be opened with the key item stack.
    final boolean
    equals(Object object)
    Indicates whether some other object is "equal to" this one.
    Creates a new ContainerLock from the Lock key of the NBT compound.
    final int
    Returns a hash code value for this object.
    key()
    Returns the value of the key record component.
    final String
    Returns a string representation of this record class.
    void
    Inserts the key string of this lock into the Lock key of the NBT compound.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • key

      private final String key
      The field for the key record component.
    • EMPTY

      public static final ContainerLock EMPTY
      An empty container lock that can always be opened.
      Mappings:
      Namespace Name Mixin selector
      named EMPTY Lnet/minecraft/inventory/ContainerLock;EMPTY:Lnet/minecraft/inventory/ContainerLock;
      intermediary field_5817 Lnet/minecraft/class_1273;field_5817:Lnet/minecraft/class_1273;
      official a Lbqu;a:Lbqu;
    • CODEC

      public static final com.mojang.serialization.Codec<ContainerLock> CODEC
      Mappings:
      Namespace Name Mixin selector
      named CODEC Lnet/minecraft/inventory/ContainerLock;CODEC:Lcom/mojang/serialization/Codec;
      intermediary field_49206 Lnet/minecraft/class_1273;field_49206:Lcom/mojang/serialization/Codec;
      official b Lbqu;b:Lcom/mojang/serialization/Codec;
    • LOCK_KEY

      public static final String LOCK_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named LOCK_KEY Lnet/minecraft/inventory/ContainerLock;LOCK_KEY:Ljava/lang/String;
      intermediary field_29956 Lnet/minecraft/class_1273;field_29956:Ljava/lang/String;
      official c Lbqu;c:Ljava/lang/String;
  • Constructor Details

    • ContainerLock

      public ContainerLock(String key)
      Creates an instance of a ContainerLock record class.
      Parameters:
      key - the value for the key record component
  • 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.

      Mappings:
      Namespace Name Mixin selector
      named canOpen Lnet/minecraft/inventory/ContainerLock;canOpen(Lnet/minecraft/item/ItemStack;)Z
      intermediary method_5472 Lnet/minecraft/class_1273;method_5472(Lnet/minecraft/class_1799;)Z
      official a Lbqu;a(Lcuq;)Z
    • writeNbt

      public void writeNbt(NbtCompound nbt)
      Inserts the key string of this lock into the Lock key of the NBT compound.
      Mappings:
      Namespace Name Mixin selector
      named writeNbt Lnet/minecraft/inventory/ContainerLock;writeNbt(Lnet/minecraft/nbt/NbtCompound;)V
      intermediary method_5474 Lnet/minecraft/class_1273;method_5474(Lnet/minecraft/class_2487;)V
      official a Lbqu;a(Lub;)V
    • fromNbt

      public static ContainerLock fromNbt(NbtCompound nbt)
      Creates a new ContainerLock from the Lock key of the NBT compound.

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

      Mappings:
      Namespace Name Mixin selector
      named fromNbt Lnet/minecraft/inventory/ContainerLock;fromNbt(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/inventory/ContainerLock;
      intermediary method_5473 Lnet/minecraft/class_1273;method_5473(Lnet/minecraft/class_2487;)Lnet/minecraft/class_1273;
      official b Lbqu;b(Lub;)Lbqu;
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object object)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component