Ejemplo n.º 1
0
  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();
    }
  }
Ejemplo n.º 2
0
  public static NBTTagCompound getCacheCompound() {
    File cache = null;

    try {
      cache = getCacheFile();
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (cache == null) throw new RuntimeException("No cache file!");

    try {
      NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache));
      return cmp;
    } catch (IOException e) {
      NBTTagCompound cmp = new NBTTagCompound();

      try {
        CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache));
        return getCacheCompound();
      } catch (IOException e1) {
        e1.printStackTrace();
        return null;
      }
    }
  }
Ejemplo n.º 3
0
 public static void injectNBTToFile(File file, NBTTagCompound cmp) {
   try {
     CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(file));
   } catch (IOException e) {
     GuiDevTools.logThrowable(e);
   }
 }
Ejemplo n.º 4
0
 public static void injectNBTToFile(NBTTagCompound cmp) {
   try {
     File f = getCacheFile();
     CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  // api
  public PacketNEIRecipe(NBTTagCompound recipe) throws IOException {
    ByteBuf data = Unpooled.buffer();

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream outputStream = new DataOutputStream(bytes);

    data.writeInt(this.getPacketID());

    CompressedStreamTools.writeCompressed(recipe, outputStream);
    data.writeBytes(bytes.toByteArray());

    this.configureWrite(data);
  }
  private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
    System.out.println("[ShipScanner] Filename: " + fileName);

    try {
      File file = new File(fileName);
      if (!file.exists()) {
        file.createNewFile();
      }

      FileOutputStream fileoutputstream = new FileOutputStream(file);

      CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);

      fileoutputstream.close();
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }
Ejemplo n.º 7
0
  private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
    WarpDrive.logger.info(this + " Filename: " + fileName);

    try {
      File file = new File(fileName);
      if (!file.exists()) {
        file.createNewFile();
      }

      FileOutputStream fileoutputstream = new FileOutputStream(file);

      CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);

      fileoutputstream.close();
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }
Ejemplo n.º 8
0
  public static NBTTagCompound getCacheCompound(File file) {
    if (file == null) throw new RuntimeException("No cache file!");

    try {
      NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(file));
      return cmp;
    } catch (IOException e) {
      NBTTagCompound cmp = new NBTTagCompound();

      try {
        CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(file));
        return getCacheCompound(file);
      } catch (IOException e1) {
        GuiDevTools.logThrowable(e1);
        return null;
      }
    }
  }
Ejemplo n.º 9
0
 public static void writeNBT(NBTTagCompound tag, File file) throws IOException {
   FileOutputStream out = new FileOutputStream(file);
   CompressedStreamTools.writeCompressed(tag, out);
   out.close();
 }