I'm working on "blockNetwork" and "signalling" mods. First one is a library-mod that helps developing new mods that require a network of blocks. If you ever played Minecraft - think of Buildcraft pipes, IC2 cables, etc. Second one is an example use of the "blockNetwork", which allows sending signals from one place in the block network to another - similar to redstone in Minecraft.
To be able to detect changes in the network, I've added event listeners in my SignalSystem class and I'm listening on Add/Changed/RemovedComponentEvent.
Now, imagine I have a block, that I want to change color and emit light, when it receives the signal - basically a lamp. Once my mod detects that this block is connected to powered network, it sets its property "isPowered=true".
In a LampSystem that knows what the lamp should do, now I need to change the look of the lamp, when the "isPowered" is changed to true. I was told, that the only way to do that is to replace the block with some other block. However, if I do that in my LampSystem, it will once again fire SignalSystem's event handlers, which in turn once again will set the property for the block, and so on...
I don't think replacing a block with another one is a clean solution, and will most definitely not fit all reasonable scenarios.
A few ideas - a block might have multiple textures/settings associated with it and code can modify some pre-defined property of the block/BlockComponent to define, which textures/settings should be used.
To be able to detect changes in the network, I've added event listeners in my SignalSystem class and I'm listening on Add/Changed/RemovedComponentEvent.
Now, imagine I have a block, that I want to change color and emit light, when it receives the signal - basically a lamp. Once my mod detects that this block is connected to powered network, it sets its property "isPowered=true".
In a LampSystem that knows what the lamp should do, now I need to change the look of the lamp, when the "isPowered" is changed to true. I was told, that the only way to do that is to replace the block with some other block. However, if I do that in my LampSystem, it will once again fire SignalSystem's event handlers, which in turn once again will set the property for the block, and so on...
I don't think replacing a block with another one is a clean solution, and will most definitely not fit all reasonable scenarios.
A few ideas - a block might have multiple textures/settings associated with it and code can modify some pre-defined property of the block/BlockComponent to define, which textures/settings should be used.