| 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.EnumParticleTypes;
|
| 6 | import net.minecraft.world.World;
|
| 7 |
|
| 8 | public class EntityParticleEmitter extends EntityFX
|
| 9 | {
|
| 10 | private Entity attachedEntity;
|
| 11 | private int age;
|
| 12 | private int lifetime;
|
| 13 | private EnumParticleTypes particleTypes;
|
| 14 |
|
| 15 | public EntityParticleEmitter(World worldIn, Entity p_i46279_2_, EnumParticleTypes particleTypesIn)
|
| 16 | {
|
| 17 | super(worldIn, p_i46279_2_.posX, p_i46279_2_.getEntityBoundingBox().minY + (double)(p_i46279_2_.height / 2.0F), p_i46279_2_.posZ, p_i46279_2_.motionX, p_i46279_2_.motionY, p_i46279_2_.motionZ);
|
| 18 | this.attachedEntity = p_i46279_2_;
|
| 19 | this.lifetime = 3;
|
| 20 | this.particleTypes = particleTypesIn;
|
| 21 | this.onUpdate();
|
| 22 | }
|
| 23 |
|
| 24 | /**
|
| 25 | * Renders the particle
|
| 26 | */
|
| 27 | public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
|
| 28 | {
|
| 29 | }
|
| 30 |
|
| 31 | /**
|
| 32 | * Called to update the entity's position/logic.
|
| 33 | */
|
| 34 | public void onUpdate()
|
| 35 | {
|
| 36 | for (int i = 0; i < 16; ++i)
|
| 37 | {
|
| 38 | double d0 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
|
| 39 | double d1 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
|
| 40 | double d2 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
|
| 41 |
|
| 42 | if (d0 * d0 + d1 * d1 + d2 * d2 <= 1.0D)
|
| 43 | {
|
| 44 | double d3 = this.attachedEntity.posX + d0 * (double)this.attachedEntity.width / 4.0D;
|
| 45 | double d4 = this.attachedEntity.getEntityBoundingBox().minY + (double)(this.attachedEntity.height / 2.0F) + d1 * (double)this.attachedEntity.height / 4.0D;
|
| 46 | double d5 = this.attachedEntity.posZ + d2 * (double)this.attachedEntity.width / 4.0D;
|
| 47 | this.worldObj.spawnParticle(this.particleTypes, false, d3, d4, d5, d0, d1 + 0.2D, d2, new int[0]);
|
| 48 | }
|
| 49 | }
|
| 50 |
|
| 51 | ++this.age;
|
| 52 |
|
| 53 | if (this.age >= this.lifetime)
|
| 54 | {
|
| 55 | this.setDead();
|
| 56 | }
|
| 57 | }
|
| 58 |
|
| 59 | public int getFXLayer()
|
| 60 | {
|
| 61 | return 3;
|
| 62 | }
|
| 63 | }
|
| 64 |
|