コード例 #1
0
  /**
   * Drawbacks: - The instrument doesn't work - forge sets it itself on function run.
   *
   * @throws IllegalArgumentException - if the instrument is invalid
   */
  public boolean play(Instrument instrument, Note note) throws IllegalArgumentException {
    Block block = getBlock();

    synchronized (block) {
      if (block.getType() == Material.NOTE_BLOCK) {
        // BlockNote nb = (BlockNote) block;
        TileEntityNote t =
            (TileEntityNote)
                ((BukkitWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
        byte oldNote = t.note;
        t.note = note.getId();
        net.minecraft.src.Block targ;
        switch (instrument.getType()) {
          case 1:
            targ = net.minecraft.src.Block.stone;
            break;
          case 2:
            targ = net.minecraft.src.Block.sand;
            break;
          case 4:
            targ = net.minecraft.src.Block.wood;
            break;
          case 3:
            targ = net.minecraft.src.Block.glass;
            break;
          default:
            throw new IllegalArgumentException("Invalid instrument: " + instrument.getType());
        }
        ((BukkitWorld) block.getWorld())
            .getHandle()
            .setBlock(getX(), getY() - 1, getZ(), targ.blockID);
        t.triggerNote(((BukkitWorld) block.getWorld()).getHandle(), getX(), getY(), getZ());
        t.note = oldNote;
        // world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(),
        // instrument.getType(), note.getId());
        return true;
      } else {
        return false;
      }
    }
  }
コード例 #2
0
  public boolean play() {
    Block block = getBlock();

    synchronized (block) {
      if (block.getType() == Material.NOTE_BLOCK) {
        note.triggerNote(world.getHandle(), getX(), getY(), getZ());
        return true;
      } else {
        return false;
      }
    }
  }
コード例 #3
0
 public void setRawNote(byte n) {
   note.note = n;
 }
コード例 #4
0
 public void setNote(Note n) {
   note.note = n.getId();
 }