diff --git a/src/Particle.c b/src/Particle.c index ebcb36b0b..949d780b0 100644 --- a/src/Particle.c +++ b/src/Particle.c @@ -307,13 +307,33 @@ struct CustomParticle { struct CustomParticleEffect Particles_CustomEffects[256]; static struct CustomParticle custom_particles[PARTICLES_MAX]; static int custom_count; +static cc_uint8 collideFlags; +#define EXPIRES_UPON_TOUCHING_GROUND (1 << 0) +#define SOLID_COLLIDES (1 << 1) +#define LIQUID_COLLIDES (1 << 2) +#define LEAF_COLLIDES (1 << 3) + +static cc_bool CustomParticle_CanPass(BlockID block) { + cc_uint8 draw = Blocks.Draw[block]; + if (draw == DRAW_TRANSPARENT_THICK && !(collideFlags & LEAF_COLLIDES)) { + return true; + } + cc_uint8 collide = Blocks.Collide[block]; + if (collide == COLLIDE_SOLID && (collideFlags & SOLID_COLLIDES)) { + return false; + } + if (collide == COLLIDE_LIQUID && (collideFlags & LIQUID_COLLIDES)) { + return false; + } + return true; +} static cc_bool CustomParticle_Tick(struct CustomParticle* p, double delta) { struct CustomParticleEffect* e = &Particles_CustomEffects[p->effectId]; particle_hitTerrain = false; - - return Particle_PhysicsTick(&p->base, e->gravity, RainParticle_CanPass, delta) - || (particle_hitTerrain && e->expireUponTouchingGround); + collideFlags = e->collideFlags; + return Particle_PhysicsTick(&p->base, e->gravity, CustomParticle_CanPass, delta) + || (particle_hitTerrain && e->collideFlags & EXPIRES_UPON_TOUCHING_GROUND); } static void CustomParticle_Render(struct CustomParticle* p, float t, VertexP3fT2fC4b* vertices) { diff --git a/src/Particle.h b/src/Particle.h index 93e4fd6af..9cf66db67 100644 --- a/src/Particle.h +++ b/src/Particle.h @@ -22,7 +22,7 @@ struct CustomParticleEffect { PackedCol tintCol; cc_uint8 frameCount; cc_uint8 particleCount; - cc_bool expireUponTouchingGround; + cc_uint8 collideFlags; cc_bool fullBright; float size; float sizeVariation; diff --git a/src/Protocol.c b/src/Protocol.c index 5b09148de..763a5d5cd 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1361,8 +1361,8 @@ static void CPE_DefineEffect(cc_uint8* data) { e->baseLifetime = (int)Stream_GetU32_BE(data + 25) / 10000.0f; e->lifetimeVariation = (int)Stream_GetU32_BE(data + 29) / 10000.0f; - e->expireUponTouchingGround = data[33]; - e->fullBright = data[34]; + e->collideFlags = data[33]; + e->fullBright = data[34]; } static void CPE_SpawnEffect(cc_uint8* data) {