| 1 | package net.minecraft.client.particle;
|
| 2 |
|
| 3 | import net.minecraft.client.Minecraft;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.client.renderer.RenderHelper;
|
| 6 | import net.minecraft.client.renderer.Tessellator;
|
| 7 | import net.minecraft.client.renderer.WorldRenderer;
|
| 8 | import net.minecraft.client.renderer.texture.TextureManager;
|
| 9 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 10 | import net.minecraft.client.renderer.vertex.VertexFormat;
|
| 11 | import net.minecraft.entity.Entity;
|
| 12 | import net.minecraft.util.ResourceLocation;
|
| 13 | import net.minecraft.world.World;
|
| 14 |
|
| 15 | public class EntityLargeExplodeFX extends EntityFX
|
| 16 | {
|
| 17 | private static final ResourceLocation EXPLOSION_TEXTURE = new ResourceLocation("textures/entity/explosion.png");
|
| 18 | private static final VertexFormat field_181549_az = (new VertexFormat()).addElement(DefaultVertexFormats.POSITION_3F).addElement(DefaultVertexFormats.TEX_2F).addElement(DefaultVertexFormats.COLOR_4UB).addElement(DefaultVertexFormats.TEX_2S).addElement(DefaultVertexFormats.NORMAL_3B).addElement(DefaultVertexFormats.PADDING_1B);
|
| 19 | private int field_70581_a;
|
| 20 | private int field_70584_aq;
|
| 21 |
|
| 22 | /** The Rendering Engine. */
|
| 23 | private TextureManager theRenderEngine;
|
| 24 | private float field_70582_as;
|
| 25 |
|
| 26 | protected EntityLargeExplodeFX(TextureManager renderEngine, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i1213_9_, double p_i1213_11_, double p_i1213_13_)
|
| 27 | {
|
| 28 | super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
|
| 29 | this.theRenderEngine = renderEngine;
|
| 30 | this.field_70584_aq = 6 + this.rand.nextInt(4);
|
| 31 | this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.6F + 0.4F;
|
| 32 | this.field_70582_as = 1.0F - (float)p_i1213_9_ * 0.5F;
|
| 33 | }
|
| 34 |
|
| 35 | /**
|
| 36 | * Renders the particle
|
| 37 | */
|
| 38 | public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
|
| 39 | {
|
| 40 | int i = (int)(((float)this.field_70581_a + partialTicks) * 15.0F / (float)this.field_70584_aq);
|
| 41 |
|
| 42 | if (i <= 15)
|
| 43 | {
|
| 44 | this.theRenderEngine.bindTexture(EXPLOSION_TEXTURE);
|
| 45 | float f = (float)(i % 4) / 4.0F;
|
| 46 | float f1 = f + 0.24975F;
|
| 47 | float f2 = (float)(i / 4) / 4.0F;
|
| 48 | float f3 = f2 + 0.24975F;
|
| 49 | float f4 = 2.0F * this.field_70582_as;
|
| 50 | float f5 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX);
|
| 51 | float f6 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY);
|
| 52 | float f7 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ);
|
| 53 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 54 | GlStateManager.disableLighting();
|
| 55 | RenderHelper.disableStandardItemLighting();
|
| 56 | worldRendererIn.begin(7, field_181549_az);
|
| 57 | worldRendererIn.pos((double)(f5 - rotationX * f4 - rotationXY * f4), (double)(f6 - rotationZ * f4), (double)(f7 - rotationYZ * f4 - rotationXZ * f4)).tex((double)f1, (double)f3).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
|
| 58 | worldRendererIn.pos((double)(f5 - rotationX * f4 + rotationXY * f4), (double)(f6 + rotationZ * f4), (double)(f7 - rotationYZ * f4 + rotationXZ * f4)).tex((double)f1, (double)f2).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
|
| 59 | worldRendererIn.pos((double)(f5 + rotationX * f4 + rotationXY * f4), (double)(f6 + rotationZ * f4), (double)(f7 + rotationYZ * f4 + rotationXZ * f4)).tex((double)f, (double)f2).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
|
| 60 | worldRendererIn.pos((double)(f5 + rotationX * f4 - rotationXY * f4), (double)(f6 - rotationZ * f4), (double)(f7 + rotationYZ * f4 - rotationXZ * f4)).tex((double)f, (double)f3).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
|
| 61 | Tessellator.getInstance().draw();
|
| 62 | GlStateManager.enableLighting();
|
| 63 | }
|
| 64 | }
|
| 65 |
|
| 66 | public int getBrightnessForRender(float partialTicks)
|
| 67 | {
|
| 68 | return 61680;
|
| 69 | }
|
| 70 |
|
| 71 | /**
|
| 72 | * Called to update the entity's position/logic.
|
| 73 | */
|
| 74 | public void onUpdate()
|
| 75 | {
|
| 76 | this.prevPosX = this.posX;
|
| 77 | this.prevPosY = this.posY;
|
| 78 | this.prevPosZ = this.posZ;
|
| 79 | ++this.field_70581_a;
|
| 80 |
|
| 81 | if (this.field_70581_a == this.field_70584_aq)
|
| 82 | {
|
| 83 | this.setDead();
|
| 84 | }
|
| 85 | }
|
| 86 |
|
| 87 | public int getFXLayer()
|
| 88 | {
|
| 89 | return 3;
|
| 90 | }
|
| 91 |
|
| 92 | public static class Factory implements IParticleFactory
|
| 93 | {
|
| 94 | public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
|
| 95 | {
|
| 96 | return new EntityLargeExplodeFX(Minecraft.getMinecraft().getTextureManager(), worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
|
| 97 | }
|
| 98 | }
|
| 99 | }
|
| 100 |
|