public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
    super.dropNaturally(world, i, j, k, l, f, i1);
    if (!world.isStatic) {
      Item item = null;

      if (this.blockFruit == Block.PUMPKIN) {
        item = Item.PUMPKIN_SEEDS;
      }

      if (this.blockFruit == Block.MELON) {
        item = Item.MELON_SEEDS;
      }

      for (int j1 = 0; j1 < 3; ++j1) {
        if (world.random.nextInt(15) <= l) {
          float f1 = 0.7F;
          float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          EntityItem entityitem =
              new EntityItem(
                  world,
                  (double) ((float) i + f2),
                  (double) ((float) j + f3),
                  (double) ((float) k + f4),
                  new ItemStack(item));

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
  public void a(World world, int i, int j, int k, Random random) {
    super.a(world, i, j, k, random);
    if (world.getLightLevel(i, j + 1, k) >= 9) {
      float f = this.i(world, i, j, k);

      if (random.nextInt((int) (25.0F / f) + 1) == 0) {
        int l = world.getData(i, j, k);

        if (l < 7) {
          ++l;
          CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this.id, l); // CraftBukkit
        } else {
          if (world.getTypeId(i - 1, j, k) == this.blockFruit.id) {
            return;
          }

          if (world.getTypeId(i + 1, j, k) == this.blockFruit.id) {
            return;
          }

          if (world.getTypeId(i, j, k - 1) == this.blockFruit.id) {
            return;
          }

          if (world.getTypeId(i, j, k + 1) == this.blockFruit.id) {
            return;
          }

          int i1 = random.nextInt(4);
          int j1 = i;
          int k1 = k;

          if (i1 == 0) {
            j1 = i - 1;
          }

          if (i1 == 1) {
            ++j1;
          }

          if (i1 == 2) {
            k1 = k - 1;
          }

          if (i1 == 3) {
            ++k1;
          }

          int l1 = world.getTypeId(j1, j - 1, k1);

          if (world.getTypeId(j1, j, k1) == 0
              && (l1 == Block.SOIL.id || l1 == Block.DIRT.id || l1 == Block.GRASS.id)) {
            CraftEventFactory.handleBlockGrowEvent(
                world, j1, j, k1, this.blockFruit.id, 0); // CraftBukkit
          }
        }
      }
    }
  }
示例#3
0
  /** Ticks the block if it's been scheduled */
  public void b(World var1, int var2, int var3, int var4, Random var5) {
    super.b(var1, var2, var3, var4, var5);

    if (var1.getLightLevel(var2, var3 + 1, var4) >= 9) {
      float var6 = this.n(var1, var2, var3, var4);

      if (var5.nextInt((int) (25.0F / var6) + 1) == 0) {
        int var7 = var1.getData(var2, var3, var4);

        if (var7 < 7) {
          ++var7;
          var1.setData(var2, var3, var4, var7);
        } else {
          if (var1.getTypeId(var2 - 1, var3, var4) == this.blockFruit.id) {
            return;
          }

          if (var1.getTypeId(var2 + 1, var3, var4) == this.blockFruit.id) {
            return;
          }

          if (var1.getTypeId(var2, var3, var4 - 1) == this.blockFruit.id) {
            return;
          }

          if (var1.getTypeId(var2, var3, var4 + 1) == this.blockFruit.id) {
            return;
          }

          int var8 = var5.nextInt(4);
          int var9 = var2;
          int var10 = var4;

          if (var8 == 0) {
            var9 = var2 - 1;
          }

          if (var8 == 1) {
            ++var9;
          }

          if (var8 == 2) {
            var10 = var4 - 1;
          }

          if (var8 == 3) {
            ++var10;
          }

          int var11 = var1.getTypeId(var9, var3 - 1, var10);

          if (var1.getTypeId(var9, var3, var10) == 0
              && (var11 == Block.SOIL.id || var11 == Block.DIRT.id || var11 == Block.GRASS.id)) {
            var1.setTypeId(var9, var3, var10, this.blockFruit.id);
          }
        }
      }
    }
  }
示例#4
0
 public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
   if (!world.isStatic && entityhuman.bT() != null && entityhuman.bT().id == Item.SHEARS.id) {
     entityhuman.a(StatisticList.C[this.id], 1);
     this.b(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l));
   } else {
     super.a(world, entityhuman, i, j, k, l);
   }
 }
