From 8bdce1122031d18e1c77cf6852be3a60fc7fc7ab Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Sat, 22 Feb 2020 00:25:22 -0800 Subject: [PATCH] Add tint and fixed size to be divided by 32 --- src/Particle.c | 1 + src/Particle.h | 1 + src/Protocol.c | 17 +++++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Particle.c b/src/Particle.c index 48474957c..a458b0ab1 100644 --- a/src/Particle.c +++ b/src/Particle.c @@ -332,6 +332,7 @@ static void CustomParticle_Render(struct CustomParticle* p, float t, VertexP3fT2 x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z); col = p->prop->fullBright ? PACKEDCOL_WHITE : (World_Contains(x, y, z) ? Lighting_Col(x, y, z) : Env.SunCol); + col = PackedCol_Tint(col, p->prop->tint); Particle_DoRender(&size, &pos, &rec, col, vertices); } diff --git a/src/Particle.h b/src/Particle.h index 40a187765..05432e846 100644 --- a/src/Particle.h +++ b/src/Particle.h @@ -19,6 +19,7 @@ struct Particle { struct CustomParticleProperty { TextureRec rec; + PackedCol tint; int frameCount; int particleCount; //how many of this particle are spawned per spawn-packet float size; //size of the particle in fixed-point world units (e.g. 32 is a full block's length) diff --git a/src/Protocol.c b/src/Protocol.c index 251d181b9..e09c8e911 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1346,10 +1346,13 @@ static void CPE_DefineParticle(cc_uint8* data) { cc_uint8 V1 = data[2]; cc_uint8 U2 = data[3]; cc_uint8 V2 = data[4]; - cc_uint8 frameCount = data[5]; - cc_uint8 particleCount = data[6]; - cc_uint8 size = data[7]; - data += 8; + cc_uint8 tintRed = data[5]; + cc_uint8 tintGreen = data[6]; + cc_uint8 tintBlue = data[7]; + cc_uint8 frameCount = data[8]; + cc_uint8 particleCount = data[9]; + cc_uint8 size = data[10]; + data += 11; int sizeVariation = (int)Stream_GetU32_BE(&data[0]); int spread = (int)Stream_GetU32_BE(&data[4]); int speed = (int)Stream_GetU32_BE(&data[8]); @@ -1366,9 +1369,11 @@ static void CPE_DefineParticle(cc_uint8* data) { //e.g. bounds of 0 0, 16 16 makes an 8x8 icon in the default 128x128 particles.png TextureRec rec = { U1/256, V1/256, U2/256, V2/256 }; prop->rec = rec; + PackedCol tint = PackedCol_Make(tintRed, tintGreen, tintBlue, 255); + prop->tint = tint; prop->frameCount = frameCount; prop->particleCount = particleCount; - prop->size = size; + prop->size = size * 0.03125; //divided by 32 to turn it into world units prop->sizeVariation = sizeVariation / 10000.0f; prop->spread = spread; prop->speed = speed / 10000.0f; @@ -1434,7 +1439,7 @@ static void CPE_Reset(void) { Net_Set(OPCODE_SET_HOTBAR, CPE_SetHotbar, 3); Net_Set(OPCODE_SET_SPAWNPOINT, CPE_SetSpawnPoint, 9); Net_Set(OPCODE_VELOCITY_CONTROL, CPE_VelocityControl, 16); - Net_Set(OPCODE_DEFINE_PARTICLE, CPE_DefineParticle, 35); + Net_Set(OPCODE_DEFINE_PARTICLE, CPE_DefineParticle, 38); Net_Set(OPCODE_SPAWN_PARTICLE, CPE_SpawnParticle, 26); }