예제 #1
0
 /**
  * Decreases the happiness with an amount calculated from the time since the last update cycle
  * multiplied by a constant (getNeedDecreaseSpeed). Needs to be called every update cycle to
  * calculate correctly.
  */
 void decreaseHappiness() {
   // Calculates the factor of decrease that should be multiplied
   // with the happiness
   float decreaseFactor =
       1 - (World.getEnvironment().getNeedDecreaseSpeed() * World.getWorld().getTimeSinceCycle());
   happiness *= decreaseFactor;
 }
예제 #2
0
  public static boolean SpawnCustomTrees(
      World world, Random rand, WorldConfig worldSettings, int x, int y, int z) {

    if (!worldSettings.HasCustomTrees) return false;

    Chunk chunk = world.getWorld().getChunkAt(x >> 4, z >> 4);

    BiomeBase localBiomeBase =
        world.getWorldChunkManager().getBiome(chunk.getX() * 16 + 16, chunk.getZ() * 16 + 16);

    boolean objectSpawned = false;
    int spawnattemps = 0;
    while (!objectSpawned && spawnattemps < worldSettings.objectSpawnRatio) {
      CustomObject SelectedObject =
          worldSettings.Objects.get(rand.nextInt(worldSettings.Objects.size()));

      spawnattemps++;

      if (SelectedObject.branch
          || !SelectedObject.canSpawnInBiome(localBiomeBase)
          || !SelectedObject.tree) continue;

      int randomRoll = rand.nextInt(100);

      if (randomRoll < SelectedObject.rarity) {
        if (CustomObjectGen.ObjectCanSpawn(world, x, y, z, SelectedObject))
          objectSpawned =
              GenerateCustomObject(world, rand, worldSettings, x, y, z, SelectedObject, true);
      }
    }
    return objectSpawned;
  }
예제 #3
0
 // CraftBukkit start - add method
 public InventoryHolder getOwner() {
   // Spigot start
   org.bukkit.block.Block block = world.getWorld().getBlockAt(x, y, z);
   if (block == null) {
     org.bukkit.Bukkit.getLogger()
         .log(
             java.util.logging.Level.WARNING,
             "No block for owner at %s %d %d %d",
             new Object[] {world.getWorld(), x, y, z});
     return null;
   }
   // Spigot end
   org.bukkit.block.BlockState state = block.getState();
   if (state instanceof InventoryHolder) return (InventoryHolder) state;
   return null;
 }
예제 #4
0
  /** Constructs default characteristics. */
  public Characteristics(int gender, int age) {
    saturation = World.getEnvironment().getDefaultNeedValue();
    happiness = World.getEnvironment().getDefaultNeedValue();
    // The value will be recalculates immideately
    safety = 1.0f;

    // Set up the randomizers
    hungryRandomizer = new IntervalRandomizer(World.getEnvironment().getNeedInterval());
    depressedRandomizer = new IntervalRandomizer(World.getEnvironment().getNeedInterval());
    // TODO Take from Environment.
    unsafeRandomizer = new ProbabilityRandomizer(0.5f);
    strollRandomizer = new IntervalRandomizer(World.getEnvironment().getStrollInterval());

    // Set health, with max health as the full health
    maximumHealth = 1f;
    recalculateHealth();

    this.gender = gender;

    startAge = age;
    timeOfBirth = World.getWorld().getWorldTime();

    gatherSkill = World.getEnvironment().getDefaultSkillValue();
    sacrificeSkill = World.getEnvironment().getDefaultSkillValue();
    transportationSkill = World.getEnvironment().getDefaultSkillValue();
  }
예제 #5
0
 /**
  * Decreases the saturation with an amount calculated from the time since the last update cycle
  * multiplied by a constant (getNeedDecreaseSpeed). Needs to be called every update cycle to
  * calculate correctly.
  */
 void decreaseSaturation() {
   // Calculates the factor of decrease that should be multiplied
   // with the saturation
   float decreaseFactor =
       1 - (World.getEnvironment().getNeedDecreaseSpeed() * World.getWorld().getTimeSinceCycle());
   saturation *= decreaseFactor;
 }
public class ReportHandler implements PacketHandler {
  public static final World world = World.getWorld();

  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    player.getActionSender().sendMessage("Nice try, Bastard.");
  }
}
 /**
  * Loads the item spawn list from xml, and spawns all the item's.
  *
  * @throws IOException
  */
 public static void init() throws IOException {
   logger.info("Loading item spawns...");
   File file = new File("data/itemSpawns.xml");
   //		spawns = new ArrayList<ItemSpawn>();
   //		spawns.add(new ItemSpawn(new Item(223, 1), Location.create(2832, 9585, 0)));
   //		XMLController.writeXML(spawns, file);
   if (file.exists()) {
     spawns = XMLController.readXML(file);
     for (ItemSpawn spawn : spawns) {
       GroundItem groundItem = new GroundItem("", spawn.getItem(), spawn.getLocation());
       World.getWorld().register(groundItem, null);
       spawn.setGroundItem(groundItem);
     }
     World.getWorld().submit(new ItemSpawnTick());
     logger.info("Loaded " + spawns.size() + " item spawns.");
   } else {
     logger.info("Item spawns not found.");
   }
 }
예제 #8
0
 /**
  * Decreases the value of the transportation skill, using a formula containing getTimeSinceCycle
  * and getSkillDecreaseSpeed.
  */
 private void decreaseTransportationSkill() {
   // Decreases the transportation skill with the speed multiplied by the
   // timeSinceCycle, but then modified with a factor of how close
   // the mininimum skill value the current skill is. This means that
   // the skill will never decrease to less than 0f.
   transportationSkill -=
       World.getEnvironment().getSkillDecreaseSpeed()
           * World.getWorld().getTimeSinceCycle()
           * transportationSkill;
 }
예제 #9
0
  public void a(World world, int i, int j, int k, Random random) {
    if (random.nextInt(25) == 0) {
      byte b0 = 4;
      int l = 5;

      int i1;
      int j1;
      int k1;

      for (i1 = i - b0; i1 <= i + b0; ++i1) {
        for (j1 = k - b0; j1 <= k + b0; ++j1) {
          for (k1 = j - 1; k1 <= j + 1; ++k1) {
            if (world.getTypeId(i1, k1, j1) == this.id) {
              --l;
              if (l <= 0) {
                return;
              }
            }
          }
        }
      }

      i1 = i + random.nextInt(3) - 1;
      j1 = j + random.nextInt(2) - random.nextInt(2);
      k1 = k + random.nextInt(3) - 1;

      for (int l1 = 0; l1 < 4; ++l1) {
        if (world.isEmpty(i1, j1, k1) && this.f(world, i1, j1, k1)) {
          i = i1;
          j = j1;
          k = k1;
        }

        i1 = i + random.nextInt(3) - 1;
        j1 = j + random.nextInt(2) - random.nextInt(2);
        k1 = k + random.nextInt(3) - 1;
      }

      if (world.isEmpty(i1, j1, k1) && this.f(world, i1, j1, k1)) {
        // lightstone start
        org.bukkit.World bworld = world.getWorld();
        org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
        blockState.setTypeId(this.id);

        BlockSpreadEvent event =
            new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
        world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
          blockState.update(true);
        }
        // lightstone end
      }
    }
  }
  public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.c();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.e();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(
                isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event =
        new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
      world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
      itemstack.count++;
      return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
      itemstack.count++;
      // Chain to handler for new item
      ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
      IDispenseBehavior idispensebehavior =
          (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
      if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
        idispensebehavior.a(isourceblock, eventStack);
        return itemstack;
      }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
    EntityFireworks entityfireworks =
        new EntityFireworks(
            isourceblock.k(),
            event.getVelocity().getX(),
            event.getVelocity().getY(),
            event.getVelocity().getZ(),
            itemstack1);

    isourceblock.k().addEntity(entityfireworks);
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
  }
예제 #11
0
 /**
  * Sets the safety according to the given Point. The safety is calculated through the distance
  * from the light pillar, with a constant (getSacrificedUnitsDistanceRatio).
  *
  * @param point the Point describing the position of the owner of the characteristics.
  */
 void setSafety(Point point) {
   LightPillarNode lightPillar = World.getWorld().getLightPillar();
   float distance = point.distanceTo(lightPillar.getPoint());
   distance = distance - lightPillar.getInfluenceRadius();
   if (distance > 0) {
     // Decreases the safety (which is 1) with the percentual value
     // that is defined by safetyDecreaseFactor. The decrease is made
     // distance times, so that safety = safetyDecrease ^ distance.
     safety = (float) Math.pow(World.getEnvironment().getSafetyDecreaseFactor(), distance);
   } else {
     safety = 1;
   }
 }
예제 #12
0
  // lightstone - added bonemeal, player and itemstack
  public boolean b(
      World world,
      int i,
      int j,
      int k,
      Random random,
      boolean bonemeal,
      Player player,
      ItemStack itemstack) {
    int l = world.getData(i, j, k);

    world.setRawTypeId(i, j, k, 0);
    // lightstone start
    boolean grown = false;
    StructureGrowEvent event = null;
    Location location = new Location(world.getWorld(), i, j, k);
    WorldGenHugeMushroom worldgenhugemushroom = null;

    if (this.id == Block.BROWN_MUSHROOM.id) {
      event =
          new StructureGrowEvent(
              location, TreeType.BROWN_MUSHROOM, bonemeal, player, new ArrayList<BlockState>());
      worldgenhugemushroom = new WorldGenHugeMushroom(0);
    } else if (this.id == Block.RED_MUSHROOM.id) {
      event =
          new StructureGrowEvent(
              location, TreeType.RED_MUSHROOM, bonemeal, player, new ArrayList<BlockState>());
      worldgenhugemushroom = new WorldGenHugeMushroom(1);
    }
    if (worldgenhugemushroom != null && event != null) {
      grown = worldgenhugemushroom.grow(world, random, i, j, k, event, itemstack, world.getWorld());
    }
    if (!grown || event.isCancelled()) {
      world.setRawTypeIdAndData(i, j, k, this.id, l);
      return false;
    }
    return true;
    // lightstone end
  }
예제 #13
0
  public void b(World world, int i, int j, int k, Random random) {
    if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) {
      // CraftBukkit start
      if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(
              world.getWorld().getBlockAt(i, j, k), 0)
          .isCancelled()) {
        return;
      }
      // CraftBukkit end

      world.setTypeId(i, j, k, 0);
    }
  }
예제 #14
0
  private void l(World world, int i, int j, int k) {
    // CraftBukkit start
    LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(i, j, k));
    world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
      return;
    }
    // CraftBukkit end

    this.c(world, i, j, k, world.getData(i, j, k), 0);
    world.setTypeId(i, j, k, 0);
  }
예제 #15
0
  public void updatePosition() {
    long now = GameEngine.getAccurateTimestamp();
    Player victim = findVictim();

    if (!isBusy() && def.isAggressive() && now - getCombatTimer() > 3000 && victim != null) {
      resetPath();

      victim.resetPath();
      victim.resetAll();
      victim.setStatus(Action.FIGHTING_MOB);
      victim.getActionSender().sendSound("underattack");
      victim.getActionSender().sendMessage("You are under attack!");

      if (victim.isSleeping()) {
        victim.getActionSender().sendWakeUp(false, false);
        victim.getActionSender().sendFatigue(victim.getFatigue());
      }

      this.setLocation(victim.getLocation(), true);

      for (Player p : getViewArea().getPlayersInView()) {
        p.removeWatchedNpc(this);
      }

      victim.setBusy(true);
      victim.setSprite(9);
      victim.setOpponent(this);
      victim.setCombatTimer();

      setBusy(true);
      setSprite(8);
      setOpponent(victim);
      setCombatTimer();
      FightEvent fighting = new FightEvent(victim, this, true);
      fighting.setLastRun(0);
      World.getWorld().getDelayedEventHandler().add(fighting);
    }

    if (now - lastMovement > 2200) {
      lastMovement = now;
      int rand = DataConversions.random(0, 1);
      if (!isBusy() && finishedPath() && rand == 1 && !isRemoved()) {
        int newX = DataConversions.random(loc.minX(), loc.maxX());
        int newY = DataConversions.random(loc.minY(), loc.maxY());
        setPath(new Path(getX(), getY(), newX, newY));
      }
    }

    super.updatePosition();
  }
