Skip to content

Instantly share code, notes, and snippets.

Created May 31, 2014 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fbeee5aee9c7ea08e113 to your computer and use it in GitHub Desktop.
Save anonymous/fbeee5aee9c7ea08e113 to your computer and use it in GitHub Desktop.
package wesserboysMod.client.particles;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
public class ParticleHelper {
public static void spawnParticle(EntityFX particle){
Minecraft mc = Minecraft.getMinecraft();
if(mc != null && mc.renderViewEntity != null && mc.effectRenderer != null){
int particleSetting = mc.gameSettings.particleSetting;
if(particleSetting == 2 || (particleSetting == 1 && particle.worldObj.rand.nextInt(3) == 0)){
return;
}
double distanceX = mc.renderViewEntity.posX - particle.posX;
double distanceY = mc.renderViewEntity.posY - particle.posY;
double distanceZ = mc.renderViewEntity.posZ - particle.posZ;
double maxDistance = 16;
if(distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ > maxDistance * maxDistance){
return;
}
if(particle != null){
mc.effectRenderer.addEffect(particle);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment