コード例 #1
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.id == Item.SHEARS.id && getOwner().getPlayer().isSneaking()) {
        if (!canEquip()) {
          return false;
        }
        for (EquipmentSlot slot : EquipmentSlot.values()) {
          ItemStack itemInSlot = ((MySkeleton) myPet).getEquipment(slot);
          if (itemInSlot != null) {
            EntityItem entityitem = this.a(itemInSlot.cloneItemStack(), 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);
            setPetEquipment(slot.getSlotId(), null);
          }
        }
        return true;
      } else if (checkForEquipment(itemStack) && getOwner().getPlayer().isSneaking()) {
        if (!canEquip()) {
          return false;
        }
        EquipmentSlot slot = EquipmentSlot.getSlotById(b(itemStack));
        ItemStack itemInSlot = ((MySkeleton) myPet).getEquipment(slot);
        if (itemInSlot != null && !entityhuman.abilities.canInstantlyBuild) {
          EntityItem entityitem = this.a(itemInSlot.cloneItemStack(), 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);
        }
        ItemStack itemStackClone = itemStack.cloneItemStack();
        itemStackClone.count = 1;
        setPetEquipment(b(itemStack), itemStackClone);
        if (!entityhuman.abilities.canInstantlyBuild) {
          --itemStack.count;
        }
        if (itemStack.count <= 0) {
          entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
        }
        return true;
      }
    }
    return false;
  }
コード例 #2
0
ファイル: FakeFurnace.java プロジェクト: rippin/LibsMcpvp
 public void burn() {
   // Can't burn? Goodbye
   if (!canBurn()) {
     return;
   }
   ItemStack itemstack = getBurnResult(contents[0]);
   // Nothing in there? Then put something there.
   if (contents[2] == null) {
     contents[2] = itemstack.cloneItemStack();
   }
   // Burn ahead
   else if (contents[2].doMaterialsMatch(itemstack)) {
     contents[2].count += itemstack.count;
   }
   // And consume the ingredient item
   // Goddamn, you have container functions, use them! Notch!
   if (contents[0].getItem().u()) // Derpnote
   {
     contents[0] = new ItemStack(contents[0].getItem().t()); // Derpnote
   } else {
     contents[0].count--;
     // Let 0 be null
     if (contents[0].count <= 0) {
       contents[0] = null;
     }
   }
 }
コード例 #3
0
ファイル: EntityItemFrame.java プロジェクト: nicecube/mc-dev
 public void setItem(ItemStack itemstack) {
   itemstack = itemstack.cloneItemStack();
   itemstack.count = 1;
   itemstack.a(this);
   this.getDataWatcher().watch(2, itemstack);
   this.getDataWatcher().h(2);
 }
