/** * Loads a tag from the file. * * @param file * @return tag * @throws IOException */ public static NBTTagCompound load(File file) throws IOException { DataInputStream dis = NbtUtils.getDataInput(file); NBTTagCompound tag = null; try { Method method = NBTCompressedStreamTools.class.getDeclaredMethod( "a", DataInput.class, int.class, NBTReadLimiter.class); method.setAccessible(true); tag = (NBTTagCompound) method.invoke(null, dis, 0, new NBTReadLimiter(Long.MAX_VALUE)); } catch (Exception e) { e.printStackTrace(); } dis.close(); return tag; }
/** * Loads items from the tag to the inventory. * * @param inventory * @param tag */ public static void loadInventory(Inventory inventory, NBTTagCompound tag) { NbtUtils.loadInventory(((CraftInventory) inventory).getInventory(), tag); }