forked from HbmMods/Hbm-s-Nuclear-Tech-GIT
/
ParticleRadiationFog.java
123 lines (91 loc) · 4.61 KB
/
ParticleRadiationFog.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.hbm.particle;
import java.util.Random;
import com.hbm.main.ModEventHandlerClient;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ParticleRadiationFog extends Particle {
private int maxAge;
public ParticleRadiationFog(World worldIn, double posXIn, double posYIn, double posZIn) {
super(worldIn, posXIn, posYIn, posZIn);
maxAge = 100 + rand.nextInt(40);
this.particleRed = this.particleGreen = this.particleBlue = 0;
this.particleScale = 7.5F;
this.particleTexture = ModEventHandlerClient.fog;
}
public ParticleRadiationFog(World p_i1218_1_, double p_i1218_2_, double p_i1218_4_, double p_i1218_6_, float red, float green, float blue, float scale) {
super(p_i1218_1_, p_i1218_2_, p_i1218_4_, p_i1218_6_);
maxAge = 100 + rand.nextInt(40);
this.particleRed = red;
this.particleGreen = green;
this.particleBlue = blue;
this.particleScale = scale;
this.particleTexture = ModEventHandlerClient.fog;
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if(maxAge < 400)
{
maxAge = 400;
}
this.particleAge++;
if (this.particleAge >= maxAge)
{
this.setExpired();
}
this.motionX *= 0.9599999785423279D;
this.motionY *= 0.9599999785423279D;
this.motionZ *= 0.9599999785423279D;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
}
@Override
public int getFXLayer() {
return 1;
}
@Override
public boolean shouldDisableDepth() {
return true;
}
@Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float alpha = 0;
alpha = (float) Math.sin(particleAge * Math.PI / (400F)) * 0.25F;
this.particleRed = 0.85F;
this.particleGreen = 0.9F;
this.particleBlue = 0.5F;
this.particleAlpha = MathHelper.clamp(alpha, 0, 1);
Random rand = new Random(50);
for(int i = 0; i < 25; i++) {
double dX = (rand.nextGaussian() - 1D) * 2.5D;
double dY = (rand.nextGaussian() - 1D) * 0.15D;
double dZ = (rand.nextGaussian() - 1D) * 2.5D;
double size = rand.nextDouble() * particleScale;
int j = this.getBrightnessForRender(partialTicks);
int k = j >> 16 & 65535;
int l = j & 65535;
float pX = (float) ((this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX) + rand.nextGaussian() * 0.5);
float pY = (float) ((this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY) + rand.nextGaussian() * 0.5);
float pZ = (float) ((this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ) + rand.nextGaussian() * 0.5);
buffer.pos((double)(pX - rotationX * size - rotationXY * size) + dX, (double)(pY - rotationZ * size) + dY, (double)(pZ - rotationYZ * size - rotationXZ * size) + dZ).tex(particleTexture.getMaxU(), particleTexture.getMaxV()).color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(k, l).endVertex();
buffer.pos((double)(pX - rotationX * size + rotationXY * size) + dX, (double)(pY + rotationZ * size) + dY, (double)(pZ - rotationYZ * size + rotationXZ * size) + dZ).tex(particleTexture.getMaxU(), particleTexture.getMinV()).color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(k, l).endVertex();
buffer.pos((double)(pX + rotationX * size + rotationXY * size) + dX, (double)(pY + rotationZ * size) + dY, (double)(pZ + rotationYZ * size + rotationXZ * size) + dZ).tex(particleTexture.getMinU(), particleTexture.getMinV()).color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(k, l).endVertex();
buffer.pos((double)(pX + rotationX * size - rotationXY * size) + dX, (double)(pY - rotationZ * size) + dY, (double)(pZ + rotationYZ * size - rotationXZ * size) + dZ).tex(particleTexture.getMinU(), particleTexture.getMaxV()).color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(k, l).endVertex();
}
}
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 240;
}
}