java - 如何从 Biome 对象中获取生物群落名称?
问题描述
我正在使用MCreator 2021.2创建一个在屏幕顶部显示坐标和当前生物群落的 Mod。我在 GitHub 上找到了这个 mod batty-UI,但它在旧版本的 Minecraft 上运行,我希望我的 mod 在 Minecraft 1.16.5 版本上运行。
看起来getBiomeName()
在 Biome 类中定义了一个函数,但它似乎被删除了。我想要一个等效于 1.16.5 版本中的以下代码:
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();
}
这是我写的代码,但它只适用于单人游戏:
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);
}
}
另外,这是我目前正在使用的文档,如果有更好的文档,请告诉我。
解决方案
推荐阅读
- ef-code-first - System.InvalidOperationException:在 SqlServer 提供程序清单中找不到存储类型“十进制(18,4)”
- node.js - 如何在 Node js 中解析请求
- mysql - 生成表上不存在的随机数,然后在 MySQL 上的 concat 函数上使用它
- php - 无法获得 formated_address 'only in English' 获得区域语言的部分结果
- python-3.x - 加载预训练的词嵌入
- azure-active-directory - Microsoft Graph API 用户和 WindowsIdentity 之间是否有任何联系?
- javascript - 用户地理位置点(蓝点)不再出现在我的 IOS 应用程序上(适用于 Android 应用程序)
- javascript - 如何合并对象数组
- php - Laravel 5:每页中的 DOMPDF(0.8.3) 页眉和页脚
- reactjs - react在哪里声明变量