コード例 #4
0
ファイル: BlockJukeBox.java プロジェクト: plleg/mc-dev
  public void dropRecord(World world, int i, int j, int k) {
    if (!world.isStatic) {
      TileEntityRecordPlayer tileentityrecordplayer =
          (TileEntityRecordPlayer) world.getTileEntity(i, j, k);

      if (tileentityrecordplayer != null) {
        ItemStack itemstack = tileentityrecordplayer.record;

        if (itemstack != null) {
          world.triggerEffect(1005, i, j, k, 0);
          world.a((String) null, i, j, k);
          tileentityrecordplayer.record = null;
          tileentityrecordplayer.update();
          world.setData(i, j, k, 0);
          float f = 0.7F;
          double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
          double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          ItemStack itemstack1 = itemstack.cloneItemStack();
          EntityItem entityitem =
              new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack1);

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
コード例 #5
0
ファイル: ItemArmor.java プロジェクト: DaMarine/Alkazia
  public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    int i = EntityInsentient.b(itemstack) - 1;
    ItemStack itemstack1 = entityhuman.r(i);

    if (itemstack1 == null) {
      entityhuman.setEquipment(i, itemstack.cloneItemStack());
      itemstack.count = 0;
    }

    return itemstack;
  }
コード例 #6
0
ファイル: BlockJukeBox.java プロジェクト: plleg/mc-dev
  public void a(World world, int i, int j, int k, ItemStack itemstack) {
    if (!world.isStatic) {
      TileEntityRecordPlayer tileentityrecordplayer =
          (TileEntityRecordPlayer) world.getTileEntity(i, j, k);

      if (tileentityrecordplayer != null) {
        tileentityrecordplayer.record = itemstack.cloneItemStack();
        tileentityrecordplayer.update();
        world.setData(i, j, k, 1);
      }
    }
  }
コード例 #7
0
  public ItemStack b(EntityHuman entityhuman, int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.c.get(i);

    if (slot != null && slot.hasItem()) {
      ItemStack itemstack1 = slot.getItem();

      itemstack = itemstack1.cloneItemStack();
      if ((i < 0 || i > 2) && i != 3) {
        if (!this.f.hasItem() && this.f.isAllowed(itemstack1)) {
          if (!this.a(itemstack1, 3, 4, false)) {
            return null;
          }
        } else if (SlotPotionBottle.b_(itemstack)) {
          if (!this.a(itemstack1, 0, 3, false)) {
            return null;
          }
        } else if (i >= 4 && i < 31) {
          if (!this.a(itemstack1, 31, 40, false)) {
            return null;
          }
        } else if (i >= 31 && i < 40) {
          if (!this.a(itemstack1, 4, 31, false)) {
            return null;
          }
        } else if (!this.a(itemstack1, 4, 40, false)) {
          return null;
        }
      } else {
        if (!this.a(itemstack1, 4, 40, true)) {
          return null;
        }

        slot.a(itemstack1, itemstack);
      }

      if (itemstack1.count == 0) {
        slot.set((ItemStack) null);
      } else {
        slot.f();
      }

      if (itemstack1.count == itemstack.count) {
        return null;
      }

      slot.a(entityhuman, itemstack1);
    }

    return itemstack;
  }
コード例 #8
0
  public void burn() {
    if (this.canBurn()) {
      ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);

      if (this.items[2] == null) {
        this.items[2] = itemstack.cloneItemStack();
      } else if (this.items[2].getItem() == itemstack.getItem()) {
        ++this.items[2].count;
      }

      --this.items[0].count;
      if (this.items[0].count <= 0) {
        this.items[0] = null;
      }
    }
  }
コード例 #9
0
ファイル: EntityItemFrame.java プロジェクト: nicecube/mc-dev
  public void b(Entity entity) {
    ItemStack itemstack = this.getItem();

    if (entity instanceof EntityHuman) {
      EntityHuman entityhuman = (EntityHuman) entity;

      if (entityhuman.abilities.canInstantlyBuild) {
        this.b(itemstack);
        return;
      }
    }

    this.a(new ItemStack(Item.ITEM_FRAME), 0.0F);
    if (itemstack != null && this.random.nextFloat() < this.e) {
      itemstack = itemstack.cloneItemStack();
      this.b(itemstack);
      this.a(itemstack, 0.0F);
    }
  }
コード例 #10
0
ファイル: VAnvil.java プロジェクト: vanZeben/VirtualPack
 public ItemStack #FIELD_CONTAINER_10#(EntityHuman entityhuman, int i)
 {
     ItemStack itemstack = null;
     Slot slot = (Slot) #FIELD_CONTAINER_3#.get(i);
     if(slot != null && slot.#FIELD_SLOT_1#())
     {
         ItemStack itemstack1 = slot.getItem();
         itemstack = itemstack1.cloneItemStack();
         if(i == 2)
         {
             if(!#FIELD_CONTAINER_8#(itemstack1, 3, 39, true))
             {
                 return null;
             }
             slot.#FIELD_SLOT_2#(itemstack1, itemstack);
         }
         else if(i != 0 && i != 1)
         {
             if(i >= 3 && i < 39 && !#FIELD_CONTAINER_8#(itemstack1, 0, 2, false))
             {
                 return null;
             }
         }
         else if(!#FIELD_CONTAINER_8#(itemstack1, 3, 39, false))
         {
             return null;
         }
         if(itemstack1.count == 0)
         {
             slot.set((ItemStack) null);
         }
         else
         {
             slot.#FIELD_SLOT_3#();
         }
         if(itemstack1.count == itemstack.count)
         {
             return null;
         }
         slot.#FIELD_SLOT_2#(entityhuman, itemstack1);
     }
     return itemstack;
 }
コード例 #11
0
  public ItemStack a(int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.e.get(i);

    if (slot != null && slot.c()) {
      ItemStack itemstack1 = slot.getItem();

      itemstack = itemstack1.cloneItemStack();
      if (i == 0) {
        if (!this.a(itemstack1, 10, 46, true)) {
          return null;
        }
      } else if (i >= 10 && i < 37) {
        if (!this.a(itemstack1, 37, 46, false)) {
          return null;
        }
      } else if (i >= 37 && i < 46) {
        if (!this.a(itemstack1, 10, 37, false)) {
          return null;
        }
      } else if (!this.a(itemstack1, 10, 46, false)) {
        return null;
      }

      if (itemstack1.count == 0) {
        slot.c((ItemStack) null);
      } else {
        slot.d();
      }

      if (itemstack1.count == itemstack.count) {
        return null;
      }

      slot.b(itemstack1);
    }

    return itemstack;
  }
コード例 #12
0
ファイル: VAnvil.java プロジェクト: vanZeben/VirtualPack
 public void #FIELD_CONTAINERANVIL_4#()
 {
     ItemStack itemstack = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(0);
     #FIELD_CONTAINERANVIL_5# = 0;
     int i = 0;
     byte b0 = 0;
     int j = 0;
     if(itemstack == null)
     {
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
         #FIELD_CONTAINERANVIL_5# = 0;
     }
     else
     {
         ItemStack itemstack1 = itemstack.cloneItemStack();
         ItemStack itemstack2 = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(1);
         Map map = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(itemstack1);
         boolean flag = false;
         int k = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost());
         _exp = 0;
         int l;
         int i1;
         int j1;
         int k1;
         int l1;
         Iterator iterator;
         Enchantment enchantment;
         if(itemstack2 != null)
         {
             flag = itemstack2.id == Item.ENCHANTED_BOOK.id && Item.ENCHANTED_BOOK.#FIELD_ITEMENCHANTEDBOOK_2#(itemstack2).size() > 0;
             if(itemstack1.#FIELD_ITEM_6#() && Item.byId[itemstack1.id].a(itemstack, itemstack2))
             {
                 l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 if(l <= 0)
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 for(i1 = 0; l > 0 && i1 < itemstack2.count; ++i1)
                 {
                     j1 = itemstack1.#FIELD_ITEMSTACK_5#() - l;
                     itemstack1.setData(j1);
                     i += Math.max(1, l / 100) + map.size();
                     l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 }
                 _exp = i1;
             }
             else
             {
                 if(!flag && (itemstack1.id != itemstack2.id || !itemstack1.#FIELD_ITEM_6#()))
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 if(itemstack1.#FIELD_ITEM_6#() && !flag)
                 {
                     l = itemstack.#FIELD_ITEMSTACK_6#() - itemstack.#FIELD_ITEMSTACK_5#();
                     i1 = itemstack2.#FIELD_ITEMSTACK_6#() - itemstack2.#FIELD_ITEMSTACK_5#();
                     j1 = i1 + itemstack1.#FIELD_ITEMSTACK_6#() * 12 / 100;
                     int i2 = l + j1;
                     k1 = itemstack1.#FIELD_ITEMSTACK_6#() - i2;
                     if(k1 < 0)
                     {
                         k1 = 0;
                     }
                     if(k1 < itemstack1.getData())
                     {
                         itemstack1.setData(k1);
                         i += Math.max(1, j1 / 100);
                     }
                 }
                 Map map1 = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(itemstack2);
                 iterator = map1.keySet().iterator();
                 while(iterator.hasNext())
                 {
                     j1 = ((Integer)iterator.next()).intValue();
                     enchantment = Enchantment.byId[j1];
                     k1 = map.containsKey(Integer.valueOf(j1)) ? ((Integer)map.get(Integer.valueOf(j1))).intValue() : 0;
                     l1 = ((Integer)map1.get(Integer.valueOf(j1))).intValue();
                     int j2;
                     if(k1 == l1)
                     {
                         ++l1;
                         j2 = l1;
                     }
                     else
                     {
                         j2 = Math.max(l1, k1);
                     }
                     l1 = j2;
                     int k2 = l1 - k1;
                     boolean flag1 = enchantment.canEnchant(itemstack);
                     if(playerFree(_player))
                     {
                         flag1 = true;
                     }
                     Iterator iterator1 = map.keySet().iterator();
                     while(iterator1.hasNext())
                     {
                         int l2 = ((Integer)iterator1.next()).intValue();
                         if(l2 != j1 && !enchantment.#FIELD_ENCHANTMENT_1#(Enchantment.byId[l2]))
                         {
                             flag1 = false;
                             i += k2;
                         }
                     }
                     if(flag1)
                     {
                         if(l1 > enchantment.getMaxLevel())
                         {
                             l1 = enchantment.getMaxLevel();
                         }
                         map.put(Integer.valueOf(j1), Integer.valueOf(l1));
                         int i3 = 0;
                         switch(enchantment.getRandomWeight())
                         {
                             case 1:
                                 i3 = 8;
                                 break;
                             case 2:
                                 i3 = 4;
                             case 3:
                             case 4:
                             case 6:
                             case 7:
                             case 8:
                             case 9:
                             default:
                                 break;
                             case 5:
                                 i3 = 2;
                                 break;
                             case 10:
                                 i3 = 1;
                         }
                         i += i3 * k2;
                     }
                 }
             }
         }
         if(_itemName != null && !_itemName.equalsIgnoreCase(itemstack.#FIELD_ITEMSTACK_7#()) && _itemName.length() > 0)
         {
             j = itemstack.#FIELD_ITEM_6#() ? 7 : itemstack.count * 5;
             i += j;
             if(itemstack.#FIELD_ITEMSTACK_8#())
             {
                 k += j / 2;
             }
             itemstack1.#FIELD_ITEMSTACK_9#(_itemName);
         }
         l = 0;
         for(iterator = map.keySet().iterator(); iterator.hasNext(); k += l + k1 * l1)
         {
             j1 = ((Integer)iterator.next()).intValue();
             enchantment = Enchantment.byId[j1];
             k1 = ((Integer)map.get(Integer.valueOf(j1))).intValue();
             l1 = 0;
             ++l;
             switch(enchantment.getRandomWeight())
             {
                 case 1:
                     l1 = 8;
                     break;
                 case 2:
                     l1 = 4;
                 case 3:
                 case 4:
                 case 6:
                 case 7:
                 case 8:
                 case 9:
                 default:
                     break;
                 case 5:
                     l1 = 2;
                     break;
                 case 10:
                     l1 = 1;
             }
             if(flag)
             {
                 l1 = Math.max(1, l1 / 2);
             }
         }
         if(flag)
         {
             k = Math.max(1, k / 2);
         }
         #FIELD_CONTAINERANVIL_5# = k + i;
         if(i <= 0)
         {
             itemstack1 = null;
         }
         if(j == i && j > 0 && #FIELD_CONTAINERANVIL_5# >= 40)
         {
             #FIELD_CONTAINERANVIL_5# = 39;
         }
         if(#FIELD_CONTAINERANVIL_5# >= 40 && !playerFree(_player))
         {
             itemstack1 = null;
         }
         if(itemstack1 != null)
         {
             i1 = itemstack1.getRepairCost();
             if(itemstack2 != null && i1 < itemstack2.getRepairCost())
             {
                 i1 = itemstack2.getRepairCost();
             }
             if(itemstack1.#FIELD_ITEMSTACK_8#())
             {
                 i1 -= 9;
             }
             if(i1 < 0)
             {
                 i1 = 0;
             }
             i1 += 2;
             itemstack1.setRepairCost(i1);
             EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_4#(map, itemstack1);
         }
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, itemstack1);
         #FIELD_CONTAINER_9#();
     }
 }