private NBTBase.NBTPrimitive getIdFromString(JsonElement jsonElement, String type) {
if (jsonElement.isJsonPrimitive()) {
JsonPrimitive jsonPrimitive = jsonElement.getAsJsonPrimitive();
if (jsonPrimitive.isString()) {
final String name = jsonPrimitive.getAsString();
final String[] split = name.split(DELIMITER_ITEM_BLOCK, 2);
int id = -1;
if (split.length == 2) {
if (split[0].equalsIgnoreCase(ID_TYPE_BLOCK)) {
id = GameData.getBlockRegistry().getId(split[1]);
} else if (split[0].equalsIgnoreCase(ID_TYPE_ITEM)) {
id = GameData.getItemRegistry().getId(split[1]);
}
} else {
id = GameData.getBlockRegistry().getId(split[0]);
if (id == -1) {
id = GameData.getItemRegistry().getId(split[0]);
}
}
if (id < 0) {
Reference.logger.fatal(String.format("The block/item %s could not be found!", name));
}
if (type.equalsIgnoreCase(TYPE_SHORT)) {
return new NBTTagShort((short) id);
} else if (type.equalsIgnoreCase(TYPE_INT)) {
return new NBTTagInt(id);
}
}
}
return null;
}
NBTTagCompoundDeserializer.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:DynIMC
作者:
评论列表
文章目录