aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/HugeExplosionParticle.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/HugeExplosionParticle.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/HugeExplosionParticle.cpp')
-rw-r--r--Minecraft.Client/HugeExplosionParticle.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/Minecraft.Client/HugeExplosionParticle.cpp b/Minecraft.Client/HugeExplosionParticle.cpp
new file mode 100644
index 00000000..273eed2b
--- /dev/null
+++ b/Minecraft.Client/HugeExplosionParticle.cpp
@@ -0,0 +1,82 @@
+#include "stdafx.h"
+#include "HugeExplosionParticle.h"
+#include "..\Minecraft.World\Random.h"
+#include "Textures.h"
+#include "Tesselator.h"
+#include "Lighting.h"
+
+HugeExplosionParticle::HugeExplosionParticle(Textures *textures, Level *level, double x, double y, double z, double xa, double ya, double za) : Particle(level,x,y,z,0,0,0)
+{
+ life = 0;
+
+ this->textures = textures;
+ lifeTime = 6 + random->nextInt(4);
+
+ // rCol = gCol = bCol = random->nextFloat() * 0.6f + 0.4f;
+
+ unsigned int clr = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Particle_HugeExplosion ); //0x999999
+ double r = ( (clr>>16)&0xFF )/255.0f, g = ( (clr>>8)&0xFF )/255.0, b = ( clr&0xFF )/255.0;
+
+ double br = random->nextFloat() * 0.6 + 0.4;
+ rCol = r * br;
+ gCol = g * br;
+ bCol = b * br;
+
+ size = 1 - (float) xa * 0.5f;
+}
+
+void HugeExplosionParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2)
+{
+ int tex = (int) ((life + a) * 15 / lifeTime);
+ if (tex > 15) return;
+ textures->bindTexture(TN_MISC_EXPLOSION); // 4J was "/misc/explosion.png"
+
+ float u0 = (tex % 4) / 4.0f;
+ float u1 = u0 + 0.999f / 4.0f;
+ float v0 = (tex / 4) / 4.0f;
+ float v1 = v0 + 0.999f / 4.0f;
+
+ float r = 2.0f * size;
+
+ float x = (float) (xo + (this->x - xo) * a - xOff);
+ float y = (float) (yo + (this->y - yo) * a - yOff);
+ float z = (float) (zo + (this->z - zo) * a - zOff);
+
+ // 4J - don't render explosion particles that are less than 3 metres away, to try and avoid large particles that are causing us problems with photosensitivity testing
+ float distSq = (x*x + y*y + z*z);
+ if( distSq < ( 3.0f * 3.0f )) return;
+
+ glColor4f(1, 1, 1, 1);
+ glDisable(GL_LIGHTING);
+ Lighting::turnOff();
+ t->begin();
+ t->color(rCol, gCol, bCol, 1.0f);
+ t->normal(0, 1, 0);
+ t->tex2(0x00f0);
+ t->vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u1, v1);
+ t->vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u1, v0);
+ t->vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0);
+ t->vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v1);
+ t->end();
+ glPolygonOffset(0, 0.0f);
+ glEnable(GL_LIGHTING);
+}
+
+int HugeExplosionParticle::getLightColor(float a)
+{
+ return 0xf0f0;
+}
+
+void HugeExplosionParticle::tick()
+{
+ xo = x;
+ yo = y;
+ zo = z;
+ life++;
+ if (life == lifeTime) remove();
+}
+
+int HugeExplosionParticle::getParticleTexture()
+{
+ return ParticleEngine::ENTITY_PARTICLE_TEXTURE;
+} \ No newline at end of file