public MusicBlock(CompoundTag tileEntityData, int type, int data) {
    super(tileEntityData, type, data);

    _note =
        ((ByteTag)
                tileEntityData.getValue().get(MinecraftSchematicTagNames.MusicBlockTagNames.NOTE))
            .getValue();
  }
示例#2
0
  /**
   * Loads NBT data from the given file.
   *
   * @param file File to load from.
   */
  public void load(String file) {
    File f = new File(file);
    if (!f.exists()) {
      if (!f.getParentFile().exists()) {
        f.getParentFile().mkdirs();
      }

      try {
        f.createNewFile();
      } catch (IOException e) {
        OpenClassic.getLogger()
            .severe("Failed to create new file for NBTData " + this.data.getName() + "!");
        e.printStackTrace();
        return;
      }

      return;
    }

    NBTInputStream in = null;

    try {
      in = new NBTInputStream(new FileInputStream(f));
      CompoundTag tag = (CompoundTag) in.readTag();
      this.data.clear();

      for (String name : tag.keySet()) {
        this.data.put(name, tag.get(name));
      }
    } catch (EOFException e) {
      this.data.clear();
      return;
    } catch (IOException e) {
      OpenClassic.getLogger()
          .severe("Failed to open stream for NBTData " + this.data.getName() + "!");
      e.printStackTrace();
      return;
    } finally {
      IOUtils.closeQuietly(in);
    }
  }
示例#3
0
 /**
  * Puts a CompoundTag.
  *
  * @param compound Tag to put.
  * @return The resulting Tag.
  */
 public Tag put(CompoundTag compound) {
   return this.data.put(compound.getName(), compound);
 }