-
Notifications
You must be signed in to change notification settings - Fork 7
Adding Components to a Block Based Item
To make sure a Component specified in a prefab gets added to the block-item representing a block simply, add the @AddToBlockbasedItem
annotation to the Component class:
@AddToBlockBasedItem
public class SpecialBlockComponent implements Component {
}
This makes it so that if you have a prefab like the following:
{
"SpecialBlock": {}
}
The SpecialBlockComponent
will be added to the block-item entity (held in the hand, inventory, hotbar, etc) as well as the block entity which exists in the world.
Components generally do not need to be applied to the block-item. The exception is when you are listening to item events, such as the one triggered when when the user tries to place a block.
For example, say you wanted people to be able to place flowers in a pot (in addition to on the ground). You would need a FlowerComponent
to be applied to the block-item so you can detect when the user is trying to place a flower.