Skip to content

Commit 5698326

Browse files
committed
chore: update LeviLamina
1 parent 7a0a7d0 commit 5698326

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

src/legacy/api/BlockAPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@ Local<Value> BlockClass::isSlabBlock() {
277277

278278
Local<Value> BlockClass::isUnbreakable() {
279279
try {
280-
return Boolean::newBoolean(block->mDirectData->mUnkc08fbd.as<float>() < 0.0f);
280+
return Boolean::newBoolean(block->mDirectData->mDestroySpeed < 0.0f);
281281
}
282282
CATCH("Fail in isUnbreakable!");
283283
}
284284

285285
Local<Value> BlockClass::isWaterBlockingBlock() {
286286
try {
287287
return Boolean::newBoolean(
288-
block->mDirectData->mUnkd3e7c9.as<DetectionRule>().mUnk21e36d.as<LiquidReaction>()
288+
block->mDirectData->mWaterDetectionRule->mUnk21e36d.as<LiquidReaction>()
289289
== LiquidReaction::Blocking
290290
);
291291
}

src/legacy/api/DataAPI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ Local<Value> DataClass::fromUuid(const Arguments& args) {
781781
CHECK_ARG_TYPE(args[0], ValueKind::kString);
782782

783783
try {
784-
auto playerInfo = ll::service::PlayerInfo::getInstance().fromUuid(args[0].asString().toString());
784+
auto playerInfo =
785+
ll::service::PlayerInfo::getInstance().fromUuid(mce::UUID::fromString(args[0].asString().toString()));
785786
if (playerInfo) {
786787
auto object = Object::newObject();
787788
object.set("xuid", playerInfo->xuid);

src/legacy/api/SimulatedPlayerAPI.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ Local<Value> McClass::spawnSimulatedPlayer(const Arguments& args) {
6565
}
6666

6767
SimulatedPlayer* PlayerClass::asSimulatedPlayer() {
68-
if (get()->isSimulatedPlayer()) {
69-
return static_cast<SimulatedPlayer*>(get());
68+
Player* ptr = get();
69+
if (ptr && ptr->isSimulatedPlayer()) {
70+
return static_cast<SimulatedPlayer*>(ptr);
7071
}
7172
return nullptr;
7273
}
@@ -373,18 +374,18 @@ Local<Value> PlayerClass::simulateLookAt(const Arguments& args) {
373374
auto sp = asSimulatedPlayer();
374375
if (!sp) return Local<Value>();
375376
int dimid = sp->getDimensionId();
376-
int lookDuration = 2; // 0 = Instant, 1 = Continuous, 2 = UntilMove
377+
auto lookDuration = sim::LookDuration::UntilMove;
377378
if (args.size() > 1) {
378379
if (!args[1].isNumber()) {
379380
LOG_WRONG_ARG_TYPE(__FUNCTION__);
380381
}
381-
lookDuration = args[1].asNumber().toInt32();
382+
lookDuration = static_cast<sim::LookDuration>(args[1].asNumber().toInt32());
382383
}
383384
if (IsInstanceOf<IntPos>(args[0])) {
384385
auto pos = IntPos::extractPos(args[0]);
385386
auto did = pos->getDimensionId();
386387
if (dimid == did || did < 0 || did > 2) {
387-
SimulatedPlayerHelper::simulateLookAt(*sp, pos->getBlockPos(), (sim::LookDuration)lookDuration);
388+
SimulatedPlayerHelper::simulateLookAt(*sp, pos->getBlockPos(), lookDuration);
388389
return Boolean::newBoolean(true);
389390
}
390391
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().debug(

src/lse/api/helper/SimulatedPlayerHelper.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "SimulatedPlayerHelper.h"
22

33
#include "mc/entity/components_json_legacy/NavigationComponent.h"
4-
#include "mc/server/sim/LookAtIntent.h"
54
#include "mc/server/sim/MoveInDirectionIntent.h"
65
#include "mc/server/sim/MoveToPositionIntent.h"
76
#include "mc/server/sim/NavigateToEntityIntent.h"
@@ -30,8 +29,7 @@ bool SimulatedPlayerHelper::simulateRespawn(SimulatedPlayer& player) {
3029
}
3130

3231
void SimulatedPlayerHelper::simulateLookAt(SimulatedPlayer& player, Actor& actor, sim::LookDuration lookType) {
33-
auto intent = sim::lookAt(player, actor.getEntityContext(), lookType);
34-
memcpy((void*)&player.mLookAtIntent, &intent, sizeof(sim::LookAtIntent));
32+
player.mLookAtIntent = sim::lookAt(player, actor.getEntityContext(), lookType);
3533
}
3634

3735
void SimulatedPlayerHelper::simulateLookAt(
@@ -40,17 +38,15 @@ void SimulatedPlayerHelper::simulateLookAt(
4038
sim::LookDuration lookType
4139
) {
4240
glm::vec3 vec3;
43-
vec3.x = (float)blockPos.x + 0.5f;
44-
vec3.y = (float)blockPos.y + 0.5f;
45-
vec3.z = (float)blockPos.z + 0.5f;
46-
auto intent = sim::lookAt(player, vec3, lookType);
47-
memcpy((void*)&player.mLookAtIntent, &intent, sizeof(sim::LookAtIntent));
41+
vec3.x = (float)blockPos.x + 0.5f;
42+
vec3.y = (float)blockPos.y + 0.5f;
43+
vec3.z = (float)blockPos.z + 0.5f;
44+
player.mLookAtIntent = sim::lookAt(player, vec3, lookType);
4845
}
4946

5047
void SimulatedPlayerHelper::simulateLookAt(SimulatedPlayer& player, Vec3 const& pos, sim::LookDuration lookType) {
5148
glm::vec3 vec3(pos.x, pos.y, pos.z);
52-
auto intent = sim::lookAt(player, vec3, lookType);
53-
memcpy((void*)&player.mLookAtIntent, &intent, sizeof(sim::LookAtIntent));
49+
player.mLookAtIntent = sim::lookAt(player, vec3, lookType);
5450
}
5551

5652
bool SimulatedPlayerHelper::simulateUseItem(SimulatedPlayer& player, ItemStack& item) {

src/lse/events/PlayerEvents.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ LL_TYPE_INSTANCE_HOOK(
330330
ContainerScreenContext const& screenContext
331331
) {
332332
IF_LISTENED(EVENT_TYPES::onOpenContainerScreen) {
333-
if (!CallEvent(EVENT_TYPES::onOpenContainerScreen, PlayerClass::newPlayer(&mUnkecd0f2.as<Player&>()))) {
333+
if (!CallEvent(EVENT_TYPES::onOpenContainerScreen, PlayerClass::newPlayer(&mPlayer))) {
334334
return;
335335
}
336336
}

xmake.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ add_rules("mode.debug", "mode.release")
33
add_repositories("levimc-repo https://github.com/LiteLDev/xmake-repo.git")
44

55
if is_config("target_type", "server") then
6-
add_requires("levilamina 1.3.0", {configs = {target_type = "server"}})
6+
add_requires("levilamina 018f6f96f93781b229c899923d9d7569f3424686", {configs = {target_type = "server"}})
77
else
8-
add_requires("levilamina 1.3.0", {configs = {target_type = "client"}})
8+
add_requires("levilamina 018f6f96f93781b229c899923d9d7569f3424686", {configs = {target_type = "client"}})
99
end
1010

1111
add_requires("levibuildscript")

0 commit comments

Comments
 (0)