Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 3820e47

Browse files
committed
feat: support LeviLamina 0.5.1
fix: fix header
1 parent 92e9113 commit 3820e47

File tree

4 files changed

+180
-17
lines changed

4 files changed

+180
-17
lines changed

src/ParticleAPI.cpp

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ std::vector<std::pair<double, int>> binSplit(double start, double end) {
3434
length -= 2048;
3535
auto point = 1024.0 + start;
3636
start += 2048.0;
37-
lengthMap.push_back({point, 2048});
37+
lengthMap.emplace_back(point, 2048);
3838
}
3939
if (length > 0) {
40-
lengthMap.push_back({end - 1024.0, 2048});
40+
lengthMap.emplace_back(end - 1024.0, 2048);
4141
}
4242
} else {
4343
int potLength = highestOneBit(length);
44-
lengthMap.push_back({start + potLength * 0.5, potLength});
44+
lengthMap.emplace_back(start + potLength * 0.5, potLength);
4545
if (length != potLength || length < size) {
46-
lengthMap.push_back({end - potLength * 0.5, potLength});
46+
lengthMap.emplace_back(end - potLength * 0.5, potLength);
4747
}
4848
}
4949
return lengthMap;
@@ -73,7 +73,7 @@ static std::unordered_map<ParticleCUI::ColorPalette, std::pair<char, mce::Color>
7373
// clang-format on
7474
};
7575

76-
inline static const char getParticleColorType(ParticleCUI::ColorPalette const& p) { return particleColors.at(p).first; }
76+
static char getParticleColorType(ParticleCUI::ColorPalette const& p) { return particleColors.at(p).first; }
7777

