Java Code Examples for net.minecraft.world.World.canLightningStrike()

The following are Jave code examples for showing how to use canLightningStrike() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BaseClient   File: BlockFarmland.java   Source Code and License Vote up 6 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    int i = ((Integer)state.getValue(MOISTURE)).intValue();

    if (!this.hasWater(worldIn, pos) && !worldIn.canLightningStrike(pos.up()))
    {
        if (i > 0)
        {
            worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(i - 1)), 2);
        }
        else if (!this.hasCrops(worldIn, pos))
        {
            worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
        }
    }
    else if (i < 7)
    {
        worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(7)), 2);
    }
}
 
Example 2
Project: BaseClient   File: BlockFarmland.java   Source Code and License Vote up 6 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    int i = ((Integer)state.getValue(MOISTURE)).intValue();

    if (!this.hasWater(worldIn, pos) && !worldIn.canLightningStrike(pos.up()))
    {
        if (i > 0)
        {
            worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(i - 1)), 2);
        }
        else if (!this.hasCrops(worldIn, pos))
        {
            worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
        }
    }
    else if (i < 7)
    {
        worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(7)), 2);
    }
}
 
Example 3
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 4
Project: BaseClient   File: BlockLeaves.java   Source Code and License Vote up 5 votes
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.canLightningStrike(pos.up()) && !World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && rand.nextInt(15) == 1)
    {
        double d0 = (double)((float)pos.getX() + rand.nextFloat());
        double d1 = (double)pos.getY() - 0.05D;
        double d2 = (double)((float)pos.getZ() + rand.nextFloat());
        worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
    }
}
 
Example 5
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 6
Project: BaseClient   File: BlockLeaves.java   Source Code and License Vote up 5 votes
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.canLightningStrike(pos.up()) && !World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && rand.nextInt(15) == 1)
    {
        double d0 = (double)((float)pos.getX() + rand.nextFloat());
        double d1 = (double)pos.getY() - 0.05D;
        double d2 = (double)((float)pos.getZ() + rand.nextFloat());
        worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
    }
}
 
Example 7
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 4 votes
protected boolean canDie(World worldIn, BlockPos pos)
{
    return worldIn.canLightningStrike(pos) || worldIn.canLightningStrike(pos.west()) || worldIn.canLightningStrike(pos.east()) || worldIn.canLightningStrike(pos.north()) || worldIn.canLightningStrike(pos.south());
}
 
Example 8
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 4 votes
protected boolean canDie(World worldIn, BlockPos pos)
{
    return worldIn.canLightningStrike(pos) || worldIn.canLightningStrike(pos.west()) || worldIn.canLightningStrike(pos.east()) || worldIn.canLightningStrike(pos.north()) || worldIn.canLightningStrike(pos.south());
}