Jump to content

reflection to get biome name...


OsHeaven

Recommended Posts

hi,

I build a method to get the biome name on server side while world generation:

 

private static String getBiomeName(World world, int chunkX, int chunkZ)
    {
        String biomeName = "unknown";
        Biome biomeInstance = world.getBiome(new BlockPos(chunkX * 16, 0, chunkZ * 16));
        String field = "biomeName";
        try
        {
            Object value = ReflectionHelper.getPrivateValue(Biome.class, biomeInstance, field);
            biomeName = (String) value;
        }
        catch (Exception e)
        {
            Logger.log(Level.ERROR, "Problem loading value from field " + field, e);
        }
        return biomeName;
    }

when i am run mc server/client in my intellj ide everthings is working well, but after compiling in normal minecraft forge, same version like forge mdk, or newer versions, the launcher crashes and the console freezes. sometimes i get infos befor freeze, that says the biomeName field in (Biome.class) does not exist... i dont know how to fix, because in the ide is no issue while running...

 

i am using the biomeName to generate ores in specific biomes (like more gold in vanilla mesa or emeralds in extreme hills)

 

I would be grateful if someone helped me to find out what i am diong wrong using reflection to get the biome name on server side.

 

 

thanks!

 

Edited by OsHeaven
Link to comment
Share on other sites

ok, i get the SRG name from http://export.mcpbot.bspk.rs/ fields.csv (biomeName = field_185412_a)

 now i am using 

 

String[] fieldName = {"biomeName", "field_185412_a"};

Field f = ReflectionHelper.findField(Biome.class, fieldName);

biomeName = (String) f.get(biomeInstance);

 

in the ide everything is fine, in the actual game the launcher dont crashes anymore and log isnt freezing, but still java.lang.NoSuchFieldException: field_185412_a

 

Link to comment
Share on other sites

ReflectionHelper.findField(Biome.class, "biomeName", "field_185412_a" ); is sufficient

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

28 minutes ago, OsHeaven said:

does not change anything
 

I said "this line of code is identical" not "this will fix your problem."

That said, if you get a field not found exception, you have the wrong field name. Are you sure that that is the only entry for "biomeName"?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER web [ ht tps:// muyerntrusthack.solutions/ ] for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m  
    • Do you have still this problem? (I have it too so I want to know if you did something with it)  
    • Thank you very much, the mod worked. I almost destroyed my computer out of anger because I couldn't find the error.
  • Topics

×
×
  • Create New...

Important Information

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