Record Class CustomItemContext

java.lang.Object
java.lang.Record
org.geysermc.geyser.registry.populator.custom.CustomItemContext
Record Components:
definition - the custom item definition itself
components - the full component map of the custom item definition. For vanilla-item overrides, this is the component patch applied on top of the vanilla item's default components. For non-vanilla items, this is the default components that were set in the API.
resolvableComponents - for non-vanilla custom items, any components that should be resolved once the session has finished the configuration phase
vanillaMapping - for vanilla-item overrides, the vanilla bedrock mapping of the item
customItemId - the bedrock ID of the item
protocolVersion - the bedrock protocol version

public record CustomItemContext(org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition definition, org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, List<ResolvableComponent<?>> resolvableComponents, Optional<GeyserMappingItem> vanillaMapping, int customItemId, int protocolVersion) extends Record
Contains various context properties regarding a custom item definition.
  • Constructor Details

    • CustomItemContext

      public CustomItemContext(org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition definition, org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, List<ResolvableComponent<?>> resolvableComponents, Optional<GeyserMappingItem> vanillaMapping, int customItemId, int protocolVersion)
      Creates an instance of a CustomItemContext record class.
      Parameters:
      definition - the value for the definition record component
      components - the value for the components record component
      resolvableComponents - the value for the resolvableComponents record component
      vanillaMapping - the value for the vanillaMapping record component
      customItemId - the value for the customItemId record component
      protocolVersion - the value for the protocolVersion record component
  • Method Details

    • createVanillaAndValidateComponents

      public static CustomItemContext createVanillaAndValidateComponents(Item javaItem, GeyserMappingItem vanillaMapping, org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition customItem, int customItemId, int protocolVersion) throws InvalidItemComponentsException
      Creates a CustomItemContext for a vanilla-item override. This patches the component patch of the CustomItemDefinition onto the default components of the javaItem
      Parameters:
      javaItem - the vanilla Java item
      vanillaMapping - the mapping of the vanilla Java item
      customItem - the custom item definition
      customItemId - the bedrock ID of the item
      protocolVersion - the bedrock protocol version
      Returns:
      the created context
      Throws:
      InvalidItemComponentsException - when the custom item definition has an invalid combination of components in its component patch
    • createNonVanillaAndValidateComponents

      public static CustomItemContext createNonVanillaAndValidateComponents(org.geysermc.geyser.api.item.custom.v2.NonVanillaCustomItemDefinition customItem, int customItemId, int protocolVersion) throws InvalidItemComponentsException
      Creates a CustomItemContext for a non-vanilla custom item.
      Parameters:
      customItem - the non-vanilla custom item definition
      customItemId - the bedrock ID of the item
      protocolVersion - the bedrock protocol version
      Returns:
      the created context
      Throws:
      InvalidItemComponentsException - when the custom item definition has an invalid combination of components in its component patch
    • 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 o)
      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • definition

      public org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition definition()
      Returns the value of the definition record component.
      Returns:
      the value of the definition record component
    • components

      public org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components()
      Returns the value of the components record component.
      Returns:
      the value of the components record component
    • resolvableComponents

      public List<ResolvableComponent<?>> resolvableComponents()
      Returns the value of the resolvableComponents record component.
      Returns:
      the value of the resolvableComponents record component
    • vanillaMapping

      public Optional<GeyserMappingItem> vanillaMapping()
      Returns the value of the vanillaMapping record component.
      Returns:
      the value of the vanillaMapping record component
    • customItemId

      public int customItemId()
      Returns the value of the customItemId record component.
      Returns:
      the value of the customItemId record component
    • protocolVersion

      public int protocolVersion()
      Returns the value of the protocolVersion record component.
      Returns:
      the value of the protocolVersion record component