| 1 | package net.minecraft.client.particle;
|
| 2 |
|
| 3 | import net.minecraft.client.renderer.WorldRenderer;
|
| 4 | import net.minecraft.entity.Entity;
|
| 5 | import net.minecraft.util.MathHelper;
|
| 6 | import net.minecraft.world.World;
|
| 7 |
|
| 8 | public class EntityReddustFX extends EntityFX
|
| 9 | {
|
| 10 | float reddustParticleScale;
|
| 11 |
|
| 12 | protected EntityReddustFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, float p_i46349_8_, float p_i46349_9_, float p_i46349_10_)
|
| 13 | {
|
| 14 | this(worldIn, xCoordIn, yCoordIn, zCoordIn, 1.0F, p_i46349_8_, p_i46349_9_, p_i46349_10_);
|
| 15 | }
|
| 16 |
|
| 17 | protected EntityReddustFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, float p_i46350_8_, float p_i46350_9_, float p_i46350_10_, float p_i46350_11_)
|
| 18 | {
|
| 19 | super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
|
| 20 | this.motionX *= 0.10000000149011612D;
|
| 21 | this.motionY *= 0.10000000149011612D;
|
| 22 | this.motionZ *= 0.10000000149011612D;
|
| 23 |
|
| 24 | if (p_i46350_9_ == 0.0F)
|
| 25 | {
|
| 26 | p_i46350_9_ = 1.0F;
|
| 27 | }
|
| 28 |
|
| 29 | float f = (float)Math.random() * 0.4F + 0.6F;
|
| 30 | this.particleRed = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_9_ * f;
|
| 31 | this.particleGreen = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_10_ * f;
|
| 32 | this.particleBlue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * p_i46350_11_ * f;
|
| 33 | this.particleScale *= 0.75F;
|
| 34 | this.particleScale *= p_i46350_8_;
|
| 35 | this.reddustParticleScale = this.particleScale;
|
| 36 | this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
|
| 37 | this.particleMaxAge = (int)((float)this.particleMaxAge * p_i46350_8_);
|
| 38 | this.noClip = false;
|
| 39 | }
|
| 40 |
|
| 41 | /**
|
| 42 | * Renders the particle
|
| 43 | */
|
| 44 | public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
|
| 45 | {
|
| 46 | float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
|
| 47 | f = MathHelper.clamp_float(f, 0.0F, 1.0F);
|
| 48 | this.particleScale = this.reddustParticleScale * f;
|
| 49 | super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * Called to update the entity's position/logic.
|
| 54 | */
|
| 55 | public void onUpdate()
|
| 56 | {
|
| 57 | this.prevPosX = this.posX;
|
| 58 | this.prevPosY = this.posY;
|
| 59 | this.prevPosZ = this.posZ;
|
| 60 |
|
| 61 | if (this.particleAge++ >= this.particleMaxAge)
|
| 62 | {
|
| 63 | this.setDead();
|
| 64 | }
|
| 65 |
|
| 66 | this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge);
|
| 67 | this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
| 68 |
|
| 69 | if (this.posY == this.prevPosY)
|
| 70 | {
|
| 71 | this.motionX *= 1.1D;
|
| 72 | this.motionZ *= 1.1D;
|
| 73 | }
|
| 74 |
|
| 75 | this.motionX *= 0.9599999785423279D;
|
| 76 | this.motionY *= 0.9599999785423279D;
|
| 77 | this.motionZ *= 0.9599999785423279D;
|
| 78 |
|
| 79 | if (this.onGround)
|
| 80 | {
|
| 81 | this.motionX *= 0.699999988079071D;
|
| 82 | this.motionZ *= 0.699999988079071D;
|
| 83 | }
|
| 84 | }
|
| 85 |
|
| 86 | public static class Factory implements IParticleFactory
|
| 87 | {
|
| 88 | public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
|
| 89 | {
|
| 90 | return new EntityReddustFX(worldIn, xCoordIn, yCoordIn, zCoordIn, (float)xSpeedIn, (float)ySpeedIn, (float)zSpeedIn);
|
| 91 | }
|
| 92 | }
|
| 93 | }
|
| 94 |
|