public void writeToFile(boolean unloadInstances) { try { NBTTagCompound data = new NBTTagCompound(); Collection playerDataCl = grid.values(); Iterator it = playerDataCl.iterator(); while (it.hasNext()) { BlockDataPoint bdp = (BlockDataPoint) it.next(); data.setTag("" + bdp.hash, bdp.writeToNBT()); } String saveFolder = CoroUtilFile.getWorldSaveFolderPath() + CoroUtilFile.getWorldFolderName() + "epoch" + File.separator; // Write out to file if (!(new File(saveFolder).exists())) (new File(saveFolder)).mkdirs(); FileOutputStream fos = new FileOutputStream( saveFolder + "EpochBlockDataDim_" + world.provider.dimensionId + ".dat"); CompressedStreamTools.writeCompressed(data, fos); fos.close(); } catch (Exception ex) { ex.printStackTrace(); } }
public void removeBlockData(int i, int j, int k) { int hash = getHash(i, j, k); if (grid.containsKey(hash)) { // perhaps theres a better memory managed way to clean these objects up? BlockDataPoint bdp = grid.get(hash); bdp.cleanup(); grid.remove(hash); // System.out.println("grid had removal, new size: " + grid.size()); } }
public void readFromFile() { try { String saveFolder = CoroUtilFile.getWorldSaveFolderPath() + CoroUtilFile.getWorldFolderName() + "epoch" + File.separator; if ((new File(saveFolder + "EpochBlockDataDim_" + world.provider.dimensionId + ".dat")) .exists()) { NBTTagCompound data = CompressedStreamTools.readCompressed( new FileInputStream( saveFolder + "EpochBlockDataDim_" + world.provider.dimensionId + ".dat")); // Collection playerDataCl = data.getTags(); Iterator it = data.func_150296_c().iterator(); // playerDataCl.iterator(); while (it.hasNext()) { String keyName = (String) it.next(); NBTTagCompound nbt = data.getCompoundTag(keyName); BlockDataPoint bdp = this.getBlockDataFromNBT( nbt.getInteger("xCoord"), nbt.getInteger("yCoord"), nbt.getInteger("zCoord"), nbt); if (bdp != null) { bdp.readFromNBT(nbt); } else { // must have been set to air at some point... } } } } catch (Exception ex) { ex.printStackTrace(); } }