Skip to content

Commit ba5468f

Browse files
committed
fix: fix onOpenContainer, onCloseContainer, and onContainerChange
1 parent 109b9cd commit ba5468f

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/lse/events/EventHooks.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "mc/world/phys/AABB.h"
7272
#include "mc/world/scores/ServerScoreboard.h"
7373
#include "mc/world/level/Explosion.h"
74+
#include "mc/world/events/PlayerOpenContainerEvent.h"
7475

7576
namespace lse::events {
7677

@@ -166,14 +167,11 @@ LL_TYPE_INSTANCE_HOOK(
166167
) {
167168
IF_LISTENED(EVENT_TYPES::onOpenContainer) {
168169
Actor* actor = static_cast<WeakEntityRef*>((void*)&playerOpenContainerEvent)->tryUnwrap<Actor>();
169-
if (actor->isType(ActorType::Player)) {
170+
if (actor && actor->isType(ActorType::Player)) {
170171
if (!CallEvent(
171172
EVENT_TYPES::onOpenContainer,
172173
PlayerClass::newPlayer(static_cast<Player*>(actor)),
173-
BlockClass::newBlock(
174-
ll::memory::dAccess<BlockPos>(&playerOpenContainerEvent, 28),
175-
actor->getDimensionId()
176-
)
174+
BlockClass::newBlock(playerOpenContainerEvent.mUnkb08e33.as<BlockPos>(), actor->getDimensionId())
177175
)) {
178176
return EventResult::StopProcessing;
179177
}
@@ -194,11 +192,8 @@ LL_TYPE_INSTANCE_HOOK(
194192
IF_LISTENED(EVENT_TYPES::onCloseContainer) {
195193
if (!CallEvent(
196194
EVENT_TYPES::onCloseContainer,
197-
PlayerClass::newPlayer(&const_cast<Player&>(player)),
198-
BlockClass::newBlock(
199-
ll::memory::dAccess<BlockActor>(this, -240).getPosition(),
200-
player.getDimensionId()
201-
) // IDA ChestBlockActor::stopOpen
195+
PlayerClass::newPlayer(&player),
196+
BlockClass::newBlock(getPosition(), player.getDimensionId())
202197
)) {
203198
return;
204199
}
@@ -218,11 +213,8 @@ LL_TYPE_INSTANCE_HOOK(
218213
IF_LISTENED(EVENT_TYPES::onCloseContainer) {
219214
if (!CallEvent(
220215
EVENT_TYPES::onCloseContainer,
221-
PlayerClass::newPlayer(&const_cast<Player&>(player)),
222-
BlockClass::newBlock(
223-
ll::memory::dAccess<BlockActor>(this, -240).getPosition(),
224-
player.getDimensionId()
225-
) // IDA ChestBlockActor::stopOpen
216+
PlayerClass::newPlayer(&player),
217+
BlockClass::newBlock(getPosition(), player.getDimensionId())
226218
)) {
227219
return;
228220
}
@@ -276,7 +268,7 @@ LL_TYPE_INSTANCE_HOOK(
276268
if (!CallEvent(
277269
EVENT_TYPES::onContainerChange,
278270
PlayerClass::newPlayer(player),
279-
BlockClass::newBlock(ll::memory::dAccess<BlockPos>(this, 224), player->getDimensionId()),
271+
BlockClass::newBlock(mUnk74419a.as<BlockPos>(), player->getDimensionId()),
280272
Number::newNumber(slotNumber + this->_getContainerOffset()),
281273
ItemClass::newItem(&const_cast<ItemStack&>(oldItem)),
282274
ItemClass::newItem(&const_cast<ItemStack&>(newItem))

0 commit comments

Comments
 (0)