Skip to content

Commit c54bde5

Browse files
committed
fix: fix onOpenContainerScreen
1 parent aa4906a commit c54bde5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/lse/events/BlockEvents.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "ll/api/memory/Hook.h"
88
#include "ll/api/memory/Memory.h"
99
#include "ll/api/service/Bedrock.h"
10-
#include "mc/legacy/ActorRuntimeID.h"
1110
#include "mc/legacy/ActorUniqueID.h"
1211
#include "mc/scripting/modules/minecraft/events/ScriptBlockGlobalEventListener.h"
1312
#include "mc/server/commands/CommandOrigin.h"

src/lse/events/EntityEvents.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#include "ll/api/service/Bedrock.h"
99
#include "ll/api/service/GamingStatus.h"
1010
#include "mc/common/Globals.h"
11-
#include "mc/deps/core/string/HashedString.h"
1211
#include "mc/deps/shared_types/legacy/actor/ActorDamageCause.h"
1312
#include "mc/entity/components_json_legacy/NpcComponent.h"
1413
#include "mc/entity/components_json_legacy/ProjectileComponent.h"
1514
#include "mc/entity/components_json_legacy/TransformationComponent.h"
16-
#include "mc/legacy/ActorRuntimeID.h"
1715
#include "mc/legacy/ActorUniqueID.h"
1816
#include "mc/world/actor/ActorDamageSource.h"
1917
#include "mc/world/actor/ActorDefinitionIdentifier.h"
@@ -29,7 +27,6 @@
2927
#include "mc/world/effect/EffectDuration.h"
3028
#include "mc/world/effect/MobEffectInstance.h"
3129
#include "mc/world/events/ActorEventCoordinator.h"
32-
#include "mc/world/events/ProjectileHitEvent.h"
3330
#include "mc/world/item/CrossbowItem.h"
3431
#include "mc/world/item/ItemInstance.h"
3532
#include "mc/world/item/ItemStack.h"

src/lse/events/PlayerEvents.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
#include "mc/world/actor/player/Player.h"
2121
#include "mc/world/actor/player/PlayerInventory.h"
2222
#include "mc/world/actor/player/PlayerItemInUse.h"
23-
#include "mc/world/containers/models/LevelContainerModel.h"
2423
#include "mc/world/effect/EffectDuration.h"
2524
#include "mc/world/effect/MobEffectInstance.h"
2625
#include "mc/world/events/BlockEventCoordinator.h"
2726
#include "mc/world/events/EventResult.h"
2827
#include "mc/world/events/PlayerOpenContainerEvent.h"
2928
#include "mc/world/gamemode/InteractionResult.h"
29+
#include "mc/world/inventory/network/ItemStackNetManagerBase.h"
3030
#include "mc/world/inventory/transaction/ComplexInventoryTransaction.h"
3131
#include "mc/world/inventory/transaction/InventoryAction.h"
3232
#include "mc/world/inventory/transaction/InventorySource.h"
@@ -357,14 +357,21 @@ LL_TYPE_INSTANCE_HOOK(
357357
origin(player, std::move(changeRequest));
358358
}
359359

360-
LL_TYPE_INSTANCE_HOOK(OpenContainerScreenHook, HookPriority::Normal, Player, &Player::canOpenContainerScreen, bool) {
360+
LL_TYPE_INSTANCE_HOOK(
361+
OpenContainerScreenHook,
362+
HookPriority::Normal,
363+
ItemStackNetManagerBase,
364+
&ItemStackNetManagerBase::$onContainerScreenOpen,
365+
void,
366+
ContainerScreenContext const& screenContext
367+
) {
361368
IF_LISTENED(EVENT_TYPES::onOpenContainerScreen) {
362-
if (!CallEvent(EVENT_TYPES::onOpenContainerScreen, PlayerClass::newPlayer(this))) {
363-
return false;
369+
if (!CallEvent(EVENT_TYPES::onOpenContainerScreen, PlayerClass::newPlayer(&mUnkecd0f2.as<Player&>()))) {
370+
return;
364371
}
365372
}
366373
IF_LISTENED_END(EVENT_TYPES::onOpenContainerScreen);
367-
return origin();
374+
return origin(screenContext);
368375
}
369376

370377
LL_TYPE_STATIC_HOOK(

0 commit comments

Comments
 (0)