Skip to content

Commit bc50c70

Browse files
committed
feat: support LeviLamina 1.5.1
1 parent 51cdf89 commit bc50c70

File tree

10 files changed

+90
-69
lines changed

10 files changed

+90
-69
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.14.0] - 2025-09-23
11+
12+
### Changed
13+
14+
- Supported LeviLamina 1.5.0 @ShrBox
15+
1016
## [0.13.2] - 2025-08-07
1117

1218
### Fixed
@@ -1004,7 +1010,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10041010
[#309]: https://github.com/LiteLDev/LegacyScriptEngine/issues/309
10051011
[#310]: https://github.com/LiteLDev/LegacyScriptEngine/issues/310
10061012

1007-
[Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.13.2...HEAD
1013+
[Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.14.0...HEAD
1014+
[0.14.0]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.13.2...v0.14.0
10081015
[0.13.2]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.13.1...v0.13.2
10091016
[0.13.1]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.13.0...v0.13.1
10101017
[0.13.0]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.12.1...v0.13.0

src/legacy/api/BlockAPI.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,28 +172,28 @@ Local<Value> BlockClass::getPos() {
172172
Local<Value> BlockClass::getTileData() {
173173
try {
174174
// preloaded
175-
return Number::newNumber(block->getLegacyBlock().getVariant(*block));
175+
return Number::newNumber(block->getBlockType().getVariant(*block));
176176
}
177177
CATCH("Fail in getTileData!");
178178
}
179179

180180
Local<Value> BlockClass::getVariant() {
181181
try {
182-
return Number::newNumber(block->getLegacyBlock().getVariant(*block));
182+
return Number::newNumber(block->getBlockType().getVariant(*block));
183183
}
184184
CATCH("Fail in getVariant!");
185185
}
186186

187187
Local<Value> BlockClass::getTranslucency() {
188188
try {
189-
return Number::newNumber(block->getLegacyBlock().mTranslucency);
189+
return Number::newNumber(block->getBlockType().mTranslucency);
190190
}
191191
CATCH("Fail in getTranslucency!");
192192
}
193193

194194
Local<Value> BlockClass::getThickness() {
195195
try {
196-
return Number::newNumber(block->getLegacyBlock().mThickness);
196+
return Number::newNumber(block->getBlockType().mThickness);
197197
}
198198
CATCH("Fail in getThickness!");
199199
}
@@ -207,7 +207,7 @@ Local<Value> BlockClass::isAir() {
207207

208208
Local<Value> BlockClass::isBounceBlock() {
209209
try {
210-
return Boolean::newBoolean(block->getLegacyBlock().isBounceBlock());
210+
return Boolean::newBoolean(block->getBlockType().isBounceBlock());
211211
}
212212
CATCH("Fail in isBounceBlock!");
213213
}
@@ -235,35 +235,35 @@ Local<Value> BlockClass::isDoorBlock() {
235235

236236
Local<Value> BlockClass::isFenceBlock() {
237237
try {
238-
return Boolean::newBoolean(block->getLegacyBlock().isFenceBlock());
238+
return Boolean::newBoolean(block->getBlockType().isFenceBlock());
239239
}
240240
CATCH("Fail in isFenceBlock!");
241241
}
242242

243243
Local<Value> BlockClass::isFenceGateBlock() {
244244
try {
245-
return Boolean::newBoolean(block->getLegacyBlock().isFenceGateBlock());
245+
return Boolean::newBoolean(block->getBlockType().isFenceGateBlock());
246246
}
247247
CATCH("Fail in isFenceGateBlock!");
248248
}
249249

250250
Local<Value> BlockClass::isThinFenceBlock() {
251251
try {
252-
return Boolean::newBoolean(block->getLegacyBlock().isThinFenceBlock());
252+
return Boolean::newBoolean(block->getBlockType().isThinFenceBlock());
253253
}
254254
CATCH("Fail in isThinFenceBlock!");
255255
}
256256

257257
Local<Value> BlockClass::isHeavyBlock() {
258258
try {
259-
return Boolean::newBoolean(block->getLegacyBlock().mFalling);
259+
return Boolean::newBoolean(block->getBlockType().mFalling);
260260
}
261261
CATCH("Fail in isHeavyBlock!");
262262
}
263263

264264
Local<Value> BlockClass::isStemBlock() {
265265
try {
266-
return Boolean::newBoolean(block->getLegacyBlock().isStemBlock());
266+
return Boolean::newBoolean(block->getBlockType().isStemBlock());
267267
}
268268
CATCH("Fail in isStemBlock!");
269269
}
@@ -285,8 +285,7 @@ Local<Value> BlockClass::isUnbreakable() {
285285
Local<Value> BlockClass::isWaterBlockingBlock() {
286286
try {
287287
return Boolean::newBoolean(
288-
block->mDirectData->mWaterDetectionRule->mUnk21e36d.as<LiquidReaction>()
289-
== LiquidReaction::Blocking
288+
block->mDirectData->mWaterDetectionRule->mOnLiquidTouches == LiquidReaction::Blocking
290289
);
291290
}
292291
CATCH("Fail in isWaterBlockingBlock!");
@@ -359,7 +358,7 @@ Local<Value> BlockClass::hasContainer(const Arguments&) {
359358
.lock()
360359
->getBlockSourceFromMainChunkSource()
361360
.getBlock(blockPos.getBlockPos());
362-
return Boolean::newBoolean(bl.getLegacyBlock().isContainerBlock());
361+
return Boolean::newBoolean(bl.getBlockType().isContainerBlock());
363362
}
364363
CATCH("Fail in hasContainer!");
365364
}
@@ -379,7 +378,7 @@ Local<Value> BlockClass::getContainer(const Arguments&) {
379378

380379
Local<Value> BlockClass::hasBlockEntity(const Arguments&) {
381380
try {
382-
return Boolean::newBoolean(block->getLegacyBlock().mBlockEntityType != BlockActorType::Undefined);
381+
return Boolean::newBoolean(block->getBlockType().mBlockEntityType != BlockActorType::Undefined);
383382
}
384383
CATCH("Fail in hasBlockEntity!");
385384
}
@@ -469,7 +468,7 @@ Local<Value> McClass::getBlock(const Arguments& args) {
469468
return {};
470469
}
471470
auto& block = lc->getBlock(
472-
ChunkBlockPos{(uchar)(pos.x & 0xf), (uchar)(pos.z & 0xf), ChunkLocalHeight{(short)pos.y - minHeight}}
471+
ChunkBlockPos{(uchar)(pos.x & 0xf), ChunkLocalHeight{(short)pos.y - minHeight}, (uchar)(pos.z & 0xf)}
473472
);
474473
return BlockClass::newBlock(block, pos.getBlockPos(), pos.dim);
475474
}

src/legacy/api/CommandAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Local<Value> McClass::runcmdEx(const Arguments& args) {
208208
if (command) {
209209
CommandOutput output(CommandOutputType::AllOutput);
210210
command->run(origin, output);
211-
static std::shared_ptr<Localization> localization =
211+
static std::shared_ptr<const Localization> localization =
212212
getI18n().getLocaleFor(getI18n().getCurrentLanguage()->mCode);
213213
for (auto& msg : output.mMessages) {
214214
outputStr += getI18n().get(msg.mMessageId, msg.mParams, localization).append("\n");

src/legacy/api/EntityAPI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Local<Value> EntityClass::isInsidePortal() {
229229

230230
auto component = entity->getEntityContext().tryGetComponent<InsideBlockComponent>();
231231
if (component) {
232-
auto& fullName = component->mInsideBlock->getLegacyBlock().mNameInfo->mFullName;
232+
auto& fullName = component->mInsideBlock->getBlockType().mNameInfo->mFullName;
233233
return Boolean::newBoolean(
234234
*fullName == VanillaBlockTypeIds::Portal() || *fullName == VanillaBlockTypeIds::EndPortal()
235235
);
@@ -1376,7 +1376,7 @@ Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
13761376
false,
13771377
true,
13781378
[&solidOnly, &fullOnly, &includeLiquid](BlockSource const&, Block const& block, bool) {
1379-
if (solidOnly && !block.mCachedComponentData->mUnkd6c5eb.as<bool>()) {
1379+
if (solidOnly && !block.mCachedComponentData->mIsSolid) {
13801380
return false;
13811381
}
13821382
if (fullOnly && !block.isSlabBlock()) {
@@ -1398,7 +1398,7 @@ Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
13981398
bp = res.mBlock;
13991399
}
14001400
Block const& bl = actor->getDimensionBlockSource().getBlock(bp);
1401-
BlockLegacy const& legacy = bl.getLegacyBlock();
1401+
BlockType const& legacy = bl.getBlockType();
14021402
if (bl.isAir() || (legacy.mProperties == BlockProperty::None && legacy.mMaterial.mType == MaterialType::Any)) {
14031403
return Local<Value>();
14041404
}
@@ -1423,7 +1423,7 @@ Local<Value> EntityClass::getBiomeId() {
14231423
Actor* actor = get();
14241424
if (!actor) return Local<Value>();
14251425
auto& bio = actor->getDimensionBlockSource().getBiome(actor->getFeetBlockPos());
1426-
return Number::newNumber(bio.mId);
1426+
return Number::newNumber(bio.mId->mValue);
14271427
}
14281428
CATCH("Fail in getBiomeId!");
14291429
}

src/legacy/api/PacketAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "lse/api/helper/ItemStackSerializerHelpers.h"
99
#include "mc/deps/core/utility/BinaryStream.h"
1010
#include "mc/network/MinecraftPackets.h"
11-
#include "mc/client/renderer/rendergraph/Packet.h"
11+
#include "mc/network/Packet.h"
1212
#include "mc/world/item/NetworkItemStackDescriptor.h"
1313

1414
//////////////////// Class Definition ////////////////////

src/legacy/api/PlayerAPI.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ Local<Value> PlayerClass::isInsidePortal() {
12051205

12061206
auto component = player->getEntityContext().tryGetComponent<InsideBlockComponent>();
12071207
if (component) {
1208-
auto& fullName = component->mInsideBlock->getLegacyBlock().mNameInfo->mFullName;
1208+
auto& fullName = component->mInsideBlock->getBlockType().mNameInfo->mFullName;
12091209
return Boolean::newBoolean(
12101210
*fullName == VanillaBlockTypeIds::Portal() || *fullName == VanillaBlockTypeIds::EndPortal()
12111211
);
@@ -1433,7 +1433,8 @@ Local<Value> PlayerClass::isMoving() {
14331433
return Local<Value>();
14341434
}
14351435

1436-
return Boolean::newBoolean(SynchedActorDataAccess::getActorFlag(player->getEntityContext(), ActorFlags::Moving)
1436+
return Boolean::newBoolean(
1437+
SynchedActorDataAccess::getActorFlag(player->getEntityContext(), ActorFlags::Moving)
14371438
);
14381439
}
14391440
CATCH("Fail in isMoving!")
@@ -1662,10 +1663,10 @@ Local<Value> PlayerClass::setTitle(const Arguments& args) {
16621663
fadeOutTime = args[4].asNumber().toInt32();
16631664
}
16641665

1665-
SetTitlePacket pkt = SetTitlePacket(type, content, std::nullopt);
1666-
pkt.mFadeInTime = fadeInTime;
1667-
pkt.mStayTime = stayTime;
1668-
pkt.mFadeOutTime = fadeOutTime;
1666+
SetTitlePacket pkt(type, content, std::nullopt);
1667+
pkt.mFadeInTime = fadeInTime;
1668+
pkt.mStayTime = stayTime;
1669+
pkt.mFadeOutTime = fadeOutTime;
16691670
player->sendNetworkPacket(pkt);
16701671
return Boolean::newBoolean(true);
16711672
}
@@ -2290,6 +2291,9 @@ Local<Value> PlayerClass::setSidebar(const Arguments& args) {
22902291
CATCH("Fail in setSidebar!")
22912292
}
22922293

2294+
RemoveObjectivePacketPayload::RemoveObjectivePacketPayload() = default;
2295+
SetDisplayObjectivePacketPayload::SetDisplayObjectivePacketPayload() = default;
2296+
22932297
Local<Value> PlayerClass::removeSidebar(const Arguments&) {
22942298
try {
22952299
Player* player = get();
@@ -2456,7 +2460,8 @@ Local<Value> PlayerClass::sendSimpleForm(const Arguments& args) {
24562460
}
24572461
}
24582462
auto formCallback = [engine{EngineScope::currentEngine()},
2459-
callback{script::Global(args[4].asFunction())
2463+
callback{
2464+
script::Global(args[4].asFunction())
24602465
}](Player& pl, int chosen, ll::form::FormCancelReason reason) {
24612466
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
24622467
if (!EngineManager::isValid(engine)) return;
@@ -2500,9 +2505,10 @@ Local<Value> PlayerClass::sendModalForm(const Arguments& args) {
25002505
args[2].asString().toString(),
25012506
args[3].asString().toString()
25022507
);
2503-
auto formCallback = [engine{EngineScope::currentEngine()},
2504-
callback{script::Global(args[4].asFunction())
2505-
}](Player& pl, ll::form::ModalFormResult const& chosen, ll::form::FormCancelReason reason
2508+
auto formCallback = [engine{EngineScope::currentEngine()}, callback{script::Global(args[4].asFunction())}](
2509+
Player& pl,
2510+
ll::form::ModalFormResult const& chosen,
2511+
ll::form::FormCancelReason reason
25062512
) {
25072513
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
25082514
if (!EngineManager::isValid(engine)) return;
@@ -3236,7 +3242,7 @@ Local<Value> PlayerClass::getBlockFromViewVector(const Arguments& args) {
32363242
false,
32373243
true,
32383244
[&solidOnly, &fullOnly, &includeLiquid](BlockSource const&, Block const& block, bool) {
3239-
if (solidOnly && !block.mCachedComponentData->mUnkd6c5eb.as<bool>()) {
3245+
if (solidOnly && !block.mCachedComponentData->mIsSolid) {
32403246
return false;
32413247
}
32423248
if (fullOnly && !block.isSlabBlock()) {
@@ -3258,7 +3264,7 @@ Local<Value> PlayerClass::getBlockFromViewVector(const Arguments& args) {
32583264
bp = res.mBlock;
32593265
}
32603266
Block const& bl = player->getDimensionBlockSource().getBlock(bp);
3261-
BlockLegacy const& legacy = bl.getLegacyBlock();
3267+
BlockType const& legacy = bl.getBlockType();
32623268
// isEmpty()
32633269
if (bl.isAir() || (legacy.mProperties == BlockProperty::None && legacy.mMaterial.mType == MaterialType::Any)) {
32643270
return Local<Value>();
@@ -3454,6 +3460,9 @@ Local<Value> PlayerClass::removeItem(const Arguments& args) {
34543460
CATCH("Fail in removeItem!")
34553461
}
34563462

3463+
ToastRequestPacket::ToastRequestPacket() = default;
3464+
ToastRequestPacketPayload::ToastRequestPacketPayload() = default;
3465+
34573466
Local<Value> PlayerClass::sendToast(const Arguments& args) {
34583467
CHECK_ARGS_COUNT(args, 2);
34593468
CHECK_ARG_TYPE(args[0], ValueKind::kString);
@@ -3628,7 +3637,7 @@ Local<Value> PlayerClass::getBiomeId() {
36283637
Player* player = get();
36293638
if (!player) return Local<Value>();
36303639
Biome const& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos());
3631-
return Number::newNumber(bio.mId);
3640+
return Number::newNumber(bio.mId->mValue);
36323641
}
36333642
CATCH("Fail in getBiomeId!");
36343643
}

src/lse/api/NetworkPacket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "mc/deps/core/platform/Result.h"
55
#include "mc/deps/core/utility/BinaryStream.h"
66
#include "mc/network/MinecraftPacketIds.h"
7-
#include "mc/client/renderer/rendergraph/Packet.h"
7+
#include "mc/network/Packet.h"
88

99
#include <string>
1010

src/lse/events/PlayerEvents.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,22 @@ LL_TYPE_INSTANCE_HOOK(
138138
ChestBlockActor,
139139
&ChestBlockActor::$stopOpen,
140140
void,
141-
Player& player
141+
Actor& actor
142142
) {
143143
IF_LISTENED(EVENT_TYPES::onCloseContainer) {
144-
if (!CallEvent(
145-
EVENT_TYPES::onCloseContainer,
146-
PlayerClass::newPlayer(&player),
147-
BlockClass::newBlock(mPosition, player.getDimensionId())
148-
)) {
149-
return;
144+
if (actor.isPlayer()) {
145+
Player& player = static_cast<Player&>(actor);
146+
if (!CallEvent(
147+
EVENT_TYPES::onCloseContainer,
148+
PlayerClass::newPlayer(&player),
149+
BlockClass::newBlock(mPosition, player.getDimensionId())
150+
)) {
151+
return;
152+
}
150153
}
151154
}
152155
IF_LISTENED_END(EVENT_TYPES::onCloseContainer);
153-
origin(player);
156+
origin(actor);
154157
}
155158

156159
LL_TYPE_INSTANCE_HOOK(
@@ -159,19 +162,22 @@ LL_TYPE_INSTANCE_HOOK(
159162
BarrelBlockActor,
160163
&BarrelBlockActor::$stopOpen,
161164
void,
162-
Player& player
165+
Actor& actor
163166
) {
164167
IF_LISTENED(EVENT_TYPES::onCloseContainer) {
165-
if (!CallEvent(
166-
EVENT_TYPES::onCloseContainer,
167-
PlayerClass::newPlayer(&player),
168-
BlockClass::newBlock(mPosition, player.getDimensionId())
169-
)) {
170-
return;
168+
if (actor.isPlayer()) {
169+
Player& player = static_cast<Player&>(actor);
170+
if (!CallEvent(
171+
EVENT_TYPES::onCloseContainer,
172+
PlayerClass::newPlayer(&player),
173+
BlockClass::newBlock(mPosition, player.getDimensionId())
174+
)) {
175+
return;
176+
}
171177
}
172178
}
173179
IF_LISTENED_END(EVENT_TYPES::onCloseContainer);
174-
origin(player);
180+
origin(actor);
175181
}
176182

177183
LL_TYPE_INSTANCE_HOOK(

0 commit comments

Comments
 (0)