11-22-2013, 08:14 AM
(11-22-2013, 07:18 AM)xoft Wrote: I fear that such a hook would seriously affect the server performance - it would be called several thousand times per tick (there are about 50 ticked blocks per loaded chunk per tick; a player normally loads 19*19 chunks -> 18k hook calls per player). We might have to accept that *some* kinds of plugins are just unreachable with current architecture.
Perhaps it's possible when calling a hook just once and supply a list of ticked blocks. This could require storing the ticked blocks. I'm not sure how much performance that costs but since there's a fixed amount of block ticks each server tick it could be stored in a fixed size array which should be pretty fast.
If you want to make mossy cobblestone grow I don't think this is the appropriate way to do it though, Lua is simply too slow to handle 18k block checks per tick. A more suitable way without needing the random tick hook would be inspecting each loaded chunk once and storing each (potentially growable) mossy cobblestone block after which the plugin manually selects a random stored block each tick to grow.