Cuberite Forum
ForEachEntity - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: ForEachEntity (/thread-860.html)



ForEachEntity - NiLSPACE - 04-21-2013

i was thinking since there is no World:ForEachEntity anymore becouse of the per-chunk entity ticking maybe there could be a World:ForEachChunk and a Chunk:ForEachEntity. or would this be realy slow?


RE: ForEachEntity - xoft - 04-21-2013

cWorld:ForEachEntity() has been kept and should work alright. And I'm a bit skeptical about exporting chunks - usually you don't need them, you need something a bit more high-level, so why not implement the higher level function optimized? Also, with chunks, one needs to be extra careful not to break any relations between them.


RE: ForEachEntity - NiLSPACE - 04-21-2013

what is a higher level function?


RE: ForEachEntity - xoft - 04-21-2013

Usually you want to do something with the chunk, for example "make an explosion". So "MakeAnExplosion" would be a higher level function, while "GetChunk, DigBlock, SetBlock" would be the lower level functions which you could use for the same purpose. Naturally, higher level functions are easier to use, but are not so universal. They are good because usually they can be more optimized.


RE: ForEachEntity - NiLSPACE - 05-02-2013

Are mobs also counted as Entitys by ForEachEntity? becouse i spawned a bunch of mobs and then i let the server do print( i ) i = i + 1 but it only printed like 2 times.


RE: ForEachEntity - xoft - 05-02-2013

Everything should be counted, but only in the loaded chunks.