Skip to content

Commit

Permalink
fix: fix onContainerChange
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 3, 2025
1 parent 046923f commit 109b9cd
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/lse/events/EventHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,20 @@ LL_TYPE_INSTANCE_HOOK(
ItemStack const& newItem
) {
IF_LISTENED(EVENT_TYPES::onContainerChange) {
Player* player = ll::memory::dAccess<Player*>(this, 216); // IDA LevelContainerModel::LevelContainerModel
if (player->hasOpenContainer()) {
if (!CallEvent(
EVENT_TYPES::onContainerChange,
PlayerClass::newPlayer(player),
BlockClass::newBlock(ll::memory::dAccess<BlockPos>(this, 224), player->getDimensionId()),
Number::newNumber(slotNumber + this->_getContainerOffset()),
ItemClass::newItem(&const_cast<ItemStack&>(oldItem)),
ItemClass::newItem(&const_cast<ItemStack&>(newItem))
)) {
return;
Actor* actor = _getEntity();

This comment has been minimized.

Copy link
@VinkyV

VinkyV Jan 4, 2025

Contributor

&LevelContainerModel::$_onItemChanged
_getEntity is getting entity with inventory like boats with chest or minecraft with chest and etc

Proof and etc in discord https://discord.com/channels/849252980430864384/1324945120579293246

if (actor && actor->isType(ActorType::Player)) {
Player* player = static_cast<Player*>(actor);
if (player->hasOpenContainer()) {
if (!CallEvent(
EVENT_TYPES::onContainerChange,
PlayerClass::newPlayer(player),
BlockClass::newBlock(ll::memory::dAccess<BlockPos>(this, 224), player->getDimensionId()),
Number::newNumber(slotNumber + this->_getContainerOffset()),
ItemClass::newItem(&const_cast<ItemStack&>(oldItem)),
ItemClass::newItem(&const_cast<ItemStack&>(newItem))
)) {
return;
}
}
}
}
Expand Down

0 comments on commit 109b9cd

Please sign in to comment.