示例#5
0
  public void a(World world, int i, int j, int k, Random random) {
    int l = world.getData(i, j, k);

    if (l < 3 && random.nextInt(10) == 0) {
      org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(
          world, i, j, k, this.id, ++l); // CraftBukkit
    }

    super.a(world, i, j, k, random);
  }
 /**
  * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the
  * coordinates of the block and l is the block's subtype/damage.
  */
 public void harvestBlock(
     World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
   if (!par1World.isRemote
       && par2EntityPlayer.getCurrentEquippedItem() != null
       && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex) {
     par2EntityPlayer.addStat(StatList.mineBlockStatArray[blockID], 1);
     dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.deadBush, 1, par6));
   } else {
     super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
   }
 }
示例#7
0
  /** Drops the block items with a specified chance of dropping the specified items */
  public void dropNaturally(
      World var1, int var2, int var3, int var4, int var5, float var6, int var7) {
    super.dropNaturally(var1, var2, var3, var4, var5, var6, var7);

    if (!var1.isStatic) {
      Item var8 = null;

      if (this.blockFruit == Block.PUMPKIN) {
        var8 = Item.PUMPKIN_SEEDS;
      }

      if (this.blockFruit == Block.MELON) {
        var8 = Item.MELON_SEEDS;
      }

      for (int var9 = 0; var9 < 3; ++var9) {
        if (var1.random.nextInt(15) <= var5) {
          this.a(var1, var2, var3, var4, new ItemStack(var8));
        }
      }
    }
  }
示例#8
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    super.updateTick(par1World, par2, par3, par4, par5Random);

    if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) {
      float var6 = this.getGrowthModifier(par1World, par2, par3, par4);

      if (par5Random.nextInt((int) (25.0F / var6) + 1) == 0) {
        int var7 = par1World.getBlockMetadata(par2, par3, par4);

        if (var7 < 7) {
          ++var7;
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var7);
        } else {
          if (par1World.getBlockId(par2 - 1, par3, par4) == this.fruitType.blockID) {
            return;
          }

          if (par1World.getBlockId(par2 + 1, par3, par4) == this.fruitType.blockID) {
            return;
          }

          if (par1World.getBlockId(par2, par3, par4 - 1) == this.fruitType.blockID) {
            return;
          }

          if (par1World.getBlockId(par2, par3, par4 + 1) == this.fruitType.blockID) {
            return;
          }

          int var8 = par5Random.nextInt(4);
          int var9 = par2;
          int var10 = par4;

          if (var8 == 0) {
            var9 = par2 - 1;
          }

          if (var8 == 1) {
            ++var9;
          }

          if (var8 == 2) {
            var10 = par4 - 1;
          }

          if (var8 == 3) {
            ++var10;
          }

          int var11 = par1World.getBlockId(var9, par3 - 1, var10);
          boolean isSoil =
              (blocksList[var11] != null
                  && blocksList[var11].canSustainPlant(
                      par1World, var9, par3 - 1, var10, ForgeDirection.UP, this));

          if (par1World.getBlockId(var9, par3, var10) == 0
              && (isSoil || var11 == Block.dirt.blockID || var11 == Block.grass.blockID)) {
            par1World.setBlockWithNotify(var9, par3, var10, this.fruitType.blockID);
          }
        }
      }
    }
  }
示例#9
0
 /** Drops the block items with a specified chance of dropping the specified items */
 public void dropBlockAsItemWithChance(
     World par1World, int par2, int par3, int par4, int par5, float par6, int par7) {
   super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
 }