ComponentAccess
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
Description
An interface exposing methods to handle setting and removing DataComponents.DataComponents are the new way of storing data in memory, instead of writing it to NBT data and to disk every time, which has a performance cost. DataComponents now occupy the space that was previously occupied or known as a NBT tag.
DataComponents are immutable. Operations that set or remove a component return a new instance of the object implementing ComponentAccess
DataComponents may optionally be persistent. They also may optionally be syncronised.
In most cases, ComponentAccesses are going to be ItemStacks, although in NeoForge FluidStacks are too.
Members
Return Type:
ItemAttributeModifiers
Return Type:
BannerPatternLayers
Return Type:
DyeColor
Return Type:
List<BeehiveBlockEntityOccupant>
Return Type:
CustomData
Return Type:
BlockItemStateProperties
Return Type:
CustomData
Return Type:
BundleContents
Return Type:
AdventureModePredicate
Return Type:
AdventureModePredicate
Return Type:
ChargedProjectiles
Return Type:
ItemContainerContents
Return Type:
SeededContainerLoot
Return Type:
bool
Return Type:
CustomData
Return Type:
CustomModelData
A custom name is generally displayed in italics and controlled by the user.
Return Type:
Component
Return Type:
int
Return Type:
DebugStickState
Return Type:
DyedItemColor
If it is present, it is first checked to determine whether there is special behaviour, otherwise the code checks for enchantments.
Return Type:
bool
Return Type:
ItemEnchantments
Return Type:
CustomData
Return Type:
FireworkExplosion
Return Type:
Fireworks
Return Type:
FoodProperties
Return Type:
bool
Return Type:
bool
Used for shield colouring.
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
This component is used for crossbows.
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
MapDecorations are additional elements that render on a map, such as waypoints.
Return Type:
bool
Return Type:
bool
This componenet stores additional info on the map, such as the scale or whether to lock it.
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Stores Potion Data on an item.
Return Type:
bool
Return Type:
bool
Return Type:
bool
Used for Knowledge Books.
Return Type:
bool
Return Type:
bool
The stored enchantments component is only present in enchanted books, since it just stores the enchantments under a lid for future use. The item is not enchanted.
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
bool
Return Type:
Instrument
Return Type:
bool
Return Type:
bool
In the case of items, an item name is set by the make to make a special instance of an item, such as with ominous banners.
Return Type:
Component
Return Type:
LockCode
Return Type:
LodestoneTracker
Return Type:
ItemLore
Return Type:
MapItemColor
Return Type:
MapDecorations
Return Type:
MapId
Return Type:
MapPostProcessing
Return Type:
int
Return Type:
int
Return Type:
ResourceLocation
Return Type:
int
Return Type:
PotDecorations
Return Type:
PotionContents
Return Type:
ResolvableProfile
Return Type:
Rarity
Return Type:
List<ResourceLocation>
Return Type:
int
Return Type:
ItemEnchantments
Return Type:
SuspiciousStewEffects
Return Type:
Tool
Return Type:
ArmorTrim
Return Type:
Unbreakable
ItemAttributeModifiers
Returns: The new instance with the modified data.
Parameters:
modifiers: ItemAttributeModifiers
Type: ItemAttributeModifiers
- The attributes to give to the item.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
modifier: ItemAttributeModifiersEntry
Type: ItemAttributeModifiersEntry
showInTooltip: bool
(optional) Type: bool
Default Value: true
Return Type:
ComponentAccess
Parameters:
modifiers: List<ItemAttributeModifiersEntry>
Type: List<ItemAttributeModifiersEntry>
showInTooltip: bool
(optional) Type: bool
Default Value: true
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
layers: List<BannerPatternLayersLayer>
Type: List<BannerPatternLayersLayer>
Return Type:
ComponentAccess
BannerPatternLayers
Returns: The new instance with the modified data.
Parameters:
layers: BannerPatternLayers
Type: BannerPatternLayers
Return Type:
ComponentAccess
DyeColor
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
occupants: List<BeehiveBlockEntityOccupant>
Type: List<BeehiveBlockEntityOccupant>
Return Type:
ComponentAccess
MapData
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
CustomData
Returns: The new instance with the modified data.
Parameters:
data: CustomData
Type: CustomData
Return Type:
ComponentAccess
BlockItemStateProperties
Returns: The new instance with the modified data.
Parameters:
properties: BlockItemStateProperties
Type: BlockItemStateProperties
Return Type:
ComponentAccess
MapData
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
CustomData
Returns: The new instance with the modified data.
Parameters:
data: CustomData
Type: CustomData
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
BundleContents
Returns: The new instance with the modified data.
Parameters:
contents: BundleContents
Type: BundleContents
Return Type:
ComponentAccess
Any predicate that matches will allow the Block to be broken by this ItemStack.
Returns: The new instance with the modified data.
Parameters:
predicates: List<BlockPredicate>
Type: List<BlockPredicate>
- The collection of predicates to test for showInTooltip: bool
(optional) Type: bool
- Whether to show the ability in the tooltip or not.
Default Value: true
Return Type:
ComponentAccess
AdventureModePredicate
Returns: The new instance with the modified data.
Parameters:
predicate: AdventureModePredicate
Type: AdventureModePredicate
- The adventure mode predicate to use to determine whether the item can be used to break a block.
Return Type:
ComponentAccess
Any predicate that matches will allow the BlockItem within the ItemStack to be placed.
Returns: The new instance with the modified data.
Parameters:
predicates: List<BlockPredicate>
Type: List<BlockPredicate>
- The collection of predicates to test for showInTooltip: bool
(optional) Type: bool
- Whether to show the restriction in the tooltip or not.
Default Value: true
Return Type:
ComponentAccess
AdventureModePredicate
Returns: The new instance with the modified data.
Parameters:
predicate: AdventureModePredicate
Type: AdventureModePredicate
- The adventure mode predicate to use to determine whether the current block can be placed on another block.
Return Type:
ComponentAccess
IItemStack
Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
ChargedProjectiles
Returns: The new instance with the modified data.
Parameters:
chargedProjectiles: ChargedProjectiles
Type: ChargedProjectiles
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
contents: List<IItemStack>
Type: List<IItemStack>
Return Type:
ComponentAccess
ItemContainerContents
Returns: The new instance with the modified data.
Parameters:
contents: ItemContainerContents
Type: ItemContainerContents
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
lootTable: ResourceKey<LootTable>
Type: ResourceKey<LootTable>
seed: long
Type: long
Return Type:
ComponentAccess
SeededContainerLoot
Returns: The new instance with the modified data.
Parameters:
loot: SeededContainerLoot
Type: SeededContainerLoot
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
MapData
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
CustomData
Returns: The new instance with the modified data.
Parameters:
customData: CustomData
Type: CustomData
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
value: int
Type: int
- The value to set the CustomModelData to
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
data: CustomModelData
Type: CustomModelData
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
damage: int
Type: int
- The new damage of the ComponentAccess.
Return Type:
ComponentAccess
DebugStickState
Returns: The new instance with the modified data.
Parameters:
state: DebugStickState
Type: DebugStickState
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
rgb: int
Type: int
- The colour to dye this item with showInTooltip: bool
(optional) Type: bool
- Whether to show this information in a tooltip
Default Value: true
Return Type:
ComponentAccess
DyedItemColor
Returns: The new instance with the modified data.
Parameters:
color: DyedItemColor
Type: DyedItemColor
Return Type:
ComponentAccess
Enchantment
and level.Returns: The new instance with the modified data.
Parameters:
level: int
(optional) Type: int
- The level of the enchantment to set
Default Value: 1
Return Type:
ComponentAccess
If it is false, the item will never render the enchantment glint If it is true, the item will render the enchantment glint always, indenpendently of whether it is enchanted or not.
Returns: The new instance with the modified data.
Parameters:
value: bool
Type: bool
- The value of the override, as described above
Return Type:
ComponentAccess
ItemEnchantments
Returns: The new instance with the modified data.
Parameters:
enchantments: ItemEnchantments
Type: ItemEnchantments
Return Type:
ComponentAccess
MapData
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
CustomData
Returns: The new instance with the modified data.
Parameters:
data: CustomData
Type: CustomData
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
FireworkExplosion
Returns: The new instance with the modified data.
Parameters:
explosion: FireworkExplosion
Type: FireworkExplosion
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
flightDuration: int
Type: int
explosions: List<FireworkExplosion>
Type: List<FireworkExplosion>
Return Type:
ComponentAccess
Fireworks
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
FoodProperties
Returns: The new instance with the modified data.
Parameters:
food: FoodProperties
Type: FoodProperties
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Instrument
Returns: The new instance with the modified data.
Parameters:
instrument: Instrument
Type: Instrument
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Component
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
code: string
Type: string
Return Type:
ComponentAccess
LockCode
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
LodestoneTracker
Returns: The new instance with the modified data.
Parameters:
tracker: LodestoneTracker
Type: LodestoneTracker
Return Type:
ComponentAccess
Component
>Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
Return Type:
ComponentAccess
ItemLore
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
rgb: int
Type: int
- The new map colour
Return Type:
ComponentAccess
MapItemColor
Returns: The new instance with the modified data.
Parameters:
color: MapItemColor
Type: MapItemColor
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
decorations: MapDecorationsEntry[string]
Type: MapDecorationsEntry[string]
Return Type:
ComponentAccess
MapDecorations
Returns: The new instance with the modified data.
Parameters:
decorations: MapDecorations
Type: MapDecorations
Return Type:
ComponentAccess
A map id is only useful after the game generates one to store data. Therefore, you should always pass in the parameter for an id you know is available.
Returns: The new instance with the modified data.
Parameters:
id: int
Type: int
Return Type:
ComponentAccess
MapId
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
MapPostProcessing
Returns: The new instance with the modified data.
Parameters:
value: MapPostProcessing
Type: MapPostProcessing
Return Type:
ComponentAccess
It is likely that you need to call withDamage(0) in order for some things to function properly.
Returns: The new instance with the modified data.
Parameters:
maxDamage: int
Type: int
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
maxStackSize: int
Type: int
- The new maxStackSize of the ComponentAccess.
Return Type:
ComponentAccess
ResourceLocation
Returns: The new instance with the modified data.
Parameters:
sound: ResourceLocation
Type: ResourceLocation
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
amplifier: int
Type: int
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Enchantment
from the ComponentAccess.Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
back: ItemDefinition
Type: ItemDefinition
left: ItemDefinition
Type: ItemDefinition
right: ItemDefinition
Type: ItemDefinition
front: ItemDefinition
Type: ItemDefinition
Return Type:
ComponentAccess
PotDecorations
Returns: The new instance with the modified data.
Parameters:
decorations: PotDecorations
Type: PotDecorations
Return Type:
ComponentAccess
Potion
and no custom effects
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Potion
and the given
MobEffectInstance
effects.Returns: The new instance with the modified data.
Parameters:
customEffects: List<MobEffectInstance>
Type: List<MobEffectInstance>
- The effects to grant upon consuming this potion.
Return Type:
ComponentAccess
Potion
and the given
MobEffectInstance
effects.Returns: The new instance with the modified data.
Parameters:
customColor: int
Type: int
- The ARGB color the potion will have. customEffects: List<MobEffectInstance>
Type: List<MobEffectInstance>
- The effects to grant upon consuming this potion.
Return Type:
ComponentAccess
PotionContents
Returns: The new instance with the modified data.
Parameters:
contents: PotionContents
Type: PotionContents
Return Type:
ComponentAccess
ResolvableProfile
Returns: The new instance with the modified data.
Parameters:
profile: ResolvableProfile
Type: ResolvableProfile
Return Type:
ComponentAccess
Rarity
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
recipes: List<ResourceLocation>
Type: List<ResourceLocation>
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
cost: int
Type: int
- The repair cost
Return Type:
ComponentAccess
ItemEnchantments
Returns: The new instance with the modified data.
Parameters:
enchantments: ItemEnchantments
Type: ItemEnchantments
Return Type:
ComponentAccess
SuspiciousStewEffects
SuspiciousStewEffects.Entry is effectively a pair of Effect and duration.
Returns: The new instance with the modified data.
Parameters:
effects: List<SuspiciousStewEffectsEntry>
Type: List<SuspiciousStewEffectsEntry>
- The list of effects to grant on consumption.
Return Type:
ComponentAccess
SuspiciousStewEffects
Returns: The new instance with the modified data.
Parameters:
suspiciousStewEffects: SuspiciousStewEffects
Type: SuspiciousStewEffects
Return Type:
ComponentAccess
Tool
instance is constructed from the parameters.Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
Tool
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
ArmorTrim
Returns: The new instance with the modified data.
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
showInTooltip: bool
(optional) Type: bool
- Whether to show that the ComponentAccess is unbreakable in a tooltip.
Default Value: true
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
Return Type:
ComponentAccess
Returns: The new instance with the modified data.
Parameters:
pages: List<Filterable<string>>
Type: List<Filterable<string>>
Return Type:
ComponentAccess
WritableBookContent
Returns: The new instance with the modified data.
Parameters:
content: WritableBookContent
Type: WritableBookContent
Return Type:
ComponentAccess
WrittenBookContent
Returns: The new instance with the modified data.
Parameters:
content: WrittenBookContent
Type: WrittenBookContent
Return Type:
ComponentAccess
Return Type:
WritableBookContent
Return Type:
WrittenBookContent