Skip to content

Commit 3acad7b

Browse files
committed
refactor: support 26.3
1 parent d47b88b commit 3acad7b

26 files changed

Lines changed: 534 additions & 821 deletions

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ jobs:
4343
restore-keys: |
4444
xmake-
4545
46+
- name: Setup LLVM
47+
uses: ZhongRuoyu/setup-llvm@v0
48+
with:
49+
llvm-version: 22
50+
4651
- run: |
4752
xmake repo -u
4853

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
restore-keys: |
3030
xmake-
3131
32+
- name: Setup LLVM
33+
uses: ZhongRuoyu/setup-llvm@v0
34+
with:
35+
llvm-version: 22
36+
3237
- run: |
3338
xmake repo -u
3439

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Adapted to LeviLamina 26.32.*
13+
1014
## [0.19.7] - 2026-08-24
1115

1216
### Added

src/legacy/api/BlockAPI.cpp

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "mc/world/level/block/BlockChangeContext.h"
1919
#include "mc/world/level/block/VanillaBlockTags.h"
2020
#include "mc/world/level/block/actor/BlockActor.h"
21+
#include "mc/world/level/block/actor/BlockActorType.h"
22+
#include "mc/world/level/block/actor/VanillaBlockActor.h"
2123
#include "mc/world/level/block/block_serialization_utils/BlockSerializationUtils.h"
2224
#include "mc/world/level/chunk/LevelChunk.h"
2325

@@ -317,21 +319,22 @@ Local<Value> BlockClass::setNbt(Arguments const& args) {
317319
// update Pre Data
318320
auto result = BlockSerializationUtils::tryGetBlockFromNBT(*nbt, nullptr);
319321
if (Block const* bl = result.second) {
320-
ll::service::getLevel()
321-
->getDimension(blockPos.dim)
322-
.lock()
323-
->getBlockSourceFromMainChunkSource()
324-
.setBlock(
325-
blockPos.getBlockPos(),
326-
*bl,
327-
3,
328-
nullptr,
329-
nullptr,
330-
BlockChangeContext(StatelessBlockChangeContext::Commands)
331-
);
322+
if (auto level = ll::service::getLevel()) {
323+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
324+
dim->getBlockSourceFromMainChunkSource().setBlock(
325+
blockPos.getBlockPos(),
326+
*bl,
327+
3,
328+
nullptr,
329+
nullptr,
330+
BlockChangeContext(StatelessBlockChangeContext::Commands)
331+
);
332+
preloadData(blockPos.getBlockPos(), blockPos.getDimensionId());
333+
return Boolean::newBoolean(true);
334+
}
335+
}
332336
}
333-
preloadData(blockPos.getBlockPos(), blockPos.getDimensionId());
334-
return Boolean::newBoolean(true);
337+
return Boolean::newBoolean(false);
335338
}
336339
CATCH_AND_THROW
337340
}
@@ -352,25 +355,29 @@ Local<Value> BlockClass::getBlockState(Arguments const&) const {
352355

353356
Local<Value> BlockClass::hasContainer(Arguments const&) const {
354357
try {
355-
auto& bl = ll::service::getLevel()
356-
->getDimension(blockPos.dim)
357-
.lock()
358-
->getBlockSourceFromMainChunkSource()
359-
.getBlock(blockPos.getBlockPos());
360-
return Boolean::newBoolean(bl.getBlockType().isContainerBlock());
358+
if (auto level = ll::service::getLevel()) {
359+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
360+
auto& bl = dim->getBlockSourceFromMainChunkSource().getBlock(blockPos.getBlockPos());
361+
return Boolean::newBoolean(bl.getBlockType().isContainerBlock());
362+
}
363+
}
364+
return Boolean::newBoolean(false);
361365
}
362366
CATCH_AND_THROW
363367
}
364368

365369
Local<Value> BlockClass::getContainer(Arguments const&) const {
366370
try {
367-
Container* container = ll::service::getLevel()
368-
->getDimension(blockPos.dim)
369-
.lock()
370-
->getBlockSourceFromMainChunkSource()
371-
.getBlockEntity(blockPos.getBlockPos())
372-
->getContainer();
373-
return container ? ContainerClass::newContainer(container) : Local<Value>();
371+
if (auto level = ll::service::getLevel()) {
372+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
373+
auto blockActor = dim->getBlockSourceFromMainChunkSource().getBlockEntity(blockPos.getBlockPos());
374+
if (blockActor->mType != BlockActorType::DataDriven) {
375+
auto container = static_cast<VanillaBlockActor*>(blockActor)->getContainer();
376+
return container ? ContainerClass::newContainer(container) : Local<Value>();
377+
}
378+
}
379+
}
380+
return {};
374381
}
375382
CATCH_AND_THROW
376383
}
@@ -384,27 +391,30 @@ Local<Value> BlockClass::hasBlockEntity(Arguments const&) const {
384391

385392
Local<Value> BlockClass::getBlockEntity(Arguments const&) const {
386393
try {
387-
BlockActor* be = ll::service::getLevel()
388-
->getDimension(blockPos.dim)
389-
.lock()
390-
->getBlockSourceFromMainChunkSource()
391-
.getBlockEntity(blockPos.getBlockPos());
392-
return be ? BlockEntityClass::newBlockEntity(be, blockPos.dim) : Local<Value>();
394+
if (auto level = ll::service::getLevel()) {
395+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
396+
BlockActor* be = dim->getBlockSourceFromMainChunkSource().getBlockEntity(blockPos.getBlockPos());
397+
return be ? BlockEntityClass::newBlockEntity(be, blockPos.dim) : Local<Value>();
398+
}
399+
}
400+
return {};
393401
}
394402
CATCH_AND_THROW
395403
}
396404

