예제 #1
0
  public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
    if (!par1EntityPlayer.capabilities.isCreativeMode) {
      par1EntityPlayer.addExperienceLevel(-this.anvil.maximumCost);
    }

    ContainerRepair.getRepairInputInventory(this.anvil)
        .setInventorySlotContents(0, (ItemStack) null);

    if (ContainerRepair.getStackSizeUsedInRepair(this.anvil) > 0) {
      ItemStack var3 = ContainerRepair.getRepairInputInventory(this.anvil).getStackInSlot(1);

      if (var3 != null && var3.stackSize > ContainerRepair.getStackSizeUsedInRepair(this.anvil)) {
        var3.stackSize -= ContainerRepair.getStackSizeUsedInRepair(this.anvil);
        ContainerRepair.getRepairInputInventory(this.anvil).setInventorySlotContents(1, var3);
      } else {
        ContainerRepair.getRepairInputInventory(this.anvil)
            .setInventorySlotContents(1, (ItemStack) null);
      }
    } else {
      ContainerRepair.getRepairInputInventory(this.anvil)
          .setInventorySlotContents(1, (ItemStack) null);
    }

    this.anvil.maximumCost = 0;

    if (!par1EntityPlayer.capabilities.isCreativeMode
        && !this.theWorld.isRemote
        && this.theWorld.getBlockId(this.field_82873_b, this.field_82874_c, this.field_82871_d)
            == Block.anvil.blockID
        && par1EntityPlayer.getRNG().nextFloat() < 0.12F) {
      int var6 =
          this.theWorld.getBlockMetadata(
              this.field_82873_b, this.field_82874_c, this.field_82871_d);
      int var4 = var6 & 3;
      int var5 = var6 >> 2;
      ++var5;

      if (var5 > 2) {
        this.theWorld.setBlockWithNotify(
            this.field_82873_b, this.field_82874_c, this.field_82871_d, 0);
        this.theWorld.playAuxSFX(
            1020, this.field_82873_b, this.field_82874_c, this.field_82871_d, 0);
      } else {
        this.theWorld.setBlockMetadataWithNotify(
            this.field_82873_b, this.field_82874_c, this.field_82871_d, var4 | var5 << 2);
        this.theWorld.playAuxSFX(
            1021, this.field_82873_b, this.field_82874_c, this.field_82871_d, 0);
      }
    } else if (!this.theWorld.isRemote) {
      this.theWorld.playAuxSFX(1021, this.field_82873_b, this.field_82874_c, this.field_82871_d, 0);
    }
  }
 /** Add experience levels to this player. */
 public void addExperienceLevel(int p_82242_1_) {
   super.addExperienceLevel(p_82242_1_);
   this.lastExperience = -1;
 }