本文整理了Java中net.minecraft.util.JsonUtils.getItem()
方法的一些代码示例,展示了JsonUtils.getItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonUtils.getItem()
方法的具体详情如下:
包路径:net.minecraft.util.JsonUtils
类名称:JsonUtils
方法名:getItem
暂无
代码示例来源:origin: PenguinSquad/Harvest-Festival
public Obtained deserialize(JsonObject json, JsonDeserializationContext context) {
return new Obtained(JsonUtils.getItem(json, "item"), JsonUtils.getInt(json, "meta", 0));
}
}
代码示例来源:origin: ForestryMC/ForestryMC
public static ItemStack deserializeItemStack(JsonObject object, ItemStack fallback, boolean logError) {
if (!object.has("item")) {
if (logError) {
Log.error("Unsupported icon type, currently only items are supported (add 'item' key)");
}
return fallback;
}
try {
Item item = net.minecraft.util.JsonUtils.getItem(object, "item");
int meta = net.minecraft.util.JsonUtils.getInt(object, "data", 0);
ItemStack stack = new ItemStack(item, 1, meta);
stack.setTagCompound(JsonUtils.readNBT(object, "nbt"));
return stack;
} catch (JsonSyntaxException e) {
if (logError) {
Log.trace("Filed to parse item.", e);
}
return fallback;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!