Record Class CustomItemContext
java.lang.Object
java.lang.Record
org.geysermc.geyser.registry.populator.custom.CustomItemContext
- Record Components:
definition- the custom item definition itselfcomponents- 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 phasevanillaMapping- for vanilla-item overrides, the vanilla bedrock mapping of the itemcustomItemId- the bedrock ID of the itemprotocolVersion- 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 Summary
ConstructorsConstructorDescriptionCustomItemContext(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 aCustomItemContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionorg.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentsReturns the value of thecomponentsrecord component.static CustomItemContextcreateNonVanillaAndValidateComponents(org.geysermc.geyser.api.item.custom.v2.NonVanillaCustomItemDefinition customItem, int customItemId, int protocolVersion) Creates a CustomItemContext for a non-vanilla custom item.static CustomItemContextcreateVanillaAndValidateComponents(Item javaItem, GeyserMappingItem vanillaMapping, org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition customItem, int customItemId, int protocolVersion) Creates a CustomItemContext for a vanilla-item override.intReturns the value of thecustomItemIdrecord component.org.geysermc.geyser.api.item.custom.v2.CustomItemDefinitionReturns the value of thedefinitionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of theprotocolVersionrecord component.Returns the value of theresolvableComponentsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevanillaMappingrecord component.
-
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 aCustomItemContextrecord class.- Parameters:
definition- the value for thedefinitionrecord componentcomponents- the value for thecomponentsrecord componentresolvableComponents- the value for theresolvableComponentsrecord componentvanillaMapping- the value for thevanillaMappingrecord componentcustomItemId- the value for thecustomItemIdrecord componentprotocolVersion- the value for theprotocolVersionrecord 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 theCustomItemDefinitiononto the default components of thejavaItem- Parameters:
javaItem- the vanilla Java itemvanillaMapping- the mapping of the vanilla Java itemcustomItem- the custom item definitioncustomItemId- the bedrock ID of the itemprotocolVersion- 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 definitioncustomItemId- the bedrock ID of the itemprotocolVersion- 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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
definition
public org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition definition()Returns the value of thedefinitionrecord component.- Returns:
- the value of the
definitionrecord component
-
components
public org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components()Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-
resolvableComponents
Returns the value of theresolvableComponentsrecord component.- Returns:
- the value of the
resolvableComponentsrecord component
-
vanillaMapping
Returns the value of thevanillaMappingrecord component.- Returns:
- the value of the
vanillaMappingrecord component
-
customItemId
public int customItemId()Returns the value of thecustomItemIdrecord component.- Returns:
- the value of the
customItemIdrecord component
-
protocolVersion
public int protocolVersion()Returns the value of theprotocolVersionrecord component.- Returns:
- the value of the
protocolVersionrecord component
-