package game.renderer.particle; import org.lwjgl.opengl.GL11; import game.Game; import game.entity.Entity; import game.renderer.DefaultVertexFormats; import game.renderer.GlState; import game.renderer.RenderBuffer; import game.renderer.Tessellator; import game.renderer.texture.TextureManager; import game.world.BlockPos; import game.world.World; public class EntityFootStepFX extends EntityFX { private int footstepAge; private int footstepMaxAge; private TextureManager currentFootSteps; protected EntityFootStepFX(TextureManager currentFootStepsIn, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn) { super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D); this.currentFootSteps = currentFootStepsIn; this.motionX = this.motionY = this.motionZ = 0.0D; this.footstepMaxAge = 200; } /** * Renders the particle */ public void renderParticle(RenderBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { double u = 2.0F / 16.0F; double u1 = u + 0.0624375F; double u2 = 6.0F / 16.0F; double u3 = u2 + 0.0624375F; float f = ((float)this.footstepAge + partialTicks) / (float)this.footstepMaxAge; f = f * f; float f1 = 2.0F - f * 2.0F; if (f1 > 1.0F) { f1 = 1.0F; } f1 = f1 * 0.2F; GlState.disableLighting(); float f2 = 0.125F; float f3 = (float)(this.posX - interpPosX); float f4 = (float)(this.posY - interpPosY); float f5 = (float)(this.posZ - interpPosZ); float f6 = this.worldObj.getLightBrightness(new BlockPos(this)); this.currentFootSteps.bindTexture(EffectRenderer.particleTextures); GlState.enableBlend(); GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); worldRendererIn.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(u1, u3).color(f6, f6, f6, f1).endVertex(); worldRendererIn.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(u1, u2).color(f6, f6, f6, f1).endVertex(); worldRendererIn.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(u, u2).color(f6, f6, f6, f1).endVertex(); worldRendererIn.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(u, u3).color(f6, f6, f6, f1).endVertex(); // Tessellator.getInstance(); Tessellator.draw(); GlState.disableBlend(); GlState.enableLighting(); } /** * Called to update the entity's position/logic. */ public void onUpdate() { ++this.footstepAge; if (this.footstepAge == this.footstepMaxAge) { this.setDead(); } } public int getFXLayer() { return 3; } public static class Factory implements IParticleFactory { public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_) { return new EntityFootStepFX(Game.getGame().getTextureManager(), worldIn, xCoordIn, yCoordIn, zCoordIn); } } }