예제 #16
0
  public void a(World world, int i, int j, int k, Random random) {
    if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) {
      // CraftBukkit start
      if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(
              world.getWorld().getBlockAt(i, j, k), Blocks.AIR)
          .isCancelled()) {
        return;
      }
      // CraftBukkit end

      this.b(world, i, j, k, world.getData(i, j, k), 0);
      world.setAir(i, j, k);
    }
  }
예제 #17
0
  /**
   * Recalculates the health using the mean value of the three needs and the time since the last
   * cycle. Health cannot be greater than the current maximum health, which is decreased constantly
   * with a percentual constant. Needs to be called every update cycle to calculate correctly.
   */
  void recalculateHealth() {
    // Calculates the factor of decrease that should be multiplied
    // with the maximum health
    if (!isChild()) {
      float agingFactor =
          1 - (World.getEnvironment().getAgingFactor() * World.getWorld().getTimeSinceCycle());
      maximumHealth *= agingFactor;
    }

    float newHealth = (saturation + happiness + (safety / 2f)) / 3f;
    if (newHealth > maximumHealth) {
      newHealth = maximumHealth;
    }

    health = newHealth;
  }
예제 #18
0
 /**
  * Increases the value of the transportation skill, using a formula containing getTimeSinceCycle
  * and getSkillIncreaseSpeed.
  */
 public void increaseTransportationSkill() {
   // Children to dont get better or worse in any skills.
   if (!isChild()) {
     // Increases the transportation skill with the speed multiplied by the
     // timeSinceCycle, but then modified with a factor of how close
     // the maximum skill value the current skill is. This means that
     // the skill will never increase to over 1f.
     transportationSkill +=
         World.getEnvironment().getSkillIncreaseSpeed()
             * World.getWorld().getTimeSinceCycle()
             * (1f - transportationSkill);
     // Decrease the other two skills.
     decreaseSacrificeSkill();
     decreaseGatherSkill();
   }
 }
예제 #19
0
  public void remove() {
    Area cur = area.get();
    cur.removeNpc(this);

    if (!isRemoved() && shouldRespawn && def.respawnTime() > 0) {
      World.getWorld()
          .getDelayedEventHandler()
          .add(
              new DelayedEvent(null, def.respawnTime() * 1000) {

                public void run() {
                  world.registerNpc(new Npc(loc));
                  matchRunning = false;
                }
              });
    }

    removed.set(true);
  }
예제 #20
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (world.isClientSide) {
      return true;
    }
    boolean powered = ((Boolean) iblockdata.get(POWERED)).booleanValue();
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    int old = powered ? 15 : 0;
    int current = !powered ? 15 : 0;

    BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
    world.getServer().getPluginManager().callEvent(eventRedstone);
    if ((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1)) {
      return true;
    }
    iblockdata = iblockdata.a(POWERED);
    world.setTypeAndData(blockposition, iblockdata, 3);
    world.makeSound(
        blockposition.getX() + 0.5D,
        blockposition.getY() + 0.5D,
        blockposition.getZ() + 0.5D,
        "random.click",
        0.3F,
        ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0.6F : 0.5F);
    world.applyPhysics(blockposition, this);
    EnumDirection enumdirection1 = ((EnumLeverPosition) iblockdata.get(FACING)).c();

    world.applyPhysics(blockposition.shift(enumdirection1.opposite()), this);
    return true;
  }
예제 #21
0
  public void setChasing(Player player) {

    this.chasing = player;
    goingToAttack = true;

    if (player == null) {
      this.chasing = null;
      goingToAttack = false;
      return;
    }

    chaseTimeout =
        new DelayedEvent(null, 15000) {

          public void run() {
            goingToAttack = false;
            setChasing(null);
            matchRunning = false;
          }
        };

    World.getWorld().getDelayedEventHandler().add(chaseTimeout);
  }
예제 #22
0
  private void k(World world, int i, int j, int k) {
    int l = world.getData(i, j, k);
    boolean flag = (l & 1) == 1;
    boolean flag1 = false;
    List list =
        world.getEntities(
            (Entity) null,
            AxisAlignedBB.a()
                .a(
                    (double) i + this.minX,
                    (double) j + this.minY,
                    (double) k + this.minZ,
                    (double) i + this.maxX,
                    (double) j + this.maxY,
                    (double) k + this.maxZ));

    if (!list.isEmpty()) {
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        Entity entity = (Entity) iterator.next();

        if (!entity.at()) {
          flag1 = true;
          break;
        }
      }
    }

    // CraftBukkit start - Call interact even when triggering connected tripwire
    if (flag != flag1 && flag1 && (world.getData(i, j, k) & 4) == 4) {
      org.bukkit.World bworld = world.getWorld();
      org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
      org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
      boolean allowed = false;

      // If all of the events are cancelled block the tripwire trigger, else allow
      for (Object object : list) {
        if (object != null) {
          org.bukkit.event.Cancellable cancellable;

          if (object instanceof EntityHuman) {
            cancellable =
                org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(
                    (EntityHuman) object,
                    org.bukkit.event.block.Action.PHYSICAL,
                    i,
                    j,
                    k,
                    -1,
                    null);
          } else if (object instanceof Entity) {
            cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
            manager.callEvent((EntityInteractEvent) cancellable);
          } else {
            continue;
          }

          if (!cancellable.isCancelled()) {
            allowed = true;
            break;
          }
        }
      }

      if (!allowed) {
        return;
      }
    }
    // CraftBukkit end

    if (flag1 && !flag) {
      l |= 1;
    }

    if (!flag1 && flag) {
      l &= -2;
    }

    if (flag1 != flag) {
      world.setData(i, j, k, l, 3);
      this.d(world, i, j, k, l);
    }

    if (flag1) {
      world.a(i, j, k, this.id, this.a(world));
    }
  }
예제 #23
0
public class CaptainRovin implements NpcHandler {
  /** World instance */
  public static final World world = World.getWorld();

