Skip to content

Instantly share code, notes, and snippets.

Created June 19, 2014 18:36
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/5557e2a1617641b13405 to your computer and use it in GitHub Desktop.
Save anonymous/5557e2a1617641b13405 to your computer and use it in GitHub Desktop.
public class EntityRainbowFX extends EntityFX {
private static final ResourceLocation textureFile = new ResourceLocation(Reference.MODID, "textures/particle/rainbow.png");
private Random rand = new Random();
public EntityRainbowFX(World world, double x, double y, double z) {
super(world, x, y, z);
this.particleMaxAge = 30;
this.particleGravity = 20;
this.particleScale = 1;
}
@Override
public void renderParticle(Tessellator tess, float tick, float par3, float par4, float par5, float par6, float par7) {
Minecraft.getMinecraft().renderEngine.bindTexture(textureFile);
glDepthMask(false);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.003921569F);
tess.startDrawingQuads();
tess.setBrightness(getBrightnessForRender(tick));
float scale = 0.1F * particleScale;
float x = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)tick - interpPosX);
float y = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)tick - interpPosY);
float z = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)tick - interpPosZ);
tess.addVertexWithUV((double)(x - par3 * scale - par6 * scale), (double)(y - par4 * scale), (double)(z - par5 * scale - par7 * scale), 1, 1);
tess.addVertexWithUV((double)(x - par3 * scale + par6 * scale), (double)(y + par4 * scale), (double)(z - par5 * scale + par7 * scale), 1, 0);
tess.addVertexWithUV((double)(x + par3 * scale + par6 * scale), (double)(y + par4 * scale), (double)(z + par5 * scale + par7 * scale), 0, 0);
tess.addVertexWithUV((double)(x + par3 * scale - par6 * scale), (double)(y - par4 * scale), (double)(z + par5 * scale - par7 * scale), 0, 1);
tess.draw();
glDisable(GL_BLEND);
glDepthMask(true);
glAlphaFunc(GL_GREATER, 0.1F);
}
@Override
public int getFXLayer() {
return 3;
}
@Override
public void onUpdate() {
this.motionX = rand.nextFloat() * 0.1F;
this.motionY = rand.nextFloat() * 0.1F;
this.motionZ = rand.nextFloat() * 0.1F;
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
this.setDead();
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment