From ecd845176152d7c7e94e6eb10a6e9b7eba68ea01 Mon Sep 17 00:00:00 2001 From: lwenk Date: Sat, 12 Sep 2026 21:58:12 +0800 Subject: [PATCH] feat: adapt to 26.40 --- CHANGELOG.md | 4 ++++ src/mod/Events/Events.cpp | 14 +++++++------- src/mod/Hook/MobDamageReduction.cpp | 8 +++++--- src/mod/Hook/Player/PlayerStartSleep.cpp | 6 ++++-- tooth.json | 6 +++--- xmake.lua | 4 ++-- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51434a6..907fb07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [未发布] +## 新增 + +- 适配LeviLamina 26.40 + ## [0.10.0] - 2026-09-12 ## 新增 diff --git a/src/mod/Events/Events.cpp b/src/mod/Events/Events.cpp index 950b6fd..59971f6 100644 --- a/src/mod/Events/Events.cpp +++ b/src/mod/Events/Events.cpp @@ -24,13 +24,13 @@ #include #include #include +#include #include #include #include "mod/Events/BlockEventHandle.h" -#include "mod/Stats/Stats.h" #include "mod/Stats/Handlers/PlayerStatsHandlers.h" - +#include "mod/Stats/Stats.h" namespace stats { namespace event { @@ -114,12 +114,12 @@ void listenEvents() { [](ll::event::entity::ActorHurtEvent& event) { if (event.isCancelled()) return; - auto& victim = event.self(); - auto const& source = event.source(); - auto const damage = event.damage(); + auto& victim = event.self(); + auto const& source = event.source(); + auto const damage = event.damage(); auto const absorptionAttribute = victim.getAttribute(SharedAttributes::ABSORPTION()); - auto const absorption = absorptionAttribute.mPtr ? absorptionAttribute.mPtr->mCurrentValue : 0.0f; - auto const* resistance = victim.getEffect(*MobEffect::DAMAGE_RESISTANCE()); + auto const absorption = absorptionAttribute.mPtr ? absorptionAttribute.mPtr->mCurrentValue : 0.0f; + auto const* resistance = victim.getEffect((uint)MobEffectIds::DamageResistance); // getLogger().info( // "[ActorHurt] victim={} tag='{}' final_damage={:.3f} health_before={} absorption_before={:.3f} " diff --git a/src/mod/Hook/MobDamageReduction.cpp b/src/mod/Hook/MobDamageReduction.cpp index 27337c8..288afee 100644 --- a/src/mod/Hook/MobDamageReduction.cpp +++ b/src/mod/Hook/MobDamageReduction.cpp @@ -1,3 +1,4 @@ +#include "mc/world/effect/MobEffectIds.h" #include "mod/Hook/Hook.h" #include @@ -13,8 +14,9 @@ #include #include -#include "mod/Stats/Stats.h" #include "mod/Stats/Handlers/PlayerStatsHandlers.h" +#include "mod/Stats/Stats.h" + namespace stats::hook::mob { namespace { @@ -61,8 +63,8 @@ LL_TYPE_INSTANCE_HOOK( ::ActorDamageSource const& source, float damage ) { - auto const afterEnchantReduction = origin(source, damage); - auto const* resistance = this->getEffect(*MobEffect::DAMAGE_RESISTANCE()); + auto const afterEnchantReduction = origin(source, damage); + auto const* resistance = this->getEffect((uint)MobEffectIds::DamageResistance); if (resistance && source.isReducedByResistanceEffect()) { auto const resistanceDamage = getResistanceDamage(afterEnchantReduction, resistance->mAmplifier); diff --git a/src/mod/Hook/Player/PlayerStartSleep.cpp b/src/mod/Hook/Player/PlayerStartSleep.cpp index c43d6ea..a04f787 100644 --- a/src/mod/Hook/Player/PlayerStartSleep.cpp +++ b/src/mod/Hook/Player/PlayerStartSleep.cpp @@ -14,9 +14,11 @@ LL_TYPE_INSTANCE_HOOK( Player, &Player::$startSleepInBed, BedSleepingResult, - BlockPos const& pos + ::BlockPos const& bedPos, + bool setsRespawn, + float sleepOffset ) { - auto res = origin(pos); + auto res = origin(bedPos, setsRespawn, sleepOffset); Player* player = this; if (res == BedSleepingResult::Ok) handler::onPlayerStartSleep(player); return res; diff --git a/tooth.json b/tooth.json index 99a1976..37a34fc 100644 --- a/tooth.json +++ b/tooth.json @@ -2,7 +2,7 @@ "format_version": 3, "format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d", "tooth": "github.com/LeafKnife/Stats", - "version": "0.10.0", + "version": "0.11.0", "info": { "name": "Stats", "description": "Minecraft 基岩版服务器(BDS) 统计信息插件", @@ -17,8 +17,8 @@ "label": "", "platform": "win-x64", "dependencies": { - "github.com/LiteLDev/LeviLamina": "26.32.*", - "github.com/LiteLDev/LegacyRemoteCall": "0.20.*" + "github.com/LiteLDev/LeviLamina": "26.40.*", + "github.com/LiteLDev/LegacyRemoteCall": "0.21.*" }, "assets": [ { diff --git a/xmake.lua b/xmake.lua index 4579a2f..3c38a74 100644 --- a/xmake.lua +++ b/xmake.lua @@ -11,10 +11,10 @@ option_end() -- add_requires("levilamina x.x.x") for a specific version -- add_requires("levilamina develop") to use develop version -- please note that you should add bdslibrary yourself if using dev version -add_requires("levilamina 26.32.*", {configs = {target_type = get_config("target_type")}}) +add_requires("levilamina 26.40.*", {configs = {target_type = get_config("target_type")}}) add_requires("levibuildscript") -add_requires("legacyremotecall v0.20.0", {configs = {target_type = get_config("target_type")}}) +add_requires("legacyremotecall v0.21.0", {configs = {target_type = get_config("target_type")}}) add_requires("nlohmann_json v3.11.3") add_requires("parallel-hashmap v2.0.0")