@Override
 public ItemStack decrStackSize(int slot, int amount) {
   if (pickSlot.getStackInSlot(slot) != null) {
     ItemStack returnStack;
     if (pickSlot.getStackInSlot(slot).stackSize <= amount) {
       returnStack = pickSlot.getStackInSlot(slot);
       pickSlot.setStackInSlot(null, slot);
       this.markDirty();
       return returnStack;
     } else {
       returnStack = pickSlot.getStackInSlot(slot).splitStack(amount);
       if (pickSlot.getStackInSlot(slot).stackSize <= 0) pickSlot.setStackInSlot(null, slot);
       this.markDirty();
       return returnStack;
     }
   }
   return null;
 }
  /**
   * *****************************************************************************************************************
   * ********************************************** Tile Methods
   * ******************************************************
   * *****************************************************************************************************************
   */
  @Override
  @SuppressWarnings("unchecked")
  public void updateEntity() {
    super.updateEntity();
    if (!worldObj.isRemote
        && !isPowered()
        && getCore() != null
        && pickSlot.getStackInSlot(0) != null
        && worldObj.rand.nextInt(20) == 0) {
      SixWayRotation rotation = new SixWayRotation();
      ForgeDirection dir =
          rotation.convertMetaToDirection(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
      Location blockBreakLocation = new Location(this);
      blockBreakLocation.travel(dir);
      if (!worldObj.isAirBlock(blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z)) {
        Block toBreak =
            worldObj.getBlock(blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z);
        if (toBreak.getMaterial() == Material.water || toBreak.getMaterial() == Material.lava)
          return;
        int harvestLevel =
            pickSlot
                .getStackInSlot(0)
                .getItem()
                .getHarvestLevel(pickSlot.getStackInSlot(0), "pickaxe");
        if (toBreak.getHarvestLevel(
                worldObj.getBlockMetadata(
                    blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z))
            <= harvestLevel) {

          int fortune = 0;
          boolean silkTouch =
              toBreak.canSilkHarvest(
                  worldObj,
                  null,
                  blockBreakLocation.x,
                  blockBreakLocation.y,
                  blockBreakLocation.x,
                  worldObj.getBlockMetadata(
                      blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z));
          boolean hasSilkTouch = false;
          NBTTagList enchantList = pickSlot.getStackInSlot(0).getEnchantmentTagList();
          if (enchantList != null) {
            for (int i = 0; i < enchantList.tagCount(); i++) {
              NBTTagCompound tag = enchantList.getCompoundTagAt(i);
              if (tag.hasKey("id") && tag.getInteger("id") == 35) fortune = tag.getInteger("lvl");
              else if (tag.hasKey("id") && tag.getInteger("id") == 33) hasSilkTouch = true;
            }
          }
          ArrayList<ItemStack> itemStacks = new ArrayList<>();
          if (silkTouch && hasSilkTouch) {
            itemStacks.add(
                new ItemStack(
                    toBreak,
                    1,
                    worldObj.getBlockMetadata(
                        blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z)));
          } else {
            itemStacks =
                toBreak.getDrops(
                    worldObj,
                    blockBreakLocation.x,
                    blockBreakLocation.y,
                    blockBreakLocation.z,
                    worldObj.getBlockMetadata(
                        blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z),
                    fortune);
          }
          for (ItemStack itemStack : itemStacks) {
            if (itemStack != null && itemStack.stackSize > 0) {
              float rx = worldObj.rand.nextFloat() * 0.8F + 0.1F;
              float ry = worldObj.rand.nextFloat() * 0.8F + 0.1F;
              float rz = worldObj.rand.nextFloat() * 0.8F + 0.1F;

              EntityItem entityItem =
                  new EntityItem(
                      worldObj,
                      blockBreakLocation.x + rx,
                      blockBreakLocation.y + ry,
                      blockBreakLocation.z + rz,
                      new ItemStack(
                          itemStack.getItem(), itemStack.stackSize, itemStack.getItemDamage()));

              if (itemStack.hasTagCompound())
                entityItem
                    .getEntityItem()
                    .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());

              float factor = 0.05F;
              entityItem.motionX = worldObj.rand.nextGaussian() * factor;
              entityItem.motionY = worldObj.rand.nextGaussian() * factor + 0.2F;
              entityItem.motionZ = worldObj.rand.nextGaussian() * factor;
              worldObj.spawnEntityInWorld(entityItem);

              itemStack.stackSize = 0;
            }
          }
          worldObj.playAuxSFX(
              2001,
              blockBreakLocation.x,
              blockBreakLocation.y,
              blockBreakLocation.z,
              Block.getIdFromBlock(toBreak)
                  + (worldObj.getBlockMetadata(
                          blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z)
                      << 12));
          worldObj.setBlockToAir(blockBreakLocation.x, blockBreakLocation.y, blockBreakLocation.z);
          pickSlot.getStackInSlot(0).setItemDamage(pickSlot.getStackInSlot(0).getItemDamage() + 1);
          if (pickSlot.getStackInSlot(0).getItemDamage()
              > pickSlot.getStackInSlot(0).getMaxDamage()) pickSlot.setStackInSlot(null, 0);
        }
      }
    }
  }
 @Override
 public void setInventorySlotContents(int slot, ItemStack stack) {
   pickSlot.setStackInSlot(stack, slot);
 }