Clarification on World.GetEntities()?

Discussion in 'Plugin Development' started by ryanhamshire, Jun 2, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    ryanhamshire

    Hey guys does anyone know whether world.getentities() gets ALL the entities, or only those in the chunks which are currently loaded? I need to scan all entities in the world, even in unloaded chunks because I'm doing an automated cleanup task on a creative mode server.
     
  2. It gets all loaded entities because it would be *very* unefficient to load all unloaded chunks whenever someone uses getEntities()... so yeah, you'd have to do it manually if you *really* want that, but do it SLOWLY because it would lag severely.... a sync task to load them a few per tick or even per second would be great.

    Still, what exacly do you need it for ?
     
    thebiologist13 likes this.
  3. Offline

    ryanhamshire

    I think what I'll do, then, is to just scan all of the loaded entities more often, rather than try to scan every entity in existence less often. I'm thinking that if an entity isn't loaded, it's neither lagging the server nor bothering any players, so no harm done and it doesn't need cleanup.

    I'm the GriefPrevention dev. In creative worlds, people like to make messes with minecarts and spawned living entities. I'm just doing a regular scan for obvious griefs and automatically cleaning them up.
     
  4. Yes you surely don't need to mess with stuff that's not loaded.

    I belive you can hook the spawn event of each particular entity and see if you really want them to spawn (I'm unsure if it triggers when the entity is loaded from a chunk tough).
     
Thread Status:
Not open for further replies.

Share This Page