public GenericStructureInfo structureInfoFromZip(ZipInputStream zipInputStream)
      throws StructureLoadException {
    try {
      String json = null;
      NBTTagCompound worldData = null;

      ZipEntry zipEntry;

      while ((zipEntry = zipInputStream.getNextEntry()) != null) {
        byte[] bytes = completeByteArray(zipInputStream);

        if (bytes != null) {
          if (STRUCTURE_INFO_JSON_FILENAME.equals(zipEntry.getName())) json = new String(bytes);
          else if (WORLD_DATA_NBT_FILENAME.equals(zipEntry.getName()))
            worldData = CompressedStreamTools.func_152457_a(bytes, NBTSizeTracker.field_152451_a);
        }

        zipInputStream.closeEntry();
      }
      zipInputStream.close();

      if (json == null || worldData == null)
        throw new StructureInvalidZipException(json != null, worldData != null);

      GenericStructureInfo genericStructureInfo = registry.createStructureFromJSON(json);
      genericStructureInfo.worldDataCompound = worldData;

      return genericStructureInfo;
    } catch (IOException e) {
      throw new StructureLoadException(e);
    }
  }
Exemplo n.º 2
0
  public static NBTTagCompound getNBTFromBase64(String elementString) {
    byte[] nbtBytes = DatatypeConverter.parseBase64Binary(elementString);

    try {
      return CompressedStreamTools.func_152457_a(nbtBytes, NBTSizeTracker.field_152451_a);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
  }
Exemplo n.º 3
0
  public static NBTTagCompound readNBTTagCompound(ByteBuf fullBuffer) throws IOException {
    short short1 = fullBuffer.readShort(); // par0DataInput.readShort();

    if (short1 < 0) {
      return null;
    } else {
      byte[] abyte = new byte[short1];
      fullBuffer.readBytes(abyte);
      return CompressedStreamTools.func_152457_a(abyte, new NBTSizeTracker(2097152L));
      // return CompressedStreamTools.decompress(abyte);
    }
  }
  @RPC(RPCSide.CLIENT)
  public void downloadBlueprintToClient(BlueprintId id, byte[] data) {
    try {
      NBTTagCompound nbt = CompressedStreamTools.func_152457_a(data, NBTSizeTracker.field_152451_a);
      BlueprintBase bpt = BlueprintBase.loadBluePrint(nbt);
      bpt.setData(data);
      bpt.id = id;

      BuildCraftBuilders.clientDB.add(bpt);
      setCurrentPage(BuildCraftBuilders.clientDB.getPage(pageId));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @RPC(RPCSide.SERVER)
  public void uploadBlueprintToServer(BlueprintId id, byte[] data) {
    try {
      if (data != null) {
        NBTTagCompound nbt =
            CompressedStreamTools.func_152457_a(data, NBTSizeTracker.field_152451_a);
        BlueprintBase bpt = BlueprintBase.loadBluePrint(nbt);
        bpt.setData(data);
        bpt.id = id;
        BuildCraftBuilders.serverDB.add(bpt);
        setInventorySlotContents(3, bpt.getStack());
      } else {
        setInventorySlotContents(3, getStackInSlot(2));
      }

      setInventorySlotContents(2, null);

      downloadingPlayer = null;
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }