Java Code Examples for net.minecraft.block.material.Material.isLiquid()

The following are Jave code examples for showing how to use isLiquid() of the net.minecraft.block.material.Material 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: Backmemed   File: CommandSpreadPlayers.java   Source Code and License Vote up 6 votes
public boolean isSafe(World worldIn)
{
    BlockPos blockpos = new BlockPos(this.x, 256.0D, this.z);

    while (blockpos.getY() > 0)
    {
        blockpos = blockpos.down();
        Material material = worldIn.getBlockState(blockpos).getMaterial();

        if (material != Material.AIR)
        {
            return !material.isLiquid() && material != Material.FIRE;
        }
    }

    return false;
}
 
Example 2
Project: BaseClient   File: CommandSpreadPlayers.java   Source Code and License Vote up 6 votes
public boolean func_111098_b(World worldIn)
{
    BlockPos blockpos = new BlockPos(this.field_111101_a, 256.0D, this.field_111100_b);

    while (blockpos.getY() > 0)
    {
        blockpos = blockpos.down();
        Material material = worldIn.getBlockState(blockpos).getBlock().getMaterial();

        if (material != Material.air)
        {
            return !material.isLiquid() && material != Material.fire;
        }
    }

    return false;
}
 
Example 3
Project: DecompiledMinecraft   File: BlockIce.java   Source Code and License Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: BlockIce.java   Source Code and License Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
Example 5
Project: BaseClient   File: BlockIce.java   Source Code and License Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
Example 6
Project: CustomWorldGen   File: BlockIce.java   Source Code and License Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            items.add(itemstack);
        }

        net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
        for (ItemStack is : items)
            spawnAsEntity(worldIn, pos, is);
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        harvesters.set(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        harvesters.set(null);
        Material material = worldIn.getBlockState(pos.down()).getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
        }
    }
}
 
Example 7
Project: BaseClient   File: BlockIce.java   Source Code and License Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
Example 8
Project: DecompiledMinecraft   File: ItemBucket.java   Source Code and License Vote up 4 votes
public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos)
{
    if (this.isFull == Blocks.air)
    {
        return false;
    }
    else
    {
        Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
        boolean flag = !material.isSolid();

        if (!worldIn.isAirBlock(pos) && !flag)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water)
            {
                int i = pos.getX();
                int j = pos.getY();
                int k = pos.getZ();
                worldIn.playSoundEffect((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int l = 0; l < 8; ++l)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && flag && !material.isLiquid())
                {
                    worldIn.destroyBlock(pos, true);
                }

                worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
            }

            return true;
        }
    }
}
 
Example 9
Project: DecompiledMinecraft   File: ItemBucket.java   Source Code and License Vote up 4 votes
public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos)
{
    if (this.isFull == Blocks.air)
    {
        return false;
    }
    else
    {
        Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
        boolean flag = !material.isSolid();

        if (!worldIn.isAirBlock(pos) && !flag)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water)
            {
                int i = pos.getX();
                int j = pos.getY();
                int k = pos.getZ();
                worldIn.playSoundEffect((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int l = 0; l < 8; ++l)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && flag && !material.isLiquid())
                {
                    worldIn.destroyBlock(pos, true);
                }

                worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
            }

            return true;
        }
    }
}
 
Example 10
Project: DecompiledMinecraft   File: BlockLiquid.java   Source Code and License Vote up 4 votes
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.water)
    {
        int i = ((Integer)state.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() * 1.0F + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air && !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + this.maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
    {
        Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.water)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
Example 11
Project: DecompiledMinecraft   File: EntityRainFX.java   Source Code and License Vote up 4 votes
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setDead();
    }

    if (this.onGround)
    {
        if (Math.random() < 0.5D)
        {
            this.setDead();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    block.setBlockBoundsBasedOnState(this.worldObj, blockpos);
    Material material = iblockstate.getBlock().getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = block.getBlockBoundsMaxY();
        }

        double d1 = (double)MathHelper.floor_double(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setDead();
        }
    }
}
 
Example 12
Project: CustomWorldGen   File: BlockLiquid.java   Source Code and License Vote up 4 votes
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.WATER)
    {
        int i = ((Integer)stateIn.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isFullyOpaque())
    {
        Material material = worldIn.getBlockState(pos.down(2)).getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.WATER)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
Example 13
Project: BaseClient   File: ItemBucket.java   Source Code and License Vote up 4 votes
public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos)
{
    if (this.isFull == Blocks.air)
    {
        return false;
    }
    else
    {
        Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
        boolean flag = !material.isSolid();

        if (!worldIn.isAirBlock(pos) && !flag)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water)
            {
                int i = pos.getX();
                int j = pos.getY();
                int k = pos.getZ();
                worldIn.playSoundEffect((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int l = 0; l < 8; ++l)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && flag && !material.isLiquid())
                {
                    worldIn.destroyBlock(pos, true);
                }

                worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
            }

            return true;
        }
    }
}
 
Example 14
Project: CustomWorldGen   File: FluidUtil.java   Source Code and License Vote up 4 votes
/**
 * Tries to place a fluid in the world in block form.
 * Makes a fluid emptying sound when successful.
 * Checks if water-like fluids should vaporize like in the nether.
 *
 * Modeled after {@link net.minecraft.item.ItemBucket#tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)}
 *
 * @param player     Player who places the fluid. May be null for blocks like dispensers.
 * @param worldIn    World to place the fluid in
 * @param fluidStack The fluidStack to place.
 * @param pos        The position in the world to place the fluid block
 * @return true if successful
 */
