本文整理汇总了Java中codechicken.lib.inventory.InventoryUtils.savePersistant方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryUtils.savePersistant方法的具体用法?Java InventoryUtils.savePersistant怎么用?Java InventoryUtils.savePersistant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codechicken.lib.inventory.InventoryUtils
的用法示例。
在下文中一共展示了InventoryUtils.savePersistant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveBannedItems
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public static void saveBannedItems() {
File file = new File(saveDir, "banneditems.cfg");
try {
if(!file.exists())
file.createNewFile();
PrintWriter p = new PrintWriter(file);
p.println("#Saved in this format for external editing. The format isn't that hard to figure out. If you think you're up to it, modify it here!");
for (ItemStackMap.Entry<Set<String>> entry : bannedItems.entries()) {
NBTTagCompound key = InventoryUtils.savePersistant(entry.key, new NBTTagCompound());
key.removeTag("Count");
if(key.getByte("Damage") == 0) key.removeTag("Damage");
p.print(key.toString());
p.print("=[");
int i = 0;
for (String s : entry.value) {
if(i++ != 0) p.print(", ");
p.print(s);
}
p.println("]");
}
p.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: saveBannedItems
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public static void saveBannedItems() {
File file = new File(saveDir, "banneditems.cfg");
try {
if (!file.exists()) {
file.createNewFile();
}
PrintWriter p = new PrintWriter(file);
p.println("#Saved in this format for external editing. The format isn't that hard to figure out. If you think you're up to it, modify it here!");
for (ItemStackMap.Entry<Set<String>> entry : bannedItems.entries()) {
NBTTagCompound key = InventoryUtils.savePersistant(entry.key, new NBTTagCompound());
key.removeTag("Count");
if (key.getByte("Damage") == 0) {
key.removeTag("Damage");
}
p.print(key.toString());
p.print("=[");
int i = 0;
for (String s : entry.value) {
if (i++ != 0) {
p.print(", ");
}
p.print(s);
}
p.println("]");
}
p.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}