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;
}
Aggregations