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/FootstepParticle.cpp | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Minecraft.Client/FootstepParticle.cpp (limited to 'Minecraft.Client/FootstepParticle.cpp') diff --git a/Minecraft.Client/FootstepParticle.cpp b/Minecraft.Client/FootstepParticle.cpp new file mode 100644 index 00000000..18331b32 --- /dev/null +++ b/Minecraft.Client/FootstepParticle.cpp @@ -0,0 +1,63 @@ +#include "stdafx.h" +#include "FootstepParticle.h" +#include "Textures.h" +#include "Tesselator.h" +#include "..\Minecraft.World\Mth.h" +#include "..\Minecraft.World\net.minecraft.world.level.h" + +FootstepParticle::FootstepParticle(Textures *textures, Level *level, double x, double y, double z) : Particle(level, x, y, z, 0, 0, 0) +{ + // 4J added initialisers + life = 0; + lifeTime = 0; + + this->textures = textures; + xd = yd = zd = 0; + lifeTime = 200; +} + +void FootstepParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) +{ + float time = (life + a) / lifeTime; + time = time * time; + + float alpha = 2 - time * 2; + if (alpha > 1) alpha = 1; + alpha = alpha * 0.2f; + + glDisable(GL_LIGHTING); + float r = 2 / 16.0f; + + float xx = (float) (x - xOff); + float yy = (float) (y - yOff); + float zz = (float) (z - zOff); + + float br = level->getBrightness(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + + textures->bindTexture(TN_MISC_FOOTSTEP);//L"/misc/footprint.png")); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + t->begin(); + t->color(br, br, br, alpha); + t->vertexUV((float)(xx - r), (float)( yy), (float)( zz + r), (float)( 0), (float)( 1)); + t->vertexUV((float)(xx + r), (float)( yy), (float)( zz + r), (float)( 1), (float)( 1)); + t->vertexUV((float)(xx + r), (float)( yy), (float)( zz - r), (float)( 1), (float)( 0)); + t->vertexUV((float)(xx - r), (float)( yy), (float)( zz - r), (float)( 0), (float)( 0)); + t->end(); + + glDisable(GL_BLEND); + glEnable(GL_LIGHTING); + +} + +void FootstepParticle::tick() +{ + life++; + if (life == lifeTime) remove(); +} + +int FootstepParticle::getParticleTexture() +{ + return ParticleEngine::ENTITY_PARTICLE_TEXTURE; +} \ No newline at end of file -- cgit v1.2.3