Posted March 9, 20187 yr 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 March 9, 20187 yr by OsHeaven
March 9, 20187 yr Author 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
March 9, 20187 yr 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.
March 9, 20187 yr 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.
March 9, 20187 yr Author "Are you sure that that is the only entry for "biomeName"?" is sufficient I should have paid attention to your signature... issue fixed, thanks all and have a nice weekend
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.