Пример #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 void playNote(Location loc, Instrument instrument, Note note) {
    if (getHandle().playerNetServerHandler == null) return;

    int id = getHandle().worldObj.getBlockId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .playerNetServerHandler
        .sendPacketToPlayer(
            new Packet54PlayNoteBlock(
                loc.getBlockX(),
                loc.getBlockY(),
                loc.getBlockZ(),
                id,
                instrument.getType(),
                note.getId()));
  }
Пример #3
0
  public void playNote(Location loc, Instrument instrument, Note note) {
    if (getHandle().field_71135_a == null) return;

    int id =
        getHandle().field_70170_p.func_72798_a(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .field_71135_a
        .func_72567_b(
            new net.minecraft.network.packet.Packet54PlayNoteBlock(
                loc.getBlockX(),
                loc.getBlockY(),
                loc.getBlockZ(),
                id,
                instrument.getType(),
                note.getId()));
  }
 /**
  * Set the instrument type.
  *
  * @param value - new instrument type.
  */
 @SuppressWarnings("deprecation")
 public void setInstrument(Instrument value) {
   setByte1(value.getType());
 }
Пример #5
0
 @Override
 public boolean play(Instrument instrument, Note note) {
   return play(instrument.getType(), note.getId());
 }