-
Notifications
You must be signed in to change notification settings - Fork 497
/
EntityDropParticleFX.java
101 lines (84 loc) · 3.39 KB
/
EntityDropParticleFX.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
* <p/>
* BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents
* of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */
package buildcraft.core.lib.client.render;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EntityDropParticleFX extends EntityFX {
/** The height of the current bob */
private int bobTimer;
public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, float particleBlue) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.motionX = this.motionY = this.motionZ = 0.0D;
// if (par8Material == Material.water)
// {
// this.particleRed = 0.0F;
// this.particleGreen = 0.0F;
// this.particleBlue = 1.0F;
// }
// else
// {
// this.particleRed = 1.0F;
// this.particleGreen = 0.0F;
// this.particleBlue = 0.0F;
// }
this.particleRed = particleRed;
this.particleGreen = particleGreen;
this.particleBlue = particleBlue;
this.setParticleTextureIndex(113);
this.setSize(0.01F, 0.01F);
this.particleGravity = 0.06F;
this.bobTimer = 40;
this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
this.motionX = this.motionY = this.motionZ = 0.0D;
}
/** Called to update the entity's position/logic. */
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= this.particleGravity;
if (this.bobTimer-- > 0) {
this.motionX *= 0.02D;
this.motionY *= 0.02D;
this.motionZ *= 0.02D;
this.setParticleTextureIndex(113);
} else {
this.setParticleTextureIndex(112);
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.particleMaxAge-- <= 0) {
this.setDead();
}
if (this.onGround) {
this.setParticleTextureIndex(114);
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.posY);
int z = MathHelper.floor_double(this.posZ);
BlockPos pos = new BlockPos(x, y, z);
Block block = worldObj.getBlockState(pos).getBlock();
Material material = block.getMaterial();
if ((material.isLiquid() || material.isSolid()) && block instanceof IFluidBlock) {
double d0 = MathHelper.floor_double(this.posY) + 1 - ((IFluidBlock) block).getFilledPercentage(worldObj, pos);
if (this.posY < d0) {
this.setDead();
}
}
}
}