7878
extern "C" {
7979
void PTAPI_spawnParticle(int displayRadius, Vec3 const& pos, std::string const& particleName, int dimId) {
@@ -148,6 +148,8 @@ void PTAPI_drawAxialLine(
148148
case ParticleCUI::Direction::POS_X:
149149
vend.x += (float)length;
150150
break;
151+
default:
152+
break;
151153
}
152154
if (length > 0.375) {
153155
PTAPI_drawOrientedLine(displayRadius, vstart, vend, dimId, ParticleCUI::PointSize::PX2, 0.125, 5, color);
@@ -183,6 +185,8 @@ void PTAPI_drawAxialLine(
183185
start = originPoint.x;
184186
end = originPoint.x + length;
185187
break;
188+
default:
189+
break;
186190
}
187191

188192
auto list = binSplit(start, end);
@@ -321,3 +325,54 @@ void PTAPI_drawCircle(
321325
}
322326
}
323327
}
328+
329+
void ParticleCUI::spawnParticle(Vec3 const& pos, std::string const& particleName, int dimId) {
330+
PTAPI_spawnParticle(displayRadius, pos, particleName, dimId);
331+
}
332+
333+
void ParticleCUI::drawPoint(
334+
Vec3 const& pos,
335+
int dimId,
336+
enum PointSize lineWidth,
337+
enum class ParticleCUI::ColorPalette color
338+
) {
339+
PTAPI_drawPoint(displayRadius, pos, dimId, lineWidth, color);
340+
}
341+
void ParticleCUI::drawNumber(Vec3 const& pos, int dimId, enum NumType num, enum class ParticleCUI::ColorPalette color) {
342+
PTAPI_drawNumber(displayRadius, pos, dimId, num, color);
343+
}
344+
void ParticleCUI::drawAxialLine(
345+
const Vec3& originPoint,
346+
enum Direction direction,
347+
double length,
348+
int dimId,
349+
enum class ParticleCUI::ColorPalette color
350+
) {
351+
PTAPI_drawAxialLine(displayRadius, highDetial, doubleSide, originPoint, direction, length, dimId, color);
352+
}
353+
void ParticleCUI::drawOrientedLine(
354+
const Vec3& start,
355+
const Vec3& end,
356+
int dimId,
357+
enum PointSize lineWidth,
358+
double minSpacing,
359+
int maxParticlesNum,
360+
enum class ParticleCUI::ColorPalette color
361+
) {
362+
PTAPI_drawOrientedLine(displayRadius, start, end, dimId, lineWidth, minSpacing, maxParticlesNum, color);
363+
}
364+
void ParticleCUI::drawCuboid(const AABB& aabb, int dimId, enum class ParticleCUI::ColorPalette color) {
365+
PTAPI_drawCuboid(displayRadius, highDetial, doubleSide, aabb, dimId, color);
366+
}
367+
void ParticleCUI::drawCircle(
368+
const Vec3& originPoint,
369+
enum Direction facing,
370+
double radius,
371+
int dimId,
372+
enum PointSize lineWidth,
373+
double minSpacing,
374+
int maxParticlesNum,
375+
enum class ParticleCUI::ColorPalette color
376+
) {
377+
PTAPI_drawCircle(displayRadius, originPoint, facing, radius, dimId, lineWidth, minSpacing, maxParticlesNum, color);
378+
}

src/ParticleAPI.h

Lines changed: 116 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file ParticleAPI.h
2+
* @file ParticlePTAPI_h
33
* @author OEOTYAN (https://github.com/OEOTYAN)
44
* @brief Spawn Particles for Client User Interface
55
*
@@ -8,9 +8,28 @@
88
*/
99
#pragma once
1010
#include "mc/deps/core/mce/Color.h"
11+
#include "mc/math/Vec3.h"
12+
#include "mc/world/level/BlockPos.h"
13+
#include "mc/world/level/levelgen/structure/BoundingBox.h"
14+
#include "mc/world/phys/AABB.h"
15+
16+
17+
#ifdef PARTICLEAPI_EXPORTS
18+
#define PARTICLE_API __declspec(dllexport)
19+
#else
20+
#define PARTICLE_API __declspec(dllimport)
21+
#endif
1122

1223
class ParticleCUI {
1324
public:
25+
unsigned int displayRadius;
26+
bool highDetial;
27+
bool doubleSide;
28+
ParticleCUI() : displayRadius(UINT_MAX), highDetial(true), doubleSide(true) {}
29+
explicit ParticleCUI(unsigned int dr, bool hd = true, bool ds = true)
30+
: displayRadius(dr),
31+
highDetial(hd),
32+
doubleSide(ds) {}
1433
enum Direction : char {
1534
NEG_Y = 0,
1635
POS_Y = 1,
@@ -71,26 +90,114 @@ class ParticleCUI {
7190
PINK,
7291
FAWN,
7392
};
93+
PARTICLE_API void spawnParticle(Vec3 const& pos, std::string const& particleName, int dimId);
94+
95+
PARTICLE_API void drawPoint(
96+
Vec3 const& pos,
97+
int dimId,
98+
enum PointSize lineWidth = PointSize::PX4,
99+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
100+
);
101+
PARTICLE_API void drawNumber(
102+
Vec3 const& pos,
103+
int dimId,
104+
enum NumType num = NumType::NUM0,
105+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
106+
);
107+
PARTICLE_API void drawAxialLine(
108+
const Vec3& originPoint,
109+
enum Direction direction,
110+
double length,
111+
int dimId,
112+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
113+
);
114+
PARTICLE_API void drawOrientedLine(
115+
const Vec3& start,
116+
const Vec3& end,
117+
int dimId,
118+
enum PointSize lineWidth = PointSize::PX4,
119+
double minSpacing = 1,
120+
int maxParticlesNum = 64,
121+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
122+
);
123+
PARTICLE_API void drawCuboid(
124+
const AABB& aabb,
125+
int dimId,
126+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
127+
);
128+
PARTICLE_API void drawCircle(
129+
const Vec3& originPoint,
130+
enum Direction facing,
131+
double radius,
132+
int dimId,
133+
enum PointSize lineWidth = PointSize::PX4,
134+
double minSpacing = 1,
135+
int maxParticlesNum = 64,
136+
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
137+
);
138+
void inline spawnParticle(BlockPos const& pos, std::string const& particleName, int dimId) {
139+
spawnParticle(pos + 0.5f, particleName, dimId);
140+
}
141+
void inline drawPoint(
142+
BlockPos const& pos,
143+
int dimId,
144+
PointSize lineWidth,
145+
enum class ParticleCUI::ColorPalette color
146+
) {
147+
drawPoint(pos + 0.5f, dimId, lineWidth, color);
148+
}
149+
void inline drawNumber(BlockPos const& pos, int dimId, NumType num, enum class ParticleCUI::ColorPalette color) {
150+
drawNumber(pos + 0.5f, dimId, num, color);
151+
}
152+
void inline drawOrientedLine(
153+
const BlockPos& start,
154+
const BlockPos& end,
155+
int dimId,
156+
PointSize lineWidth,
157+
double minSpacing,
158+
int maxParticlesNum,
159+
enum class ParticleCUI::ColorPalette color
160+
) {
161+
drawOrientedLine(start + 0.5f, end + 0.5f, dimId, lineWidth, minSpacing, maxParticlesNum, color);
162+
}
163+
void inline drawCuboid(const BoundingBox& box, int dimId, enum class ParticleCUI::ColorPalette color) {
164+
drawCuboid(box, dimId, color);
165+
}
166+
void inline drawCuboid(const BlockPos& pos, int dimId, enum class ParticleCUI::ColorPalette color) {
167+
drawCuboid(pos, dimId, color);
168+
}
169+
void inline drawCircle(
170+
const BlockPos& originPoint,
171+
Direction facing,
172+
double radius,
173+
int dimId,
174+
PointSize lineWidth,
175+
double minSpacing,
176+
int maxParticlesNum,
177+
enum class ParticleCUI::ColorPalette color
178+
) {
179+
drawCircle(originPoint + 0.5f, facing, radius, dimId, lineWidth, minSpacing, maxParticlesNum, color);
180+
}
74181
};
75182

76183
extern "C" {
77-
__declspec(dllexport
78-
) void PTAPI_spawnParticle(int displayRadius, class Vec3 const& pos, std::string const& particleName, int dimId);
79-
__declspec(dllexport) void PTAPI_drawPoint(
184+
PARTICLE_API void
185+
PTAPI_spawnParticle(int displayRadius, class Vec3 const& pos, std::string const& particleName, int dimId);
186+
PARTICLE_API void PTAPI_drawPoint(
80187
int displayRadius,
81188
class Vec3 const& pos,
82189
int dimId,
83190
char lineWidth = ParticleCUI::PointSize::PX4,
84191
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
85192
);
86-
__declspec(dllexport) void PTAPI_drawNumber(
193+
PARTICLE_API void PTAPI_drawNumber(
87194
int displayRadius,
88195
class Vec3 const& pos,
89196
int dimId,
90197
char num = ParticleCUI::NumType::NUM0,
91198
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
92199
);
93-
__declspec(dllexport) void PTAPI_drawAxialLine(
200+
PARTICLE_API void PTAPI_drawAxialLine(
94201
int displayRadius,
95202
bool highDetial,
96203
bool doubleSide,
@@ -100,7 +207,7 @@ __declspec(dllexport) void PTAPI_drawAxialLine(
100207
int dimId,
101208
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
102209
);
103-
__declspec(dllexport) void PTAPI_drawOrientedLine(
210+
PARTICLE_API void PTAPI_drawOrientedLine(
104211
int displayRadius,
105212
const class Vec3& start,
106213
const class Vec3& end,
@@ -110,15 +217,15 @@ __declspec(dllexport) void PTAPI_drawOrientedLine(
110217
int maxParticlesNum = 64,
111218
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
112219
);
113-
__declspec(dllexport) void PTAPI_drawCuboid(
220+
PARTICLE_API void PTAPI_drawCuboid(
114221
int displayRadius,
115222
bool highDetial,
116223
bool doubleSide,
117224
const class AABB& aabb,
118225
int dimId,
119226
enum class ParticleCUI::ColorPalette color = ParticleCUI::ColorPalette::WHITE
120227
);
121-
__declspec(dllexport) void PTAPI_drawCircle(
228+
PARTICLE_API void PTAPI_drawCircle(
122229
int displayRadius,
123230
const class Vec3& originPoint,
124231
char facing,

tooth.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "github.com/LiteLDev/LegacyParticleAPI",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"info": {
66
"name": "LegacyParticleAPI",
77
"description": "ParticleAPI ported from LiteLoaderBDS",
@@ -11,7 +11,7 @@
1111
"library"
1212
]
1313
},
14-
"asset_url": "https://github.com/LiteLDev/LegacyParticleAPI/releases/download/v0.1.0/LegacyParticleAPI-windows-x64.zip",
14+
"asset_url": "https://github.com/LiteLDev/LegacyParticleAPI/releases/download/v0.1.1/LegacyParticleAPI-windows-x64.zip",
1515
"files": {
1616
"place": [
1717
{

xmake.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ target("LegacyParticleAPI")
1414
"/utf-8"
1515
)
1616
add_defines(
17-
"_HAS_CXX23=1"
17+
"_HAS_CXX23=1",
18+
"PARTICLEAPI_EXPORTS"
1819
)
1920
add_files(
2021
"src/**.cpp"

0 commit comments

Comments
 (0)