public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn, FluidStack fluidStack, BlockPos pos)
{
    if (worldIn == null || fluidStack == null || pos == null)
    {
        return false;
    }

    Fluid fluid = fluidStack.getFluid();
    if (fluid == null || !fluid.canBePlacedInWorld())
    {
        return false;
    }

    // check that we can place the fluid at the destination
    IBlockState destBlockState = worldIn.getBlockState(pos);
    Material destMaterial = destBlockState.getMaterial();
    boolean isDestNonSolid = !destMaterial.isSolid();
    boolean isDestReplaceable = destBlockState.getBlock().isReplaceable(worldIn, pos);
    if (!worldIn.isAirBlock(pos) && !isDestNonSolid && !isDestReplaceable)
    {
        return false; // Non-air, solid, unreplacable block. We can't put fluid here.
    }

    if (worldIn.provider.doesWaterVaporize() && fluid.doesVaporize(fluidStack))
    {
        fluid.vaporize(player, worldIn, pos, fluidStack);
    }
    else
    {
        if (!worldIn.isRemote && (isDestNonSolid || isDestReplaceable) && !destMaterial.isLiquid())
        {
            worldIn.destroyBlock(pos, true);
        }

        SoundEvent soundevent = fluid.getEmptySound(fluidStack);
        worldIn.playSound(player, pos, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);

        IBlockState fluidBlockState = fluid.getBlock().getDefaultState();
        worldIn.setBlockState(pos, fluidBlockState, 11);
    }
    return true;
}
 
Example 15
Project: CustomWorldGen   File: ParticleRain.java   Source Code and License Vote up 4 votes
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (Math.random() < 0.5D)
        {
            this.setExpired();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = iblockstate.getBoundingBox(this.worldObj, blockpos).maxY;
        }

        double d1 = (double)MathHelper.floor_double(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}
 
Example 16
Project: CustomWorldGen   File: ItemBucket.java   Source Code and License Vote up 4 votes
public boolean tryPlaceContainedLiquid(@Nullable EntityPlayer player, World worldIn, BlockPos posIn)
{
    if (this.containedBlock == Blocks.AIR)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(posIn);
        Material material = iblockstate.getMaterial();
        boolean flag = !material.isSolid();
        boolean flag1 = iblockstate.getBlock().isReplaceable(worldIn, posIn);

        if (!worldIn.isAirBlock(posIn) && !flag && !flag1)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.containedBlock == Blocks.FLOWING_WATER)
            {
                int l = posIn.getX();
                int i = posIn.getY();
                int j = posIn.getZ();
                worldIn.playSound(player, posIn, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int k = 0; k < 8; ++k)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)l + Math.random(), (double)i + Math.random(), (double)j + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && (flag || flag1) && !material.isLiquid())
                {
                    worldIn.destroyBlock(posIn, true);
                }

                SoundEvent soundevent = this.containedBlock == Blocks.FLOWING_LAVA ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
                worldIn.playSound(player, posIn, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
                worldIn.setBlockState(posIn, this.containedBlock.getDefaultState(), 11);
            }

            return true;
        }
    }
}
 
Example 17
Project: BaseClient   File: BlockLiquid.java   Source Code and License Vote up 4 votes
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.water)
    {
        int i = ((Integer)state.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() * 1.0F + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air && !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + this.maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
    {
        Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.water)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
Example 18
Project: BaseClient   File: EntityRainFX.java   Source Code and License Vote up 4 votes
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setDead();
    }

    if (this.onGround)
    {
        if (Math.random() < 0.5D)
        {
            this.setDead();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    block.setBlockBoundsBasedOnState(this.worldObj, blockpos);
    Material material = iblockstate.getBlock().getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = block.getBlockBoundsMaxY();
        }

        double d1 = (double)MathHelper.floor_double(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setDead();
        }
    }
}
 
Example 19
Project: Backmemed   File: ItemBucket.java   Source Code and License Vote up 4 votes
public boolean tryPlaceContainedLiquid(@Nullable EntityPlayer player, World worldIn, BlockPos posIn)
{
    if (this.containedBlock == Blocks.AIR)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(posIn);
        Material material = iblockstate.getMaterial();
        boolean flag = !material.isSolid();
        boolean flag1 = iblockstate.getBlock().isReplaceable(worldIn, posIn);

        if (!worldIn.isAirBlock(posIn) && !flag && !flag1)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.containedBlock == Blocks.FLOWING_WATER)
            {
                int l = posIn.getX();
                int i = posIn.getY();
                int j = posIn.getZ();
                worldIn.playSound(player, posIn, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int k = 0; k < 8; ++k)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)l + Math.random(), (double)i + Math.random(), (double)j + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && (flag || flag1) && !material.isLiquid())
                {
                    worldIn.destroyBlock(posIn, true);
                }

                SoundEvent soundevent = this.containedBlock == Blocks.FLOWING_LAVA ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
                worldIn.playSound(player, posIn, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
                worldIn.setBlockState(posIn, this.containedBlock.getDefaultState(), 11);
            }

            return true;
        }
    }
}
 
Example 20
Project: CustomWorldGen   File: ParticleDrip.java   Source Code and License Vote up 4 votes
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    if (this.materialType == Material.WATER)
    {
        this.particleRed = 0.2F;
        this.particleGreen = 0.3F;
        this.particleBlue = 1.0F;
    }
    else
    {
        this.particleRed = 1.0F;
        this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16);
        this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8);
    }

    this.motionY -= (double)this.particleGravity;

    if (this.bobTimer-- > 0)
    {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        this.setParticleTextureIndex(113);
    }
    else
    {
        this.setParticleTextureIndex(112);
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (this.materialType == Material.WATER)
        {
            this.setExpired();
            this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        }
        else
        {
            this.setParticleTextureIndex(114);
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue());
        }

        double d1 = (double)(MathHelper.floor_double(this.posY) + 1) - d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}