EntityRainFX .java

net.minecraft.client.particle.EntityRainFX (class, 94 lines): extends EntityFX. members: Factory, onUpdate. imports: BlockLiquid, Block, Material.

net.minecraft.client.particleclass94 linesclientextends EntityFX3.0 KB

API Surface (2)

void onUpdate()
EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)

Full Source

EntityRainFX.java94 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.particle;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.BlockLiquid;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.state.IBlockState;
7
import net.minecraft.util.BlockPos;
8
import net.minecraft.util.MathHelper;
9
import net.minecraft.world.World;
10
11
public class EntityRainFX extends EntityFX
12
{
13
    protected EntityRainFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn)
14
    {
15
        super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
16
        this.motionX *= 0.30000001192092896D;
17
        this.motionY = Math.random() * 0.20000000298023224D + 0.10000000149011612D;
18
        this.motionZ *= 0.30000001192092896D;
19
        this.particleRed = 1.0F;
20
        this.particleGreen = 1.0F;
21
        this.particleBlue = 1.0F;
22
        this.setParticleTextureIndex(19 + this.rand.nextInt(4));
23
        this.setSize(0.01F, 0.01F);
24
        this.particleGravity = 0.06F;
25
        this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
26
    }
27
28
    /**
29
     * Called to update the entity's position/logic.
30
     */
31
    public void onUpdate()
32
    {
33
        this.prevPosX = this.posX;
34
        this.prevPosY = this.posY;
35
        this.prevPosZ = this.posZ;
36
        this.motionY -= (double)this.particleGravity;
37
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
38
        this.motionX *= 0.9800000190734863D;
39
        this.motionY *= 0.9800000190734863D;
40
        this.motionZ *= 0.9800000190734863D;
41
42
        if (this.particleMaxAge-- <= 0)
43
        {
44
            this.setDead();
45
        }
46
47
        if (this.onGround)
48
        {
49
            if (Math.random() < 0.5D)
50
            {
51
                this.setDead();
52
            }
53
54
            this.motionX *= 0.699999988079071D;
55
            this.motionZ *= 0.699999988079071D;
56
        }
57
58
        BlockPos blockpos = new BlockPos(this);
59
        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
60
        Block block = iblockstate.getBlock();
61
        block.setBlockBoundsBasedOnState(this.worldObj, blockpos);
62
        Material material = iblockstate.getBlock().getMaterial();
63
64
        if (material.isLiquid() || material.isSolid())
65
        {
66
            double d0 = 0.0D;
67
68
            if (iblockstate.getBlock() instanceof BlockLiquid)
69
            {
70
                d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
71
            }
72
            else
73
            {
74
                d0 = block.getBlockBoundsMaxY();
75
            }
76
77
            double d1 = (double)MathHelper.floor_double(this.posY) + d0;
78
79
            if (this.posY < d1)
80
            {
81
                this.setDead();
82
            }
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 EntityRainFX(worldIn, xCoordIn, yCoordIn, zCoordIn);
91
        }
92
    }
93
}
94

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