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/WaterDropParticle.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/WaterDropParticle.cpp')
| -rw-r--r-- | Minecraft.Client/WaterDropParticle.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Minecraft.Client/WaterDropParticle.cpp b/Minecraft.Client/WaterDropParticle.cpp new file mode 100644 index 00000000..90035243 --- /dev/null +++ b/Minecraft.Client/WaterDropParticle.cpp @@ -0,0 +1,55 @@ +#include "stdafx.h" +#include "WaterDropParticle.h" +#include "..\Minecraft.World\JavaMath.h" +#include "..\Minecraft.World\net.minecraft.world.level.h" +#include "..\Minecraft.World\net.minecraft.world.level.material.h" +#include "..\Minecraft.World\net.minecraft.world.level.tile.h" + +WaterDropParticle::WaterDropParticle(Level *level, double x, double y, double z) : Particle(level, x, y, z, 0, 0, 0) +{ + xd *= 0.3f; + yd = (float) Math::random() * 0.2f + 0.1f; + zd *= 0.3f; + + rCol = 1.0f; + gCol = 1.0f; + bCol = 1.0f; + setMiscTex(16+3+random->nextInt(4)); + this->setSize(0.01f, 0.01f); + gravity = 0.06f; + + noPhysics = true; // 4J - optimisation - do we really need collision on these? its really slow... + lifetime = (int) (8 / (Math::random() * 0.8 + 0.2)); +} + +void WaterDropParticle::tick() +{ + xo = x; + yo = y; + zo = z; + + yd -= gravity; + move(xd, yd, zd); + xd *= 0.98f; + yd *= 0.98f; + zd *= 0.98f; + + if (lifetime-- <= 0) remove(); + + if (onGround) + { + if (Math::random() < 0.5) remove(); + xd *= 0.7f; + zd *= 0.7f; + } + + Material *m = level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + if (m->isLiquid() || m->isSolid()) + { + double y0 = Mth::floor(y) + 1 - LiquidTile::getHeight(level->getData(Mth::floor(x), Mth::floor(y), Mth::floor(z))); + if (y < y0) + { + remove(); + } + } +} |
