mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 06:24:29 +01:00
Created Attaching TileEntity Behaviours (markdown)
parent
c003df5c0a
commit
a012f68df2
16
Attaching-TileEntity-Behaviours.md
Normal file
16
Attaching-TileEntity-Behaviours.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
### TileEntityBehaviourEvent
|
||||||
|
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:
|
||||||
|
```java
|
||||||
|
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
|
||||||
|
|
||||||
|
* 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.
|
Loading…
Reference in New Issue
Block a user