Esempio n. 1
0
  /** Attempts to right-click use an item by the given EntityPlayer in the given World */
  public boolean tryUseItem(
      EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack) {
    int var4 = par3ItemStack.stackSize;
    int var5 = par3ItemStack.getItemDamage();
    ItemStack var6 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);

    if (var6 == par3ItemStack
        && (var6 == null
            || var6.stackSize == var4
                && var6.getMaxItemUseDuration() <= 0
                && var6.getItemDamage() == var5)) {
      return false;
    } else {
      par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = var6;

      if (this.isCreative()) {
        var6.stackSize = var4;

        if (var6.isItemStackDamageable()) {
          var6.setItemDamage(var5);
        }
      }

      if (var6.stackSize == 0) {
        par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
      }

      if (!par1EntityPlayer.isUsingItem()) {
        ((EntityPlayerMP) par1EntityPlayer)
            .sendContainerToPlayer(par1EntityPlayer.inventoryContainer);
      }

      return true;
    }
  }
 public boolean func_325_c(int i, int j, int k) {
   int l = thisWorld.getBlockId(i, j, k);
   int i1 = thisWorld.getBlockMetadata(i, j, k);
   boolean flag = removeBlock(i, j, k);
   ItemStack itemstack = thisPlayer.getCurrentEquippedItem();
   if (itemstack != null) {
     itemstack.func_25124_a(l, i, j, k, thisPlayer);
     if (itemstack.stackSize == 0) {
       itemstack.func_577_a(thisPlayer);
       thisPlayer.destroyCurrentEquippedItem();
     }
   }
   if (flag && thisPlayer.canHarvestBlock(Block.blocksList[l])) {
     Block.blocksList[l].harvestBlock(thisWorld, thisPlayer, i, j, k, i1);
     ((EntityPlayerMP) thisPlayer)
         .playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, thisWorld));
   }
   return flag;
 }
Esempio n. 3
0
 public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
   EntityPlayerMP var3 = getCommandSenderAsPlayer(par1ICommandSender);
   var3.attackEntityFrom(DamageSource.outOfWorld, Float.MAX_VALUE);
   par1ICommandSender.sendChatToPlayer(
       ChatMessageComponent.func_111077_e("commands.kill.success"));
 }