  public void handleNpc(final Npc npc, final Player player) throws Exception {
    if (player.getDemonSlayerStatus() == 6) { // Quest Complete
      player.informOfNpcMessage(
          new ChatMessage(
              npc,
              "Well done brave adventurer. You surely showed Delrith who is boss around here!",
              player));
      return;
    }
    if (player.getDemonSlayerStatus() == 5) { // Got the silverlight
      player.informOfNpcMessage(
          new ChatMessage(npc, "Please go slay Delrith with the silverlight!", player));
      return;
    }
    if (player.getDemonSlayerStatus() == 4) {
      player.informOfNpcMessage(
          new ChatMessage(
              npc,
              "Perhaps you should get all the keys to Sir Prysin as soon as possible!",
              player));
      return;
    }
    if (player.getDemonSlayerStatus() == 0) {
      player.informOfNpcMessage(
          new ChatMessage(
              npc, "Go speak with the gypsy. She looks like she's in trouble!", player));
      return;
    }
    if (player.getDemonSlayerStatus() == 1) {
      player.informOfNpcMessage(
          new ChatMessage(
              npc, "I heard Delrith is around town. Go find and inform Sir Prysin!", player));
      return;
    }
    if (player.getDemonSlayerStatus() == 3) {
      player.informOfNpcMessage(
          new ChatMessage(
              npc, "Take the keys back to Sir Prysin to recieve the silverlight sword!", player));
      return;
    }
    if (player.getDemonSlayerStatus() == 2) {
      player.informOfNpcMessage(new ChatMessage(npc, "How can I help you?", player));
      world
          .getDelayedEventHandler()
          .add(
              new ShortEvent(player) {
                public void action() {
                  String[] option =
                      new String[] {
                        "What are you doing up here?",
                        "I am looking for the silverlight key",
                        "You can't help me"
                      };
                  player.setMenuHandler(
                      new MenuHandler(option) {
                        public void handleReply(final int option, final String reply) {
                          if (player.isBusy()) {
                            return;
                          }
                          player.informOfChatMessage(new ChatMessage(player, reply, npc));
                          player.setBusy(true);
                          world
                              .getDelayedEventHandler()
                              .add(
                                  new ShortEvent(player) {
                                    public void action() {
                                      player.setBusy(false);
                                      if (option == 2) { // Nothing
                                        player.informOfNpcMessage(
                                            new ChatMessage(
                                                npc,
                                                "Then go away! I need to keep the guards in order!",
                                                player));
                                        return;
                                      }
                                      if (option == 0) { // What are you doing up here
                                        player.informOfNpcMessage(
                                            new ChatMessage(
                                                npc,
                                                "I am training these guards and keeping them in top shape!",
                                                player));
                                        return;
                                      }
                                      if (option == 1) { // Looking for the key
                                        player.informOfNpcMessage(
                                            new ChatMessage(
                                                npc,
                                                "Ah, yes. Sir Prysin informed of you would be coming to see me",
                                                player));
                                        world
                                            .getDelayedEventHandler()
                                            .add(
                                                new ShortEvent(player) {
                                                  public void action() {
                                                    player.informOfNpcMessage(
                                                        new ChatMessage(
                                                            npc,
                                                            "The Delrith is no push over, I hope you know what you are getting into",
                                                            player));
                                                    world
                                                        .getDelayedEventHandler()
                                                        .add(
                                                            new ShortEvent(player) {
                                                              public void action() {
                                                                player.informOfChatMessage(
                                                                    new ChatMessage(
                                                                        player,
                                                                        "Let me worry about defeating the Delrith. You stick to coaching the guards!",
                                                                        npc));
                                                                world
                                                                    .getDelayedEventHandler()
                                                                    .add(
                                                                        new ShortEvent(player) {
                                                                          public void action() {
                                                                            player
                                                                                .informOfNpcMessage(
                                                                                    new ChatMessage(
                                                                                        npc,
                                                                                        "Ok soldier! Here's the key!",
                                                                                        player));
                                                                            player
                                                                                .getInventory()
                                                                                .add(
                                                                                    new InvItem(
                                                                                        26, 1));
                                                                            player
                                                                                .getActionSender()
                                                                                .sendInventory();
                                                                            player
                                                                                .setDemonSlayerStatus(
                                                                                    3);
                                                                            npc.unblock();
                                                                          }
                                                                        });
                                                              }
                                                            });
                                                  }
                                                });
                                      }
                                    }
                                  });
                        }
                      });
                  owner.getActionSender().sendMenu(option);
                }
              });
      npc.blockedBy(player);
    }
  }
}
예제 #24
0
파일: Mob.java 프로젝트: spenk/CanaryMod
 /**
  * Creates a mob interface
  *
  * @param mob name of the mob
  * @param world World for the mob
  */
 public Mob(String mob, World world) {
   this((OEntityLiving) OEntityList.a(mob, world.getWorld()));
 }
예제 #25
0
  // CraftBukkit - priv to public
  public void dispense(World world, int i, int j, int k, Random random) {
    int l = world.getData(i, j, k);
    byte b0 = 0;
    byte b1 = 0;

    if (l == 3) {
      b1 = 1;
    } else if (l == 2) {
      b1 = -1;
    } else if (l == 5) {
      b0 = 1;
    } else {
      b0 = -1;
    }

    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      // CraftBukkit start
      int dispenseSlot = tileentitydispenser.findDispenseSlot();
      ItemStack itemstack = null;
      if (dispenseSlot > -1) {
        itemstack = tileentitydispenser.getContents()[dispenseSlot];

        // Copy item stack, because we want it to have 1 item
        itemstack =
            new ItemStack(itemstack.id, 1, itemstack.getData(), itemstack.getEnchantments());
      }
      // CraftBukkit end

      double d0 = (double) i + (double) b0 * 0.6D + 0.5D;
      double d1 = (double) j + 0.5D;
      double d2 = (double) k + (double) b1 * 0.6D + 0.5D;

      if (itemstack == null) {
        world.triggerEffect(1001, i, j, k, 0);
      } else {
        // CraftBukkit start
        double d3 = random.nextDouble() * 0.1D + 0.2D;
        double motX = (double) b0 * d3;
        double motY = 0.20000000298023224D;
        double motZ = (double) b1 * d3;
        motX += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motY += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D;

        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone();

        BlockDispenseEvent event =
            new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ));
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
          return;
        }

        if (event.getItem().equals(bukkitItem)) {
          // Actually remove the item
          tileentitydispenser.splitStack(dispenseSlot, 1);
        }

        motX = event.getVelocity().getX();
        motY = event.getVelocity().getY();
        motZ = event.getVelocity().getZ();

        itemstack = CraftItemStack.createNMSItemStack(event.getItem());
        // CraftBukkit end

        if (itemstack.id == Item.ARROW.id) {
          EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2);

          entityarrow.shoot((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          entityarrow.fromPlayer = true;
          world.addEntity(entityarrow);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EGG.id) {
          EntityEgg entityegg = new EntityEgg(world, d0, d1, d2);

          entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entityegg);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.SNOW_BALL.id) {
          EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2);

          entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entitysnowball);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.POTION.id && ItemPotion.c(itemstack.getData())) {
          EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData());

          entitypotion.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitypotion);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EXP_BOTTLE.id) {
          EntityThrownExpBottle entitythrownexpbottle =
              new EntityThrownExpBottle(world, d0, d1, d2);

          entitythrownexpbottle.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitythrownexpbottle);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.MONSTER_EGG.id) {
          ItemMonsterEgg.a(
              world,
              itemstack.getData(),
              d0 + (double) b0 * 0.3D,
              d1 - 0.3D,
              d2 + (double) b1 * 0.3D);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.FIREBALL.id) {
          EntitySmallFireball entitysmallfireball =
              new EntitySmallFireball(
                  world,
                  d0 + (double) b0 * 0.3D,
                  d1,
                  d2 + (double) b1 * 0.3D,
                  (double) b0 + random.nextGaussian() * 0.05D,
                  random.nextGaussian() * 0.05D,
                  (double) b1 + random.nextGaussian() * 0.05D);

          world.addEntity(entitysmallfireball);
          world.triggerEffect(1009, i, j, k, 0);
        } else {
          EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
          // CraftBukkit start
          // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
          entityitem.motX = motX;
          entityitem.motY = motY;
          entityitem.motZ = motZ;
          // CraftBukkit end
          world.addEntity(entityitem);
          world.triggerEffect(1000, i, j, k, 0);
        }

        world.triggerEffect(2000, i, j, k, b0 + 1 + (b1 + 1) * 3);
      }
    }
  }
