Started by
mzage31
on
Topic category: Help with Minecraft modding (Java Edition)
I'm using MCreator 2021.2 to create a Mod that shows coordinates and current biome on the top of the screen. I found this mod batty-UI on GitHub but it operates on old versions of Minecraft and I want my mod to operate on version 1.16.5 of Minecraft.
It looks like there was a function defined as getBiomeName()
inside the Biome class, But it appears to be removed. I want an equivalent to the following code in 1.16.5 version:
World _world = entity.world;
String _biome = "???";
BlockPos myBlock = new BlockPos(_x, _y, _z);
if(_world != null && _world.isBlockLoaded(myBlock)){
Chunk myChunk = _world.getChunkFromBlockCoords(myBlock);
_biome = myChunk.getBiome(myBlock, _world.getBiomeProvider()).getBiomeName();
}
This is the code I wrote, But it only works in single player:
World _world = entity.world;
String _biome = "???";
Biome biome = _world.getBiome(new BlockPos(_x, _y, _z));
if(biome != null){
ResourceLocation regName = biome.getRegistryName();
if(regName != null){ //getRegistryName() returns null in multiplayer mode
_biome = regName.getPath();
_biome = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, _biome);
}
}
Also, this is the document I'm currently using, If there are any better documents out there, please let me know.
I really need this to be working, Any help would be appreciated. Thanks in advance