Java Code Examples for net.minecraft.init.Blocks#ICE

The following examples show how to use net.minecraft.init.Blocks#ICE . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.getBlockState(pos).getBlock() == Blocks.ICE && worldIn.isBlockModifiable(player, pos))
    {
        if (worldIn.isRemote == false)
        {
            int num = 8;
            float velocity = 0.2f;
            // The Super variant (meta = 1) doesn't cause a block update
            int flag = player.getHeldItem(hand).getMetadata() == 1 ? 2 : 3;

            if (worldIn.provider.doesWaterVaporize() == false)
            {
                worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), flag);
            }
            else
            {
                worldIn.setBlockToAir(pos);
                num = 32;
                velocity = 0.4f;
            }

            Effects.spawnParticlesFromServer(worldIn.provider.getDimension(), pos.up(), EnumParticleTypes.SMOKE_LARGE, num, 0.5f, velocity);
            worldIn.playSound(null, player.getPosition(), SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.MASTER, 0.8f, 1.0f);
        }

        return EnumActionResult.SUCCESS;
    }

    return EnumActionResult.PASS;
}
 
Example 2
public boolean canSustainBush(IBlockState state) {
    return state.getBlock() == getBlock("blue_rock") || state.getBlock() == Blocks.ICE || state.getBlock() == Blocks.FROSTED_ICE || state.getBlock() == Blocks.PACKED_ICE;
}
 
Example 3
public boolean canSustainBush(IBlockState state) {
    return state.getBlock() == getBlock("blue_rock") || state.getBlock() == Blocks.ICE || state.getBlock() == Blocks.FROSTED_ICE || state.getBlock() == Blocks.PACKED_ICE;
}
 
Example 4
public boolean generate(World worldIn, Random rand, BlockPos position) {
    while (worldIn.isAirBlock(position) && position.getY() > 2) {
        position = position.down();
    }

    if (worldIn.getBlockState(position).getBlock() != Blocks.SNOW) {
        return false;
    } else {
        position = position.up(rand.nextInt(4));
        int i = rand.nextInt(4) + 7;
        int j = i / 4 + rand.nextInt(2);

        if (j > 1 && rand.nextInt(60) == 0) {
            position = position.up(10 + rand.nextInt(30));
        }

        for (int k = 0; k < i; ++k) {
            float f = (1.0F - (float) k / (float) i) * (float) j;
            int l = MathHelper.ceil(f);

            for (int i1 = -l; i1 <= l; ++i1) {
                float f1 = (float) MathHelper.abs(i1) - 0.25F;

                for (int j1 = -l; j1 <= l; ++j1) {
                    float f2 = (float) MathHelper.abs(j1) - 0.25F;

                    if ((i1 == 0 && j1 == 0 || f1 * f1 + f2 * f2 <= f * f) && (i1 != -l && i1 != l && j1 != -l && j1 != l || rand.nextFloat() <= 0.75F)) {
                        IBlockState iblockstate = worldIn.getBlockState(position.add(i1, k, j1));
                        Block block = iblockstate.getBlock();

                        if (iblockstate.getBlock().isAir(iblockstate, worldIn, position.add(i1, k, j1)) || block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) {
                            this.setBlockAndNotifyAdequately(worldIn, position.add(i1, k, j1), Blocks.PACKED_ICE.getDefaultState());
                        }

                        if (k != 0 && l > 1) {
                            iblockstate = worldIn.getBlockState(position.add(i1, -k, j1));
                            block = iblockstate.getBlock();

                            if (iblockstate.getBlock().isAir(iblockstate, worldIn, position.add(i1, -k, j1)) || block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) {
                                this.setBlockAndNotifyAdequately(worldIn, position.add(i1, -k, j1), Blocks.PACKED_ICE.getDefaultState());
                            }
                        }
                    }
                }
            }
        }

        int k1 = j - 1;

        if (k1 < 0) {
            k1 = 0;
        } else if (k1 > 1) {
            k1 = 1;
        }

        for (int l1 = -k1; l1 <= k1; ++l1) {
            for (int i2 = -k1; i2 <= k1; ++i2) {
                BlockPos blockpos = position.add(l1, -1, i2);
                int j2 = 50;

                if (Math.abs(l1) == 1 && Math.abs(i2) == 1) {
                    j2 = rand.nextInt(5);
                }

                while (blockpos.getY() > 50) {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
                    Block block1 = iblockstate1.getBlock();

                    if (!iblockstate1.getBlock().isAir(iblockstate1, worldIn, blockpos) && block1 != Blocks.DIRT && block1 != Blocks.SNOW && block1 != Blocks.ICE && block1 != Blocks.PACKED_ICE) {
                        break;
                    }

                    this.setBlockAndNotifyAdequately(worldIn, blockpos, Blocks.PACKED_ICE.getDefaultState());
                    blockpos = blockpos.down();
                    --j2;

                    if (j2 <= 0) {
                        blockpos = blockpos.down(rand.nextInt(5) + 1);
                        j2 = rand.nextInt(5);
                    }
                }
            }
        }

        return true;
    }
}