EntityDiggingFX .java

net.minecraft.client.particle.EntityDiggingFX (class, 124 lines): members: func_174845_l, setBlockPos, sourceState, sourcePos, getFXLayer, renderParticle.

net.minecraft.client.particleclass124 linesclientextends EntityFX5.7 KB

API Surface (6)

EntityDiggingFX setBlockPos(BlockPos pos)
EntityDiggingFX func_174845_l()
int getFXLayer()
void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
int getBrightnessForRender(float partialTicks)
EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)

Fields & Constants (2)

sourceState
sourcePos

Full Source

EntityDiggingFX.java124 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.particle;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.state.IBlockState;
5
import net.minecraft.client.Minecraft;
6
import net.minecraft.client.renderer.WorldRenderer;
7
import net.minecraft.entity.Entity;
8
import net.minecraft.init.Blocks;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.world.World;
11
12
public class EntityDiggingFX extends EntityFX
13
{
14
    private IBlockState sourceState;
15
    private BlockPos sourcePos;
16
17
    protected EntityDiggingFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, IBlockState state)
18
    {
19
        super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
20
        this.sourceState = state;
21
        this.setParticleIcon(Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state));
22
        this.particleGravity = state.getBlock().blockParticleGravity;
23
        this.particleRed = this.particleGreen = this.particleBlue = 0.6F;
24
        this.particleScale /= 2.0F;
25
    }
26
27
    /**
28
     * Sets the position of the block that this particle came from. Used for calculating texture and color multiplier.
29
     */
30
    public EntityDiggingFX setBlockPos(BlockPos pos)
31
    {
32
        this.sourcePos = pos;
33
34
        if (this.sourceState.getBlock() == Blocks.grass)
35
        {
36
            return this;
37
        }
38
        else
39
        {
40
            int i = this.sourceState.getBlock().colorMultiplier(this.worldObj, pos);
41
            this.particleRed *= (float)(i >> 16 & 255) / 255.0F;
42
            this.particleGreen *= (float)(i >> 8 & 255) / 255.0F;
43
            this.particleBlue *= (float)(i & 255) / 255.0F;
44
            return this;
45
        }
46
    }
47
48
    public EntityDiggingFX func_174845_l()
49
    {
50
        this.sourcePos = new BlockPos(this.posX, this.posY, this.posZ);
51
        Block block = this.sourceState.getBlock();
52
53
        if (block == Blocks.grass)
54
        {
55
            return this;
56
        }
57
        else
58
        {
59
            int i = block.getRenderColor(this.sourceState);
60
            this.particleRed *= (float)(i >> 16 & 255) / 255.0F;
61
            this.particleGreen *= (float)(i >> 8 & 255) / 255.0F;
62
            this.particleBlue *= (float)(i & 255) / 255.0F;
63
            return this;
64
        }
65
    }
66
67
    public int getFXLayer()
68
    {
69
        return 1;
70
    }
71
72
    /**
73
     * Renders the particle
74
     */
75
    public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
76
    {
77
        float f = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F;
78
        float f1 = f + 0.015609375F;
79
        float f2 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F;
80
        float f3 = f2 + 0.015609375F;
81
        float f4 = 0.1F * this.particleScale;
82
83
        if (this.particleIcon != null)
84
        {
85
            f = this.particleIcon.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F));
86
            f1 = this.particleIcon.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F));
87
            f2 = this.particleIcon.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F));
88
            f3 = this.particleIcon.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F));
89
        }
90
91
        float f5 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX);
92
        float f6 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY);
93
        float f7 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ);
94
        int i = this.getBrightnessForRender(partialTicks);
95
        int j = i >> 16 & 65535;
96
        int k = i & 65535;
97
        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(j, k).endVertex();
98
        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(j, k).endVertex();
99
        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(j, k).endVertex();
100
        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(j, k).endVertex();
101
    }
102
103
    public int getBrightnessForRender(float partialTicks)
104
    {
105
        int i = super.getBrightnessForRender(partialTicks);
106
        int j = 0;
107
108
        if (this.worldObj.isBlockLoaded(this.sourcePos))
109
        {
110
            j = this.worldObj.getCombinedLight(this.sourcePos, 0);
111
        }
112
113
        return i == 0 ? j : i;
114
    }
115
116
    public static class Factory implements IParticleFactory
117
    {
118
        public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
119
        {
120
            return (new EntityDiggingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, Block.getStateById(p_178902_15_[0]))).func_174845_l();
121
        }
122
    }
123
}
124

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