397405
Local<Value> BlockClass::removeBlockEntity(Arguments const&) const {
398406
try {
399-
return Boolean::newBoolean(
400-
ll::service::getLevel()
401-
->getDimension(blockPos.dim)
402-
.lock()
403-
->getBlockSourceFromMainChunkSource()
404-
.getChunkAt(blockPos.getBlockPos())
405-
->removeBlockEntity(blockPos.getBlockPos())
406-
!= nullptr
407-
);
407+
if (auto level = ll::service::getLevel()) {
408+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
409+
return Boolean::newBoolean(
410+
dim->getBlockSourceFromMainChunkSource()
411+
.getChunkAt(blockPos.getBlockPos())
412+
->removeBlockEntity(blockPos.getBlockPos())
413+
!= nullptr
414+
);
415+
}
416+
}
417+
return Boolean::newBoolean(false);
408418
}
409419
CATCH_AND_THROW
410420
}
@@ -416,16 +426,18 @@ Local<Value> BlockClass::destroyBlock(Arguments const& args) const {
416426
try {
417427
// same as `Level::getBlockInstance(pos.getBlockPos(),
418428
// pos.dim).breakNaturally()` when drop
419-
BlockSource& bl =
420-
ll::service::getLevel()->getDimension(blockPos.dim).lock()->getBlockSourceFromMainChunkSource();
421-
return Boolean::newBoolean(
422-
ll::service::getLevel()->destroyBlock(
423-
bl,
424-
blockPos.getBlockPos(),
425-
args[0].asBoolean().value(),
426-
BlockChangeContext(StatelessBlockChangeContext::Commands)
427-
)
428-
);
429+
if (auto level = ll::service::getLevel()) {
430+
if (auto dim = level->getDimension(blockPos.dim).lock()) {
431+
BlockSource& bl = dim->getBlockSourceFromMainChunkSource();
432+
return Boolean::newBoolean(level->destroyBlock(
433+
bl,
434+
blockPos.getBlockPos(),
435+
args[0].asBoolean().value(),
436+
BlockChangeContext(StatelessBlockChangeContext::Commands)
437+
));
438+
}
439+
}
440+
return Boolean::newBoolean(false);
429441
}
430442
CATCH_AND_THROW
431443
}

src/legacy/api/BlockEntityAPI.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "mc/world/item/SaveContextFactory.h"
1212
#include "mc/world/level/BlockSource.h"
1313
#include "mc/world/level/block/actor/BlockActor.h"
14+
#include "mc/world/level/block/actor/BlockActorType.h"
15+
#include "mc/world/level/block/actor/VanillaBlockActor.h"
1416
#include "mc/world/level/dimension/Dimension.h"
1517

1618
//////////////////// Class Definition ////////////////////
@@ -59,7 +61,11 @@ Local<Value> BlockEntityClass::getPos() const {
5961

6062
Local<Value> BlockEntityClass::getName() const {
6163
try {
62-
return String::newString(blockEntity->getName());
64+
if (blockEntity->mType != BlockActorType::DataDriven) {
65+
auto blockActor = static_cast<VanillaBlockActor*>(blockEntity);
66+
return String::newString(blockActor->getName());
67+
}
68+
return String::newString("");
6369
}
6470
CATCH_AND_THROW
6571
}
@@ -125,15 +131,23 @@ Local<Value> BlockEntityClass::setCustomName(Arguments const& args) const {
125131
CHECK_ARG_TYPE(args[0], ValueKind::kString);
126132

127133
try {
128-
blockEntity->setCustomName({args[0].asString().toString(), std::nullopt});
129-
return Boolean::newBoolean(true);
134+
if (blockEntity->mType != BlockActorType::DataDriven) {
135+
auto blockActor = static_cast<VanillaBlockActor*>(blockEntity);
136+
blockActor->mCustomName = args[0].asString().toString();
137+
return Boolean::newBoolean(true);
138+
}
139+
return Boolean::newBoolean(false);
130140
}
131141
CATCH_AND_THROW
132142
}
133143

134144
Local<Value> BlockEntityClass::getCustomName() const {
135145
try {
136-
return String::newString(blockEntity->getCustomName().mUnredactedString);
146+
if (blockEntity->mType != BlockActorType::DataDriven) {
147+
auto blockActor = static_cast<VanillaBlockActor*>(blockEntity);
148+
return String::newString(blockActor->mCustomName->mUnredactedString);
149+
}
150+
return String::newString("");
137151
}
138152
CATCH_AND_THROW
139153
}

0 commit comments

Comments
 (0)