Exemplo n.º 1
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World world, int x, int y, int z, Random random) {
    super.updateTick(world, x, y, z, random);

    if (world.getBlockLightValue(x, y + 1, z) >= 9) {
      float f = this.func_149875_n(world, x, y, z);

      if (random.nextInt((int) (25.0F / f) + 1) == 0) {
        int l = world.getBlockMetadata(x, y, z);

        if (l < 7) {
          ++l;
          world.setBlockMetadataWithNotify(x, y, z, l, 2);
        } else {
          if (world.getBlock(x - 1, y, z) == this.block) {
            return;
          }
          if (world.getBlock(x + 1, y, z) == this.block) {
            return;
          }
          if (world.getBlock(x, y, z - 1) == this.block) {
            return;
          }
          if (world.getBlock(x, y, z + 1) == this.block) {
            return;
          }

          int i1 = random.nextInt(4);
          int j1 = x;
          int k1 = z;

          if (i1 == 0) {
            j1 = x - 1;
          }
          if (i1 == 1) {
            ++j1;
          }
          if (i1 == 2) {
            k1 = z - 1;
          }
          if (i1 == 3) {
            ++k1;
          }

          Block block = world.getBlock(j1, y - 1, k1);

          if (world.isAirBlock(j1, y, k1)
              && (block.canSustainPlant(world, j1, y - 1, k1, UP, this)
                  || block == Blocks.dirt
                  || block == Blocks.grass)) {
            world.setBlock(j1, y, k1, this.block);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    super.updateTick(worldIn, pos, state, rand);

    if (worldIn.getLightFromNeighbors(pos.up()) >= 9) {
      int i = (Integer) state.getValue(AGE);

      if (i < 2) {
        if (rand.nextInt(5) == 0) {
          worldIn.setBlockState(pos, state.withProperty(AGE, i + 1), 2);
        }
      }
    }
  }
Exemplo n.º 3
0
  /** Drops the block items with a specified chance of dropping the specified items */
  @SuppressWarnings("unused")
  public void dropBlockAsItemWithChance(
      World world, int x, int y, int z, int par_1, float par_2, int par_3) {
    super.dropBlockAsItemWithChance(world, x, y, z, par_1, par_2, par_3);

    if (false && !world.isRemote) {
      Item item = null;

      if (this.block == PineappleBlocks.pineapple_block) {
        item = PineappleItems.pineapple;
      }

      for (int j1 = 0; j1 < 3; ++j1) {
        if (world.rand.nextInt(15) <= par_1) {
          this.dropBlockAsItem(world, x, y, z, new ItemStack(item));
        }
      }
    }
  }
 @Override
 public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
   super.neighborChanged(state, world, pos, block);
   if (this.getMetaFromState(state) < getMaxMeta(0))
     world.notifyBlockOfStateChange(pos.add(0, 1, 0), this);
 }
 @Override
 public void onBlockPlacedBy(
     World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
   super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
 }
Exemplo n.º 6
0
 @Override
 public void dropBlockAsItemWithChance(
     World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) {
   super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
 }