Request - Getting biome name or ID for an OTG biome
robotnikthingy opened this issue ยท 19 comments
So basically I need my Spigot plugin to be able to tell if a Location is within a custom biome created by Open Terrain Generator.
I was wondering if OTG had an API which would allow me to do this, or if there was any other way of getting the biome name of a custom biome.
/otg biome
or
/otg tp [biome_ID]
(that one teleports you to the nearest instance of biome X)
Turns out there is not a method in the spigot API either for getting the ID of the biome either, so im kinda stuck on this
Hey, for Forge I could tell you, for Spigot unfortunately I don't know. You might have better luck asking bloodmc (this repo is forked from his) or rutgerkok (terraincontrol dev). I'll be diving into the bukkit/spigot part of OTG more in the future, that may take a little while longer though.
Hey @bloodmc, do you know this offhand?
@rutgerkok If you know the method TC (and therefore OTG) uses for this, could you chime in real quick?
You can create a java.util.Set<org.bukkit.block.Biome>
of all vanilla biomes, and check whether the biome at a location is in that set. If not, you know it is a custom biome.
Do you know how to get the ID or name of the current biome, though? This is for a whitelist in a plugin that pastes worldedit schematics in biomes as the world generates.
Will that method return the name of the custom biome? I assume it would be the name of the biomes config file?
The name is just block.getBiome().toString()
. Getting the biome id is only possible through internal Minecraft code.
I think that should work! @robotnikthingy, feel free to PM me a test build. It might be helpful to leave a code snippet here for others to reference in the future once it's working.
Yeah, it will return the name of custom biomes, but chaned to UPPERCASE. TerrainControl uses some hacks to add new values to the Biome enum.
@rutgerkok, is there a way to use the virtual biome names from OTG/TC, rather than the ReplaceToBiomeName results?
It actually just seems to return vanilla biome names when trying to get the biome name from a location in an OTG world
TerrainControl had a method for getting the name of a custom biome
https://github.com/MCTCP/TerrainControl/wiki/Developer-page
But I cant seem to find that method anywhere in the OTG code, so do you have a similar method for getting the name of a custom biome
@PG85 Since the TC method appears to be missing from OTG, I think this might be a question for you?
These lines are just flat missing from OTG.java. Why?
* Convienence method to quickly get the biome name at the given
* coordinates. Will return null if the world isn't loaded by Terrain
* Control.
* <p>
* @param worldName The world name.
* @param x The block x in the world.
* @param z The block z in the world.
* @return The biome name, or null if the world isn't managed by Terrain
* Control.
*/
public static String getBiomeName(String worldName, int x, int z)
{
LocalWorld world = getWorld(worldName);
if (world == null)
{
// World isn't loaded by Terrain Control
return null;
}
return world.getSavedBiome(x, z).getName();
}
Thanks, will re-add this. Was probably removed because it wasn't being used anywhere in the code.
Awesome. Feel free to tag when you have a test build, and @robotnikthingy and I can test implementation.