EntityFX .java

net.minecraft.client.particle.EntityFX (class, 274 lines): members: multipleParticleScaleBy, setParticleTextureIndex, particleTextureJitterX, getAlpha.

net.minecraft.client.particleclass274 linesclientextends Entity9.5 KB

API Surface (20)

EntityFX multiplyVelocity(float multiplier)
EntityFX multipleParticleScaleBy(float scale)
void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn)
void setAlphaF(float alpha)
float getRedColorF()
float getGreenColorF()
float getBlueColorF()
float getAlpha()
boolean canTriggerWalking()
void entityInit()
void onUpdate()
void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
int getFXLayer()
void writeEntityToNBT(NBTTagCompound tagCompound)
void readEntityFromNBT(NBTTagCompound tagCompund)
void setParticleIcon(TextureAtlasSprite icon)
void setParticleTextureIndex(int particleTextureIndex)
void nextTextureIndexX()
boolean canAttackWithItem()
String toString()

Fields & Constants (16)

particleTextureIndexX
particleTextureIndexY
particleTextureJitterX
particleTextureJitterY
particleAge
particleMaxAge
particleScale
particleGravity
particleRed
particleGreen
particleBlue
particleAlpha
particleIcon
interpPosX
interpPosY
interpPosZ

String literals (4)

"Invalid call to Particle.setMiscTex"
", Pos ("
"), RGBA ("
"), Age "

Full Source

EntityFX.java274 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.particle;
2
3
import net.minecraft.client.Minecraft;
4
import net.minecraft.client.renderer.WorldRenderer;
5
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
6
import net.minecraft.entity.Entity;
7
import net.minecraft.nbt.NBTTagCompound;
8
import net.minecraft.util.MathHelper;
9
import net.minecraft.world.World;
10
11
public class EntityFX extends Entity
12
{
13
    protected int particleTextureIndexX;
14
    protected int particleTextureIndexY;
15
    protected float particleTextureJitterX;
16
    protected float particleTextureJitterY;
17
    protected int particleAge;
18
    protected int particleMaxAge;
19
    protected float particleScale;
20
    protected float particleGravity;
21
22
    /** The red amount of color. Used as a percentage, 1.0 = 255 and 0.0 = 0. */
23
    protected float particleRed;
24
25
    /**
26
     * The green amount of color. Used as a percentage, 1.0 = 255 and 0.0 = 0.
27
     */
28
    protected float particleGreen;
29
30
    /**
31
     * The blue amount of color. Used as a percentage, 1.0 = 255 and 0.0 = 0.
32
     */
33
    protected float particleBlue;
34
35
    /** Particle alpha */
36
    protected float particleAlpha;
37
38
    /** The icon field from which the given particle pulls its texture. */
39
    protected TextureAtlasSprite particleIcon;
40
    public static double interpPosX;
41
    public static double interpPosY;
42
    public static double interpPosZ;
43
44
    protected EntityFX(World worldIn, double posXIn, double posYIn, double posZIn)
45
    {
46
        super(worldIn);
47
        this.particleAlpha = 1.0F;
48
        this.setSize(0.2F, 0.2F);
49
        this.setPosition(posXIn, posYIn, posZIn);
50
        this.lastTickPosX = this.prevPosX = posXIn;
51
        this.lastTickPosY = this.prevPosY = posYIn;
52
        this.lastTickPosZ = this.prevPosZ = posZIn;
53
        this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
54
        this.particleTextureJitterX = this.rand.nextFloat() * 3.0F;
55
        this.particleTextureJitterY = this.rand.nextFloat() * 3.0F;
56
        this.particleScale = (this.rand.nextFloat() * 0.5F + 0.5F) * 2.0F;
57
        this.particleMaxAge = (int)(4.0F / (this.rand.nextFloat() * 0.9F + 0.1F));
58
        this.particleAge = 0;
59
    }
60
61
    public EntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn)
62
    {
63
        this(worldIn, xCoordIn, yCoordIn, zCoordIn);
64
        this.motionX = xSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
65
        this.motionY = ySpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
66
        this.motionZ = zSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
67
        float f = (float)(Math.random() + Math.random() + 1.0D) * 0.15F;
68
        float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
69
        this.motionX = this.motionX / (double)f1 * (double)f * 0.4000000059604645D;
70
        this.motionY = this.motionY / (double)f1 * (double)f * 0.4000000059604645D + 0.10000000149011612D;
71
        this.motionZ = this.motionZ / (double)f1 * (double)f * 0.4000000059604645D;
72
    }
73
74
    public EntityFX multiplyVelocity(float multiplier)
75
    {
76
        this.motionX *= (double)multiplier;
77
        this.motionY = (this.motionY - 0.10000000149011612D) * (double)multiplier + 0.10000000149011612D;
78
        this.motionZ *= (double)multiplier;
79
        return this;
80
    }
81
82
    public EntityFX multipleParticleScaleBy(float scale)
83
    {
84
        this.setSize(0.2F * scale, 0.2F * scale);
85
        this.particleScale *= scale;
86
        return this;
87
    }
88
89
    public void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn)
90
    {
91
        this.particleRed = particleRedIn;
92
        this.particleGreen = particleGreenIn;
93
        this.particleBlue = particleBlueIn;
94
    }
95
96
    /**
97
     * Sets the particle alpha (float)
98
     */
