diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/CritParticle.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/CritParticle.cpp')
| -rw-r--r-- | Minecraft.Client/CritParticle.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Minecraft.Client/CritParticle.cpp b/Minecraft.Client/CritParticle.cpp new file mode 100644 index 00000000..6c71b027 --- /dev/null +++ b/Minecraft.Client/CritParticle.cpp @@ -0,0 +1,61 @@ +#include "stdafx.h" +#include "CritParticle.h" +#include "..\Minecraft.World\net.minecraft.world.entity.h" +#include "..\Minecraft.World\Random.h" +#include "..\Minecraft.World\net.minecraft.world.phys.h" +#include "..\Minecraft.World\net.minecraft.world.level.h" + +void CritParticle::_init(Level *level, shared_ptr<Entity> entity, ePARTICLE_TYPE type) +{ + life = 0; + this->entity = entity; + lifeTime = 3; + particleName = type; + // 4J-PB - can't use a shared_from_this in the constructor + //tick(); +} + +CritParticle::CritParticle(Level *level, shared_ptr<Entity> entity) : Particle(level, entity->x, entity->bb->y0 + entity->bbHeight / 2, entity->z, entity->xd, entity->yd, entity->zd) +{ + _init(level,entity,eParticleType_crit); +} + +CritParticle::CritParticle(Level *level, shared_ptr<Entity> entity, ePARTICLE_TYPE type) : Particle(level, entity->x, entity->bb->y0 + entity->bbHeight / 2, entity->z, entity->xd, entity->yd, entity->zd) +{ + _init(level, entity, type); +} + +// 4J - Added this so that we can use some shared_ptr functions that were needed in the ctor +void CritParticle::CritParticlePostConstructor(void) +{ + tick(); +} + +void CritParticle::render(Tesselator *t, float a, float xa, float ya, float za, float xa2, float za2) +{ +} + +void CritParticle::tick() +{ + for (int i=0; i<16; i++) + { + double xa = random->nextFloat()*2-1; + double ya = random->nextFloat()*2-1; + double za = random->nextFloat()*2-1; + if (xa*xa+ya*ya+za*za>1) continue; + double x = entity->x+xa*entity->bbWidth/4; + double y = entity->bb->y0+entity->bbHeight/2+ya*entity->bbHeight/4; + double z = entity->z+za*entity->bbWidth/4; + level->addParticle(particleName, x, y, z, xa, ya+0.2, za); + } + life++; + if (life >= lifeTime) + { + remove(); + } +} + +int CritParticle::getParticleTexture() +{ + return ParticleEngine::ENTITY_PARTICLE_TEXTURE; +}
\ No newline at end of file |
