ParkerMC Posted December 26, 2019 Posted December 26, 2019 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! Quote
ParkerMC Posted December 26, 2019 Author Posted December 26, 2019 (edited) I tried World#loadedEntityList first but it had the same issue I have now. So then I switch to what I have now (I got the code from World#getEntitiesWithinAABB and just removed the AABB code). I agree it is usually a bad idea but I basically need to update every villager. I can update all the ones not loaded by using when they load with EntityJoinWorldEvent but I need to update the ones already loaded. Edited December 27, 2019 by DaemonUmbra Fixed Formatting Quote
Cadiboo Posted December 26, 2019 Posted December 26, 2019 You can attach IntelliJ’s debugger to non-development minecraft and debug it. Eclipse might have something similar 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
ParkerMC Posted December 27, 2019 Author Posted December 27, 2019 Thanks for the help both of y'all. Turns out I had the world object of a different dimension than the overworld and now that I changed that it is fixed. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.