feat: randomization-free landing particles
This commit is contained in:
@@ -3185,6 +3185,11 @@ shared_ptr<Particle> LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle
|
||||
int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType);
|
||||
particle = std::make_shared<BreakingItemParticle>(lev, x, y, z, xa, ya, za, Item::items[id], textures, data);
|
||||
}
|
||||
else if( ( eParticleType >= eParticleType_blockdust_base ) && ( eParticleType <= eParticleType_blockdust_last ) )
|
||||
{
|
||||
int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType);
|
||||
particle = dynamic_pointer_cast<Particle>(std::make_shared<TerrainParticle>(lev, x, y, z, xa, ya, za, Tile::tiles[id], 0, data, textures, false)->init(data) );
|
||||
}
|
||||
else if( ( eParticleType >= eParticleType_tilecrack_base ) && ( eParticleType <= eParticleType_tilecrack_last ) )
|
||||
{
|
||||
int id = PARTICLE_CRACK_ID(eParticleType), data = PARTICLE_CRACK_DATA(eParticleType);
|
||||
|
||||
@@ -98,7 +98,7 @@ Particle::Particle(Level *level, double x, double y, double z) : Entity(nullptr,
|
||||
}
|
||||
}
|
||||
|
||||
Particle::Particle(Level *level, double x, double y, double z, double xa, double ya, double za) : Entity(nullptr, false)
|
||||
Particle::Particle(Level *level, double x, double y, double z, double xa, double ya, double za, bool useRandomizedLogic) : Entity(nullptr, false)
|
||||
{
|
||||
_init(level,x,y,z);
|
||||
|
||||
@@ -113,15 +113,28 @@ Particle::Particle(Level *level, double x, double y, double z, double xa, double
|
||||
this->level = nullptr;
|
||||
}
|
||||
|
||||
xd = xa + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
yd = ya + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
zd = za + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
float speed = static_cast<float>(Math::random() + Math::random() + 1) * 0.15f;
|
||||
if (useRandomizedLogic) {
|
||||
xd = xa + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
yd = ya + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
zd = za + static_cast<float>(Math::random() * 2 - 1) * 0.4f;
|
||||
float speed = static_cast<float>(Math::random() + Math::random() + 1) * 0.15f;
|
||||
|
||||
float dd = (float) (Mth::sqrt(xd * xd + yd * yd + zd * zd));
|
||||
xd = xd / dd * speed * 0.4f;
|
||||
yd = yd / dd * speed * 0.4f + 0.1f;
|
||||
zd = zd / dd * speed * 0.4f;}
|
||||
float dd = (float) (Mth::sqrt(xd * xd + yd * yd + zd * zd));
|
||||
xd = xd / dd * speed * 0.4f;
|
||||
yd = yd / dd * speed * 0.4f + 0.1f;
|
||||
zd = zd / dd * speed * 0.4f;
|
||||
}
|
||||
else {
|
||||
xd = xa;
|
||||
yd = ya;
|
||||
zd = za;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Particle::Particle(Level *level, double x, double y, double z, double xa, double ya, double za) : Particle(level, x, y, z, xa, ya, za, true)
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<Particle> Particle::setPower(float power)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ protected:
|
||||
Particle(Level *level, double x, double y, double z);
|
||||
public:
|
||||
Particle(Level *level, double x, double y, double z, double xa, double ya, double za);
|
||||
Particle(Level *level, double x, double y, double z, double xa, double ya, double za, bool useRandomizedLogic);
|
||||
virtual shared_ptr<Particle> setPower(float power);
|
||||
virtual shared_ptr<Particle> scale(float scale);
|
||||
void setColor(float r, float g, float b);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <unordered_map>
|
||||
#include "ParticleType.h"
|
||||
|
||||
ParticleType::ParticleType(const std::string& name, int id, bool overrideLimiter, int paramCount)
|
||||
@@ -10,6 +11,19 @@ ParticleType::ParticleType(const std::string& name, int id, bool overrideLimiter
|
||||
this->paramCount = paramCount;
|
||||
}
|
||||
|
||||
const ParticleType* ParticleType::blockdust = new ParticleType("blockdust_", 0x29, false, 1);
|
||||
const ParticleType* ParticleType::blockcrack = new ParticleType("blockcrack_", 0x28, false, 2);
|
||||
|
||||
static std::unordered_map<int, const ParticleType*>& particleRegistry()
|
||||
{
|
||||
static std::unordered_map<int, const ParticleType*> registry = {
|
||||
{ ParticleType::blockdust->getId(), ParticleType::blockdust },
|
||||
{ ParticleType::blockcrack->getId(), ParticleType::blockcrack },
|
||||
};
|
||||
return registry;
|
||||
}
|
||||
|
||||
|
||||
int ParticleType::getId() const
|
||||
{
|
||||
return id;
|
||||
@@ -34,6 +48,7 @@ const ParticleType* ParticleType::getDefault()
|
||||
|
||||
const ParticleType* ParticleType::byId(int searchId)
|
||||
{
|
||||
|
||||
return nullptr;
|
||||
auto& reg = particleRegistry();
|
||||
auto it = reg.find(searchId);
|
||||
return (it != reg.end()) ? it->second : nullptr;
|
||||
}
|
||||
@@ -20,4 +20,7 @@ public:
|
||||
|
||||
static const ParticleType* byId(int id);
|
||||
static const ParticleType* getDefault();
|
||||
|
||||
static const ParticleType* blockdust;
|
||||
static const ParticleType* blockcrack;
|
||||
};
|
||||
@@ -1683,11 +1683,22 @@ void ServerLevel::flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFoun
|
||||
}
|
||||
void ServerLevel::sendParticles(const ParticleType* type, bool longDistance, double x, double y, double z, int count, double dx, double dy, double dz, double speed, arrayWithLength<int> data)
|
||||
{
|
||||
wchar_t buf[32];
|
||||
swprintf_s(buf, L"%d", type->getId());
|
||||
wstring particleName;
|
||||
if (type != nullptr && type->getId() == ParticleType::blockdust->getId() && data.length > 0)
|
||||
{
|
||||
int tileId = data[0] & Tile::TILE_NUM_MASK;
|
||||
int tileData = (data[0] >> Tile::TILE_NUM_SHIFT) & 0xFF;
|
||||
particleName = std::to_wstring(PARTICLE_BLOCKDUST(tileId, tileData));
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t buf[32];
|
||||
swprintf_s(buf, L"%d", type != nullptr ? type->getId() : 0);
|
||||
particleName = buf;
|
||||
}
|
||||
|
||||
auto packet = make_shared<LevelParticlesPacket>(
|
||||
buf,
|
||||
particleName,
|
||||
(float)x, (float)y, (float)z,
|
||||
(float)dx, (float)dy, (float)dz,
|
||||
(float)speed,
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
#include "../Minecraft.World/net.minecraft.world.level.h"
|
||||
#include "../Minecraft.World/net.minecraft.world.h"
|
||||
|
||||
TerrainParticle::TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures) : Particle(level, x, y, z, xa, ya, za)
|
||||
TerrainParticle::TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures) : TerrainParticle(level, x, y, z, xa, ya, za, tile, face, data, textures, true)
|
||||
{
|
||||
}
|
||||
|
||||
TerrainParticle::TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures, bool useRandomizedLogic) : Particle(level, x, y, z, xa, ya, za, useRandomizedLogic)
|
||||
{
|
||||
this->tile = tile;
|
||||
if (tile == nullptr) return; // tu31 tutorial world fix
|
||||
|
||||
@@ -11,6 +11,7 @@ private:
|
||||
|
||||
public:
|
||||
TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures);
|
||||
TerrainParticle(Level *level, double x, double y, double z, double xa, double ya, double za, Tile *tile, int face, int data, Textures *textures, bool useRandomizedLogic);
|
||||
shared_ptr<TerrainParticle> init(int x, int y, int z, int data); // 4J - added data parameter
|
||||
shared_ptr<TerrainParticle> init(int data);
|
||||
virtual int getParticleTexture();
|
||||
|
||||
Reference in New Issue
Block a user