From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/RedDustParticle.cpp | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Minecraft.Client/RedDustParticle.cpp (limited to 'Minecraft.Client/RedDustParticle.cpp') diff --git a/Minecraft.Client/RedDustParticle.cpp b/Minecraft.Client/RedDustParticle.cpp new file mode 100644 index 00000000..6a6ad1e1 --- /dev/null +++ b/Minecraft.Client/RedDustParticle.cpp @@ -0,0 +1,75 @@ +#include "stdafx.h" +#include "..\Minecraft.World\JavaMath.h" +#include "RedDustParticle.h" + +void RedDustParticle::init(Level *level, double x, double y, double z, float scale, float rCol, float gCol, float bCol) +{ + xd *= 0.1f; + yd *= 0.1f; + zd *= 0.1f; + + // 4J Stu - If they are all 0 then this particle has been created differently + // If just red is 0 it could be because we have made redstone a completely different colour (eg blue) + if (rCol == 0 && gCol == 0 && bCol == 0) + { + rCol = 1; + } + float brr = (float) Math::random() * 0.4f + 0.6f; + this->rCol = ((float) (Math::random() * 0.2f) + 0.8f) * rCol * brr; + this->gCol = ((float) (Math::random() * 0.2f) + 0.8f) * gCol * brr; + this->bCol = ((float) (Math::random() * 0.2f) + 0.8f) * bCol * brr; + size *= 0.75f; + size *= scale; + oSize = size; + + lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); + lifetime = (int)(lifetime * scale); + noPhysics = false; +} + +RedDustParticle::RedDustParticle(Level *level, double x, double y, double z, float rCol, float gCol, float bCol) : Particle(level, x, y, z, 0, 0, 0) +{ + init(level, x, y, z, 1, rCol, gCol, bCol); +} + +RedDustParticle::RedDustParticle(Level *level, double x, double y, double z, float scale, float rCol, float gCol, float bCol) : Particle(level, x, y, z, 0, 0, 0) +{ + init(level, x, y, z, scale, rCol, gCol, bCol); +} + +void RedDustParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) +{ + float l = ((age + a) / lifetime) * 32; + if (l < 0) l = 0; + if (l > 1) l = 1; + + size = oSize * l; + Particle::render(t, a, xa, ya, za, xa2, za2); +} + +void RedDustParticle::tick() +{ + xo = x; + yo = y; + zo = z; + + if (age++ >= lifetime) remove(); + + setMiscTex(7 - age * 8 / lifetime); + + move(xd, yd, zd); + if (y == yo) + { + xd *= 1.1; + zd *= 1.1; + } + xd *= 0.96f; + yd *= 0.96f; + zd *= 0.96f; + + if (onGround) + { + xd *= 0.7f; + zd *= 0.7f; + } +} -- cgit v1.2.3