Search in sources :

Example 6 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project ForestryMC by ForestryMC.

the class ParticleHelper method addDestroyEffects.

/**
 * Spawn particles for when the block is destroyed. Due to the nature of how
 * this is invoked, the x/y/z locations are not always guaranteed to host
 * your block. So be sure to do proper sanity checks before assuming that
 * the location is this block.
 *
 * @return True to prevent vanilla break particles from spawning.
 */
@SideOnly(Side.CLIENT)
public static boolean addDestroyEffects(World world, Block block, IBlockState state, BlockPos pos, ParticleManager effectRenderer, Callback callback) {
    if (block != state.getBlock()) {
        return true;
    }
    byte iterations = 4;
    for (int i = 0; i < iterations; ++i) {
        for (int j = 0; j < iterations; ++j) {
            for (int k = 0; k < iterations; ++k) {
                double px = pos.getX() + (i + 0.5D) / iterations;
                double py = pos.getY() + (j + 0.5D) / iterations;
                double pz = pos.getZ() + (k + 0.5D) / iterations;
                ParticleDigging fx = (ParticleDigging) effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), px, py, pz, px - pos.getX() - 0.5D, py - pos.getY() - 0.5D, pz - pos.getZ() - 0.5D, Block.getStateId(state));
                if (fx != null) {
                    callback.addDestroyEffects(fx, world, pos, state);
                    effectRenderer.addEffect(fx.setBlockPos(pos));
                }
            }
        }
    }
    return true;
}
Also used : ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ParticleDigging (net.minecraft.client.particle.ParticleDigging)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 IBlockState (net.minecraft.block.state.IBlockState)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 IPaintable (crazypants.enderio.base.paint.IPaintable)1 Particle (net.minecraft.client.particle.Particle)1 BlockPos (net.minecraft.util.math.BlockPos)1