I am currently working on a mod in 1.12.2 where I need to loop through a list of all loaded entities in the world.
The code works perfectly when running it in eclipse but as when I run it by itself in forge outside of the development environment I do not get any entities printed. I have ruled out it being an issue with sides because it works fine when running both the server and client in eclipse. Is there something I'm missing?
Code:
FMLLog.log.info("Looking for entities... isRemote: %b", world.isRemote);
for(Chunk c : ((WorldServer)this.world).getChunkProvider().getLoadedChunks()) {
for(ClassInheritanceMultiMap<Entity> list : c.getEntityLists()) {
if (!list.isEmpty()){
for (Entity entity : list){
FMLLog.log.info(entity.getClass().toString());
// More code
}
}
}
}
}
In dev environment:
[19:56:46] [Server thread/INFO] [FML]: Looking for entities... isRemote: %b
[19:56:46] [Server thread/INFO] [FML]: class net.minecraft.entity.passive.EntityVillager
[19:56:46] [Server thread/INFO] [FML]: class net.minecraft.entity.passive.EntitySquid
[19:56:46] [Server thread/INFO] [FML]: class net.minecraft.entity.passive.EntitySquid
...
Outside of dev environment: (only the one line)
[19:54:39] [Server thread/INFO] [FML]: Looking for entities... isRemote: false
Thanks!