예제 #26
0
  private void a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getData(i, j, k);
    int l1 = 0;

    this.a = false;
    boolean flag = world.isBlockIndirectlyPowered(i, j, k);

    this.a = true;

    if (flag) {
      l1 = 15;
    } else {
      for (int i2 = 0; i2 < 4; i2++) {
        int j2 = i;
        int k2 = k;
        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          j2++;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          k2++;
        }

        if ((j2 != l) || (j != i1) || (k2 != j1)) {
          l1 = getPower(world, j2, j, k2, l1);
        }

        if ((world.s(j2, j, k2)) && (!world.s(i, j + 1, k))) {
          if ((j2 != l) || (j + 1 != i1) || (k2 != j1)) l1 = getPower(world, j2, j + 1, k2, l1);
        } else if ((!world.s(j2, j, k2)) && ((j2 != l) || (j - 1 != i1) || (k2 != j1))) {
          l1 = getPower(world, j2, j - 1, k2, l1);
        }
      }

      if (l1 > 0) l1--;
      else {
        l1 = 0;
      }
    }

    if (k1 != l1) {
      BlockRedstoneEvent event =
          new BlockRedstoneEvent(world.getWorld().getBlockAt(i, j, k), k1, l1);
      world.getServer().getPluginManager().callEvent(event);

      l1 = event.getNewCurrent();
    }

    if (k1 != l1) {
      world.suppressPhysics = true;
      world.setData(i, j, k, l1);
      world.d(i, j, k, i, j, k);
      world.suppressPhysics = false;

      for (int i2 = 0; i2 < 4; i2++) {
        int j2 = i;
        int k2 = k;
        int l2 = j - 1;

        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          j2++;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          k2++;
        }

        if (world.s(j2, j, k2)) {
          l2 += 2;
        }

        boolean flag1 = false;
        int i3 = getPower(world, j2, j, k2, -1);

        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          l1--;
        }

        if ((i3 >= 0) && (i3 != l1)) {
          a(world, j2, j, k2, i, j, k);
        }

        i3 = getPower(world, j2, l2, k2, -1);
        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          l1--;
        }

        if ((i3 >= 0) && (i3 != l1)) {
          a(world, j2, l2, k2, i, j, k);
        }
      }

      if ((k1 < l1) || (l1 == 0)) {
        this.b.add(new ChunkPosition(i, j, k));
        this.b.add(new ChunkPosition(i - 1, j, k));
        this.b.add(new ChunkPosition(i + 1, j, k));
        this.b.add(new ChunkPosition(i, j - 1, k));
        this.b.add(new ChunkPosition(i, j + 1, k));
        this.b.add(new ChunkPosition(i, j, k - 1));
        this.b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }
예제 #27
0
 /**
  * Returns an integer representing the age in pseudo years, as and individual would experience it.
  * The age is calculated from a constant (getTimeYearRatio()).
  *
  * @return a int representing the age in pseudo years.
  */
 public int getAge() {
   return (int)
           ((World.getWorld().getWorldTime() - timeOfBirth)
               / World.getEnvironment().getYearSecondsRatio())
       + startAge;
 }
  public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    ItemBucket itembucket = (ItemBucket) itemstack.getItem();
    BlockPosition blockposition =
        isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));

    // CraftBukkit start
    World world = isourceblock.i();
    int x = blockposition.getX();
    int y = blockposition.getY();
    int z = blockposition.getZ();
    if (world.isEmpty(blockposition)
        || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
      org.bukkit.block.Block block =
          world
              .getWorld()
              .getBlockAt(
                  isourceblock.getBlockPosition().getX(),
                  isourceblock.getBlockPosition().getY(),
                  isourceblock.getBlockPosition().getZ());
      CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);

      BlockDispenseEvent event =
          new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
      if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
      }

      if (event.isCancelled()) {
        return itemstack;
      }

      if (!event.getItem().equals(craftItem)) {
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior =
            (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
          idispensebehavior.a(isourceblock, eventStack);
          return itemstack;
        }
      }

      itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
    }
    // CraftBukkit end

    if (itembucket.a(isourceblock.i(), blockposition)) {
      // CraftBukkit start - Handle stacked buckets
      Item item = Items.BUCKET;
      if (--itemstack.count == 0) {
        itemstack.setItem(Items.BUCKET);
        itemstack.count = 1;
      } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item))
          < 0) {
        this.b.a(isourceblock, new ItemStack(item));
      }
      // CraftBukkit end
      return itemstack;
    } else {
      return this.b.a(isourceblock, itemstack);
    }
  }
