-
Notifications
You must be signed in to change notification settings - Fork 929
Attaching TileEntity Behaviours
simibubi edited this page Aug 25, 2021
·
2 revisions
Event that is fired just before a SmartTileEntity is being deserealized, alternatively just after it was newly placed. Use it to attach a new TileEntityBehaviour or replace existing ones (with caution)
Example:
forgeEventBus.addGenericListener(FunnelTileEntity.class, (TileEntityBehaviourEvent<FunnelTileEntity> event) -> event
.attach(new FunFunnelBehaviour(event.getTileEntity())));
Will attach the new FunFunnelBehaviour
to any Funnels placed or loaded in
- When loaded from disk, the attached behaviour will be able to read from the tileentities' tag just after it was added. See
TileEntityBehaviour#read()
- The attached behaviour can initialize fully on its first tick. See
TileEntityBehaviour#initialize()
- In
TileEntityBehaviour#write()
, data can be placed into the tag before serialization. That way your custom data will persist until your next read()
Within the event context, make sure the tileentity itself is only used to provide the reference for later. Its level, position and data will not be set at this time.