Esempio n. 1
0
 public int onUpdate(int type) {
   if (type == Level.BLOCK_UPDATE_NORMAL) {
     if (this.getSide(0).isTransparent()) {
       this.getLevel().useBreakOn(this);
       return Level.BLOCK_UPDATE_NORMAL;
     }
   } else if (type == Level.BLOCK_UPDATE_RANDOM) { // Growth
     if (new NukkitRandom().nextRange(1, 7) == 1) {
       if ((this.meta & 0x08) == 0x08) {
         ObjectTree.growTree(
             this.getLevel(),
             (int) this.x,
             (int) this.y,
             (int) this.z,
             new NukkitRandom(),
             this.meta & 0x07);
       } else {
         this.meta |= 0x08;
         this.getLevel().setBlock(this, this, true);
         return Level.BLOCK_UPDATE_RANDOM;
       }
     } else {
       return Level.BLOCK_UPDATE_RANDOM;
     }
   }
   return 1;
 }
Esempio n. 2
0
  public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { // BoneMeal
      ObjectTree.growTree(
          this.getLevel(),
          (int) this.x,
          (int) this.y,
          (int) this.z,
          new NukkitRandom(),
          this.meta & 0x07);
      if ((player.gamemode & 0x01) == 0) {
        item.count--;
      }

      return true;
    }
    this.getLevel().loadChunk((int) this.x >> 4, (int) this.z >> 4);
    return false;
  }