@Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
Esempio n. 2
0
 public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
   if (!worldIn.isRemote) {
     if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
       // float power = 2F + (((5000) / 10369F) * 18F);
       // ProcessHandler.addProcess(new NuclearExplosion(worldIn, pos.getX(), pos.getY(),
       // pos.getZ(), power));
       EntityNukePrimed entitytntprimed =
           new EntityNukePrimed(
               worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
       worldIn.spawnEntityInWorld(entitytntprimed);
       worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
     }
   }
 }
Esempio n. 3
0
 @Override
 public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
   if (!worldIn.isRemote) {
     EntityNukePrimed entitytntprimed =
         new EntityNukePrimed(
             worldIn,
             pos.getX() + 0.5F,
             pos.getY() + 0.5F,
             pos.getZ() + 0.5F,
             explosionIn.getExplosivePlacedBy());
     entitytntprimed.fuse =
         worldIn.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
     worldIn.spawnEntityInWorld(entitytntprimed);
   }
 }