99
    public void setAlphaF(float alpha)
100
    {
101
        if (this.particleAlpha == 1.0F && alpha < 1.0F)
102
        {
103
            Minecraft.getMinecraft().effectRenderer.moveToAlphaLayer(this);
104
        }
105
        else if (this.particleAlpha < 1.0F && alpha == 1.0F)
106
        {
107
            Minecraft.getMinecraft().effectRenderer.moveToNoAlphaLayer(this);
108
        }
109
110
        this.particleAlpha = alpha;
111
    }
112
113
    public float getRedColorF()
114
    {
115
        return this.particleRed;
116
    }
117
118
    public float getGreenColorF()
119
    {
120
        return this.particleGreen;
121
    }
122
123
    public float getBlueColorF()
124
    {
125
        return this.particleBlue;
126
    }
127
128
    public float getAlpha()
129
    {
130
        return this.particleAlpha;
131
    }
132
133
    /**
134
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
135
     * prevent them from trampling crops
136
     */
137
    protected boolean canTriggerWalking()
138
    {
139
        return false;
140
    }
141
142
    protected void entityInit()
143
    {
144
    }
145
146
    /**
147
     * Called to update the entity's position/logic.
148
     */
149
    public void onUpdate()
150
    {
151
        this.prevPosX = this.posX;
152
        this.prevPosY = this.posY;
153
        this.prevPosZ = this.posZ;
154
155
        if (this.particleAge++ >= this.particleMaxAge)
156
        {
157
            this.setDead();
158
        }
159
160
        this.motionY -= 0.04D * (double)this.particleGravity;
161
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
162
        this.motionX *= 0.9800000190734863D;
163
        this.motionY *= 0.9800000190734863D;
164
        this.motionZ *= 0.9800000190734863D;
165
166
        if (this.onGround)
167
        {
168
            this.motionX *= 0.699999988079071D;
169
            this.motionZ *= 0.699999988079071D;
170
        }
171
    }
172
173
    /**
174
     * Renders the particle
175
     */
176
    public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
177
    {
178
        float f = (float)this.particleTextureIndexX / 16.0F;
179
        float f1 = f + 0.0624375F;
180
        float f2 = (float)this.particleTextureIndexY / 16.0F;
181
        float f3 = f2 + 0.0624375F;
182
        float f4 = 0.1F * this.particleScale;
183
184
        if (this.particleIcon != null)
185
        {
186
            f = this.particleIcon.getMinU();
187
            f1 = this.particleIcon.getMaxU();
188
            f2 = this.particleIcon.getMinV();
189
            f3 = this.particleIcon.getMaxV();
190
        }
191
192
        float f5 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX);
193
        float f6 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY);
194
        float f7 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ);
195
        int i = this.getBrightnessForRender(partialTicks);
196
        int j = i >> 16 & 65535;
197
        int k = i & 65535;
198
        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, this.particleAlpha).lightmap(j, k).endVertex();
199
        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, this.particleAlpha).lightmap(j, k).endVertex();
200
        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, this.particleAlpha).lightmap(j, k).endVertex();
201
        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, this.particleAlpha).lightmap(j, k).endVertex();
202
    }
203
204
    public int getFXLayer()
205
    {
206
        return 0;
207
    }
208
209
    /**
210
     * (abstract) Protected helper method to write subclass entity data to NBT.
211
     */
212
    public void writeEntityToNBT(NBTTagCompound tagCompound)
213
    {
214
    }
215
216
    /**
217
     * (abstract) Protected helper method to read subclass entity data from NBT.
218
     */
219
    public void readEntityFromNBT(NBTTagCompound tagCompund)
220
    {
221
    }
222
223
    /**
224
     * Sets the particle's icon.
225
     */
226
    public void setParticleIcon(TextureAtlasSprite icon)
227
    {
228
        int i = this.getFXLayer();
229
230
        if (i == 1)
231
        {
232
            this.particleIcon = icon;
233
        }
234
        else
235
        {
236
            throw new RuntimeException("Invalid call to Particle.setTex, use coordinate methods");
237
        }
238
    }
239
240
    /**
241
     * Public method to set private field particleTextureIndex.
242
     */
243
    public void setParticleTextureIndex(int particleTextureIndex)
244
    {
245
        if (this.getFXLayer() != 0)
246
        {
247
            throw new RuntimeException("Invalid call to Particle.setMiscTex");
248
        }
249
        else
250
        {
251
            this.particleTextureIndexX = particleTextureIndex % 16;
252
            this.particleTextureIndexY = particleTextureIndex / 16;
253
        }
254
    }
255
256
    public void nextTextureIndexX()
257
    {
258
        ++this.particleTextureIndexX;
259
    }
260
261
    /**
262
     * If returns false, the item will not inflict any damage against entities.
263
     */
264
    public boolean canAttackWithItem()
265
    {
266
        return false;
267
    }
268
269
    public String toString()
270
    {
271
        return this.getClass().getSimpleName() + ", Pos (" + this.posX + "," + this.posY + "," + this.posZ + "), RGBA (" + this.particleRed + "," + this.particleGreen + "," + this.particleBlue + "," + this.particleAlpha + "), Age " + this.particleAge;
272
    }
273
}
274

Deobfuscated MCP 1.8.9 source of EntityFX from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/particle/EntityFX.java), stored verbatim.