Open Terrain Generator (OTG)

Open Terrain Generator (OTG)

9M Downloads

Request - Getting biome name or ID for an OTG biome

robotnikthingy opened this issue ยท 19 comments

commented

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.

commented

/otg biome
or
/otg tp [biome_ID]
(that one teleports you to the nearest instance of biome X)

commented

That is a player command, not a Java method for a plugin to use.

commented

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

commented

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.

commented

Hey @bloodmc, do you know this offhand?

commented

@rutgerkok If you know the method TC (and therefore OTG) uses for this, could you chime in real quick?

commented

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.

commented

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.

commented

Will that method return the name of the custom biome? I assume it would be the name of the biomes config file?

commented

The name is just block.getBiome().toString(). Getting the biome id is only possible through internal Minecraft code.

commented

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.

commented

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.

commented

@rutgerkok, is there a way to use the virtual biome names from OTG/TC, rather than the ReplaceToBiomeName results?

commented

@rutgerkok

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

commented

@PG85 Since the TC method appears to be missing from OTG, I think this might be a question for you?

commented

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();
    }

https://github.com/MCTCP/TerrainControl/blob/f590de40cdc9e80a6b1e9bff76d36cb785411727/common/src/main/java/com/khorn/terraincontrol/TerrainControl.java

https://github.com/PG85/OpenTerrainGenerator/blob/1.12-OTG%2B/common/src/main/java/com/pg85/otg/OTG.java

commented

Thanks, will re-add this. Was probably removed because it wasn't being used anywhere in the code.

commented

Awesome. Feel free to tag when you have a test build, and @robotnikthingy and I can test implementation.

commented

Sorry for the late response, added this a long time ago, probably for v6 already. To be sure, you can grab v7 or v8 from the OTG discord at #openterraingen.