关于模组名称获取
有官方的方法
注意! 这个方法可能出现错误! 请看代码。public void setCurrentMod(@Nullable LoadedMod mod){
this.currentMod = mod;
}
public String transformName(String name){
return currentMod == null ? name : currentMod.name + "-" + name;
}
我的建议是
直接在模组列表中通过你的模组类获取模组名称,这里的名字是直接通过mod.hjson
获取的,所以一定准确。请看代码。
/** @return the loaded mod found by class, or null if not found. */
public @Nullable LoadedMod getMod(Class<? extends Mod> type){
return mods.find(m -> m.main != null && m.main.getClass() == type);
}
上面获取到后可以设为变量
并且使用以下的方法