예제 #29
0
  private void g(World world, int i, int j, int k) {
    boolean flag = world.getData(i, j, k) == 1;
    boolean flag1 = false;
    float f = 0.125F;
    List list = null;

    if (this.a == EnumMobType.EVERYTHING) {
      list =
          world.b(
              (Entity) null,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.MOBS) {
      list =
          world.a(
              EntityLiving.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.PLAYERS) {
      list =
          world.a(
              EntityHuman.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (list.size() > 0) {
      flag1 = true;
    }

    // CraftBukkit start - Interact Pressure Plate
    org.bukkit.World bworld = world.getWorld();
    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();

    if (flag != flag1) {
      if (flag1) {
        for (Object object : list) {
          if (object != null) {
            org.bukkit.event.Cancellable cancellable;

            if (object instanceof EntityHuman) {
              cancellable =
                  CraftEventFactory.callPlayerInteractEvent(
                      (EntityHuman) object,
                      org.bukkit.event.block.Action.PHYSICAL,
                      i,
                      j,
                      k,
                      -1,
                      null);
            } else if (object instanceof Entity) {
              cancellable =
                  new EntityInteractEvent(
                      ((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
              manager.callEvent((EntityInteractEvent) cancellable);
            } else {
              continue;
            }
            if (cancellable.isCancelled()) {
              return;
            }
          }
        }
      }

      BlockRedstoneEvent eventRedstone =
          new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
      manager.callEvent(eventRedstone);

      flag1 = eventRedstone.getNewCurrent() > 0;
    }
    // CraftBukkit end

    if (flag1 && !flag) {
      world.setData(i, j, k, 1);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag1 && flag) {
      world.setData(i, j, k, 0);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag1) {
      world.c(i, j, k, this.id, this.d());
    }
  }
예제 #30
0
public class InvActionHandler implements PacketHandler {
  /** World instance */
  public static final World world = World.getWorld();

  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    if (player.isBusy()) {
      if (player.inCombat()) {
        player.getActionSender().sendMessage("You cannot do that whilst fighting!");
      }
      return;
    }
    player.resetAll();
    int idx = (int) p.readShort();
    if (idx < 0 || idx >= player.getInventory().size()) {
      player.setSuspiciousPlayer(true);
      return;
    }
    final InvItem item = player.getInventory().get(idx);
    if (item == null || item.getDef().getCommand().equals("")) {
      player.setSuspiciousPlayer(true);
      return;
    }
    if (item.isEdible()) {
      player.setBusy(true);
      player.getActionSender().sendSound("eat");
      player.getActionSender().sendMessage("You eat the " + item.getDef().getName() + ".");
      final boolean heals = player.getCurStat(3) < player.getMaxStat(3);
      if (heals) {
        int newHp = player.getCurStat(3) + item.eatingHeals();
        if (newHp > player.getMaxStat(3)) {
          newHp = player.getMaxStat(3);
        }
        player.setCurStat(3, newHp);
        player.getActionSender().sendStat(3);
      }
      world
          .getDelayedEventHandler()
          .add(
              new SingleEvent(player, 200) {
                public void action() {
                  if (heals) {
                    owner.getActionSender().sendMessage("It heals some health.");
                  }
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 326: // Meat pizza
                      owner.getInventory().add(new InvItem(328));
                      break;
                    case 327: // Anchovie pizza
                      owner.getInventory().add(new InvItem(329));
                      break;
                    case 330: // Cake
                      owner.getInventory().add(new InvItem(333));
                      break;
                    case 333: // Partical cake
                      owner.getInventory().add(new InvItem(335));
                      break;
                    case 332: // Choc cake
                      owner.getInventory().add(new InvItem(334));
                      break;
                    case 334: // Partical choc cake
                      owner.getInventory().add(new InvItem(336));
                      break;
                    case 257: // Apple pie
                      owner.getInventory().add(new InvItem(263));
                      break;
                    case 261: // Half apple pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 258: // Redberry pie
                      owner.getInventory().add(new InvItem(262));
                      break;
                    case 262: // Half redberry pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 259: // Meat pie
                      owner.getInventory().add(new InvItem(261));
                      break;
                    case 263: // Half meat pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                  }
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("bury")) {
      player.setBusy(true);
      player.getActionSender().sendMessage("You dig a hole in the ground.");
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  owner
                      .getActionSender()
                      .sendMessage("You bury the " + item.getDef().getName() + ".");
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 20: // Bones
                    case 604: // Bat bones
                      owner.incExp(5, 8 * 10, true);
                      break;
                    case 413: // Big bones
                      owner.incExp(5, 24 * 10, true);
                      break;
                    case 814: // Dragon bones
                      owner.incExp(5, 90 * 10, true);
                      break;
                  }
                  owner.getActionSender().sendStat(5);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("clean")) {
      if (!player.getQuestManager().completed("Druidic Ritual")) {
        player
            .getActionSender()
            .sendMessage(
                "You can not use Herblaw until you have completed the Druidic Ritual quest.");
        return;
      }
      ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
      if (herb == null) {
        return;
      }
      if (player.getMaxStat(15) < herb.getLevelRequired()) {
        player
            .getActionSender()
            .sendMessage("Your herblaw ability is not high enough to clean this herb.");
        return;
      }
      player.setBusy(true);
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
                  InvItem newItem = new InvItem(herb.getNewId());
                  owner.getInventory().remove(item);
                  owner.getInventory().add(newItem);
                  owner
                      .getActionSender()
                      .sendMessage("You clean the mud off the " + newItem.getDef().getName() + ".");
                  owner.incExp(15, herb.getExp() * 10, true);
                  owner.getActionSender().sendStat(15);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("drink")) {
      switch (item.getID()) {
        case 739: // Tea
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It's nice and refreshing.");
                      owner.getInventory().remove(item);
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 193: // Beer
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 142: // Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 246: // Half Jug of Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 1);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 180: // Bad Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("Yuck! Your head starts to hurt.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 830: // Greenmans Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It has a strange taste.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(15) <= owner.getMaxStat(15)) {
                        owner.setCurStat(15, owner.getCurStat(15) + 1);
                        owner.getActionSender().sendStat(15);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 268: // Mind Bomb
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel very strange.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(6) <= owner.getMaxStat(6)) {
                        owner.setCurStat(6, owner.getCurStat(6) + 2);
                        owner.getActionSender().sendStat(6);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 269: // Dwarven Stout
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It tastes foul.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(13) <= owner.getMaxStat(13)) {
                        owner.setCurStat(13, owner.getCurStat(13) + 1);
                        owner.getActionSender().sendStat(13);
                      }
                      if (owner.getCurStat(14) <= owner.getMaxStat(14)) {
                        owner.setCurStat(14, owner.getCurStat(14) + 1);
                        owner.getActionSender().sendStat(14);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 267: // Asgarnian Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly reinvigorated");
                      owner.getActionSender().sendMessage("And slightly dizzy too.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 829: // Dragon Bitter
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
          /** HANDLE WINE+ CURE POISON AND ANTIDOTE AND ZAMAROCK POTIONS * */
        case 221: // Strength Potion - 4 dose
          useNormalPotion(player, item, 2, 10, 2, 222, 3);
          break;
        case 222: // Strength Potion - 3 dose
          useNormalPotion(player, item, 2, 10, 2, 223, 2);
          break;
        case 223: // Strength Potion - 2 dose
          useNormalPotion(player, item, 2, 10, 2, 224, 1);
          break;
        case 224: // Strength Potion - 1 dose
          useNormalPotion(player, item, 2, 10, 2, 465, 0);
          break;
        case 474: // attack Potion - 3 dose
          useNormalPotion(player, item, 0, 10, 2, 475, 2);
          break;
        case 475: // attack Potion - 2 dose
          useNormalPotion(player, item, 0, 10, 2, 476, 1);
          break;
        case 476: // attack Potion - 1 dose
          useNormalPotion(player, item, 0, 10, 2, 465, 0);
          break;
        case 477: // stat restoration Potion - 3 dose
          useStatRestorePotion(player, item, 478, 2);
          break;
        case 478: // stat restoration Potion - 2 dose
          useStatRestorePotion(player, item, 479, 1);
          break;
        case 479: // stat restoration Potion - 1 dose
          useStatRestorePotion(player, item, 465, 0);
          break;
        case 480: // defense Potion - 3 dose
          useNormalPotion(player, item, 1, 10, 2, 481, 2);
          break;
        case 481: // defense Potion - 2 dose
          useNormalPotion(player, item, 1, 10, 2, 482, 1);
          break;
        case 482: // defense Potion - 1 dose
          useNormalPotion(player, item, 1, 10, 2, 465, 0);
          break;
        case 483: // restore prayer Potion - 3 dose
          usePrayerPotion(player, item, 484, 2);
          break;
        case 484: // restore prayer Potion - 2 dose
          usePrayerPotion(player, item, 485, 1);
          break;
        case 485: // restore prayer Potion - 1 dose
          usePrayerPotion(player, item, 465, 0);
          break;
        case 486: // Super attack Potion - 3 dose
          useNormalPotion(player, item, 0, 15, 4, 487, 2);
          break;
        case 487: // Super attack Potion - 2 dose
          useNormalPotion(player, item, 0, 15, 4, 488, 1);
          break;
        case 488: // Super attack Potion - 1 dose
          useNormalPotion(player, item, 0, 15, 4, 465, 0);
          break;
        case 489: // fishing Potion - 3 dose
          useFishingPotion(player, item, 490, 2);
          break;
        case 490: // fishing Potion - 2 dose
          useFishingPotion(player, item, 491, 1);
          break;
        case 491: // fishing Potion - 1 dose
          useFishingPotion(player, item, 465, 0);
          break;
        case 492: // Super strength Potion - 3 dose
          useNormalPotion(player, item, 2, 15, 4, 493, 2);
          break;
        case 493: // Super strength Potion - 2 dose
          useNormalPotion(player, item, 2, 15, 4, 494, 1);
          break;
        case 494: // Super strength Potion - 1 dose
          useNormalPotion(player, item, 2, 15, 4, 465, 0);
          break;
        case 495: // Super defense Potion - 3 dose
          useNormalPotion(player, item, 1, 15, 4, 496, 2);
          break;
        case 496: // Super defense Potion - 2 dose
          useNormalPotion(player, item, 1, 15, 4, 497, 1);
          break;
        case 497: // Super defense Potion - 1 dose
          useNormalPotion(player, item, 1, 15, 4, 465, 0);
          break;
        case 498: // ranging Potion - 3 dose
          useNormalPotion(player, item, 4, 10, 2, 499, 2);
          break;
        case 499: // ranging Potion - 2 dose
          useNormalPotion(player, item, 4, 10, 2, 500, 1);
          break;
        case 500: // ranging Potion - 1 dose
          useNormalPotion(player, item, 4, 10, 2, 465, 0);
          break;
        default:
          player.getActionSender().sendMessage("Nothing interesting happens.");
          return;
      }
    } else {
      switch (item.getID()) {
        case 597: // Charged Dragonstone amulet
          player.getActionSender().sendMessage("You rub the amulet...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      String[] options =
                          new String[] {
                            "Edgeville",
                            "Karamja",
                            "Draynor Village",
                            "Al Kharid",
                            "Mage Arena",
                            "Seers",
                            "Yanille"
                          };
                      owner.setMenuHandler(
                          new MenuHandler(options) {
                            public void handleReply(final int option, final String reply) {
                              if (owner.isBusy() || owner.getInventory().get(item) == null) {
                                return;
                              }
                              if (owner.getLocation().wildernessLevel() >= 30
                                  || (owner.getLocation().inModRoom() && !owner.isMod())
                                  || (owner.getLocation().inJail() && !owner.isMod())) {
                                owner
                                    .getActionSender()
                                    .sendMessage("A magical force stops you from teleporting.");
                                return;
                              }
                              owner.getActionSender().sendSound("spellok");
                              switch (option) {
                                case 0: // Edgeville
                                  owner.teleport(193, 435, true);
                                  break;
                                case 1: // Karamja
                                  owner.teleport(360, 696, true);
                                  break;
                                case 2: // Draynor Village
                                  owner.teleport(214, 632, true);
                                  break;
                                case 3: // Al Kharid
                                  owner.teleport(72, 696, true);
                                  break;
                                case 4: // Mage Arena
                                  owner.teleport(447, 3371, true);
                                  break;
                                case 5: // Seers
                                  owner.teleport(516, 460, true);
                                  break;
                                case 6: // Yanille
                                  owner.teleport(587, 761, true);
                                  break;
                                default:
                                  return;
                              }
                              if (DataConversions.random(0, 5) == 1
                                  && owner.getInventory().remove(item) > -1) {
                                owner.getInventory().add(new InvItem(522, 1));
                                owner.getActionSender().sendInventory();
                              }
                            }
                          });
                      owner.getActionSender().sendMenu(options);
                    }
                  });
          break;
        case 387: // Disk of Returning
          if (player.getLocation().wildernessLevel() >= 30
              || (player.getLocation().inModRoom() && !player.isMod())) {
            player.getActionSender().sendMessage("The disk doesn't seem to work here.");
            return;
          }
          player.getActionSender().sendMessage("The disk starts to spin...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.resetPath();
                      owner.teleport(219, 455, true);
                      owner.getInventory().remove(item);
                      owner
                          .getActionSender()
                          .sendMessage("You find yourself back in Varrock with a sore bottom.");
                      owner.getActionSender().sendMessage("The disk has now gone");
                      owner.getActionSender().sendInventory();
                    }
                  });
          break;
        case 1263: // Sleeping Bag
          player.resetPath();
          player.getActionSender().sendMessage("You rest in the Sleeping Bag.");
          switch (rand(0, 10)) {
            case 0:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Quarter", "Quadah", "Korter", "Twenyfavcent", "Nubface"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 1:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"N00b", "Newbie", "Noobletz", "Noobz", "Noobcakez"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 2:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Jaquet", "Jaket", "Jackit", "Brangelina", "Jacket"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 3:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Marwolf", "Mar", "Wolf", "Mar!11", "Halp"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 4:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Dawg", "Dawggie", "Homeslice", "Dog", "Snoop"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 3) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 5:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Gangstar", "Gangsta", "Gangster", "Sean Brooks", "Thug lyfe yo"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 6:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Like", "Lyk", "Liek", "I suck at this", "I give up"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 7:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Wrong Answer",
                                "Right Answer",
                                "Wrong Answer",
                                "Wrong Answer",
                                "Wrong Answer"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 8:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Charictor", "Charactor", "Charector", "Carhuh?", "Character"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 9:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Hatianz", "Zombies", "Botnetz", "Tom Cruise!1", "Elephantz"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();

                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 10:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Deposet", "Deposat", "Despot", "Rapidshit", "Deposit"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });

              break;
          }
        default:
          player.getActionSender().sendMessage("Match the word with the correct spelling.");
          return;
      }
    }
  }

  public static int rand(int bound) {
    return rand(0, bound - 1);
  }

  public static int rand(int low, int high) {
    return low + (int) (Math.random() * (high - low + 1));
  }

  private void showBubble(Player player, InvItem item) {
    Bubble bubble = new Bubble(player, item.getID());
    for (Player p1 : player.getViewArea().getPlayersInView()) {
      p1.informOfBubble(bubble);
    }
  }

  private void useNormalPotion(
      Player player,
      final InvItem item,
      final int affectedStat,
      final int percentageIncrease,
      final int modifier,
      final int newItem,
      final int left) {
    player.setBusy(true);
    player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
    world
        .getDelayedEventHandler()
        .add(
            new MiniEvent(player) {
              public void action() {
                owner.getActionSender().sendMessage("You have " + left + " doses left.");
                int baseStat =
                    owner.getCurStat(affectedStat) > owner.getMaxStat(affectedStat)
                        ? owner.getMaxStat(affectedStat)
                        : owner.getCurStat(affectedStat);
                int newStat =
                    baseStat
                        + DataConversions.roundUp(
                            (owner.getMaxStat(affectedStat) / 100D) * percentageIncrease)
                        + modifier;
                if (newStat > owner.getCurStat(affectedStat)) {
                  owner.setCurStat(affectedStat, newStat);
                  owner.getActionSender().sendStat(affectedStat);
                }
                owner.getInventory().remove(item);
                owner.getInventory().add(new InvItem(newItem));
                owner.getActionSender().sendInventory();
                owner.setBusy(false);
              }
            });
  }

  private void usePrayerPotion(
      Player player, final InvItem item, final int newItem, final int left) {
    player.setBusy(true);
    player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
    world
        .getDelayedEventHandler()
        .add(
            new MiniEvent(player) {
              public void action() {
                owner.getActionSender().sendMessage("You have " + left + " doses left.");
                int newPrayer = owner.getCurStat(5) + 21;
                if (newPrayer > owner.getMaxStat(5)) {
                  newPrayer = owner.getMaxStat(5);
                }
                owner.setCurStat(5, newPrayer);
                owner.getInventory().remove(item);
                owner.getInventory().add(new InvItem(newItem));
                owner.getActionSender().sendStat(5);
                owner.getActionSender().sendInventory();
                owner.setBusy(false);
              }
            });
  }

  private void useStatRestorePotion(
      Player player, final InvItem item, final int newItem, final int left) {
    player.setBusy(true);
    player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
    world
        .getDelayedEventHandler()
        .add(
            new MiniEvent(player) {
              public void action() {
                owner.getActionSender().sendMessage("You have " + left + " doses left.");
                for (int i = 0; i < 18; i++) {
                  if (i == 3 || i == 5) {
                    continue;
                  }
                  int max = owner.getMaxStat(i);
                  if (owner.getCurStat(i) < max) {
                    owner.setCurStat(i, max);
                    owner.getActionSender().sendStat(i);
                  }
                }
                owner.getInventory().remove(item);
                owner.getInventory().add(new InvItem(newItem));
                owner.getActionSender().sendInventory();
                owner.setBusy(false);
              }
            });
  }

  private void useFishingPotion(
      Player player, final InvItem item, final int newItem, final int left) {
    player.setBusy(true);
    player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
    world
        .getDelayedEventHandler()
        .add(
            new MiniEvent(player) {
              public void action() {
                owner.getActionSender().sendMessage("You have " + left + " doses left.");
                owner.setCurStat(10, owner.getMaxStat(10) + 3);
                owner.getInventory().remove(item);
                owner.getInventory().add(new InvItem(newItem));
                owner.getActionSender().sendStat(10);
                owner.getActionSender().sendInventory();
                owner.setBusy(false);
              }
            });
  }
}