Jump to content

[1.12.2] Can't get all loaded entities when out of development environment


ParkerMC

Recommended Posts

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!

Link to comment
Share on other sites

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 by DaemonUmbra
Fixed Formatting
Link to comment
Share on other sites

You can attach IntelliJ’s debugger to non-development minecraft and debug it. Eclipse might have something similar

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.