예제 #1
0
 @Override
 protected void recipeFinished() {
   log.finer("Recipe Finished");
   // getInputs().removeOneFrom(getInventory()); // Don't double dip! Parent consume already ate
   // recipe costs.
   org.bukkit.inventory.ItemStack[] contents = getInventory().getContents();
   for (int x = 0; x < contents.length; x++) {
     org.bukkit.inventory.ItemStack stack = contents[x];
     if (stack == null) {
       continue;
     }
     if (repairable(stack)) {
       log.fine("Found repairable: " + stack.getType());
       ItemStack s = CraftItemStack.asNMSCopy(stack);
       s.setRepairCost(rfp.getResetLevel());
       getInventory().setItem(x, CraftItemStack.asBukkitCopy(s));
     } else {
       log.fine("Found non-repairable: " + stack.getType());
     }
   }
 }
예제 #2
0
  public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
      return true;
    }

    ItemStack itemStack = entityhuman.inventory.getItemInHand();

    if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) {
      if (itemStack.getItem() == Item.getItemOf(Blocks.RED_FLOWER)
          && !getMyPet().hasFlower()
          && getOwner().getPlayer().isSneaking()) {
        getMyPet().setFlower(CraftItemStack.asBukkitCopy(itemStack));
        if (!entityhuman.abilities.canInstantlyBuild) {
          if (--itemStack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
          }
        }
        return true;
      } else if (itemStack.getItem() == Items.SHEARS
          && getMyPet().hasFlower()
          && getOwner().getPlayer().isSneaking()) {
        EntityItem entityitem = this.a(CraftItemStack.asNMSCopy(getMyPet().getFlower()), 1.0F);
        entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
        entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
        entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);

        makeSound("mob.sheep.shear", 1.0F, 1.0F);
        getMyPet().setFlower(null);
        if (!entityhuman.abilities.canInstantlyBuild) {
          itemStack.damage(1, entityhuman);
        }

        return true;
      }
    }
    return false;
  }