コード例 #1
0
  /** Called when a player completes the destruction of a block */
  public boolean onPlayerDestroyBlock(int par1, int par2, int par3, int par4) {
    if (creativeMode) {
      return super.onPlayerDestroyBlock(par1, par2, par3, par4);
    }

    int i = mc.theWorld.getBlockId(par1, par2, par3);
    boolean flag = super.onPlayerDestroyBlock(par1, par2, par3, par4);
    ItemStack itemstack = mc.thePlayer.getCurrentEquippedItem();

    if (itemstack != null) {
      itemstack.onDestroyBlock(i, par1, par2, par3, mc.thePlayer);

      if (itemstack.stackSize == 0) {
        itemstack.onItemDestroyedByUse(mc.thePlayer);
        mc.thePlayer.destroyCurrentEquippedItem();
      }
    }

    return flag;
  }
コード例 #2
0
  /** Called when a player completes the destruction of a block */
  public boolean onPlayerDestroyBlock(int par1, int par2, int par3, int par4) {
    ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
    if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, mc.thePlayer)) {
      return false;
    }
    if (this.creativeMode) {
      return super.onPlayerDestroyBlock(par1, par2, par3, par4);
    } else {
      int var5 = this.mc.theWorld.getBlockId(par1, par2, par3);
      boolean var6 = super.onPlayerDestroyBlock(par1, par2, par3, par4);
      ItemStack var7 = this.mc.thePlayer.getCurrentEquippedItem();

      if (var7 != null) {
        var7.onDestroyBlock(var5, par1, par2, par3, this.mc.thePlayer);

        if (var7.stackSize == 0) {
          var7.onItemDestroyedByUse(this.mc.thePlayer);
          this.mc.thePlayer.destroyCurrentEquippedItem();
        }
      }

      return var6;
    }
  }