I am attempting to find a combination of events that allow tracking each valid block with particular components in the world. This will enable integrating with the BlockNetwork module and allow adding blocks to the in memory network.
Currently I have hooked up to these events:
OnActivatedBlocks which notifies of blocks entering the world through chunk loading.
OnActivatedComponent which should notify when blocks are placed in the world
There is odd behavior in that after I destroy a block, the BeforeDeactivateComponent fires, and then right afterwards an OnActivatedComponent fires. Upon closer inspection, the second OnActivatedComponent is triggered in EntityAwareWorldProvider.cleanUpTemporaryEntity(...).
This behavior causes the locally cached set of network nodes to get confused as it does not know how to distinguish between a real entity that is valid in the world, and a temporary one.
Is this set of events the correct way to track valid blocks in the world?
Currently I have hooked up to these events:
OnActivatedBlocks which notifies of blocks entering the world through chunk loading.
Code:
@ReceiveEvent
public void createNetworkNodesOnWorldLoad(OnActivatedBlocks event, EntityRef blockType, BlockNetworkNodeComponent blockNetworkNode) {
// add all these blocks to the list of valid network nodes
}
@ReceiveEvent
public void removeNetworkNodesOnWorldUnload(BeforeDeactivateBlocks event, EntityRef blockType, BlockNetworkNodeComponent blockNetworkNode) {
// remove all these blocks from the list of valid network nodes
}
Code:
@ReceiveEvent
public void createNetworkNode(OnActivatedComponent event, EntityRef entity, BlockNetworkNodeComponent blockNetworkNode, BlockComponent block) {
// add all this block to the list of valid network nodes
}
@ReceiveEvent
public void removeNetworkNode(BeforeDeactivateComponent event, EntityRef entity, BlockNetworkNodeComponent blockNetworkNode, BlockComponent block) {
// remove this block from the list of valid network nodes
}
There is odd behavior in that after I destroy a block, the BeforeDeactivateComponent fires, and then right afterwards an OnActivatedComponent fires. Upon closer inspection, the second OnActivatedComponent is triggered in EntityAwareWorldProvider.cleanUpTemporaryEntity(...).
This behavior causes the locally cached set of network nodes to get confused as it does not know how to distinguish between a real entity that is valid in the world, and a temporary one.
Is this set of events the correct way to track valid blocks in the world?