|
21 | 21 | #include "mc/world/actor/player/Inventory.h" |
22 | 22 | #include "mc/world/actor/player/Player.h" |
23 | 23 | #include "mc/world/actor/player/PlayerInventory.h" |
| 24 | +#include "mc/world/containers/managers/models/ContainerManagerModel.h" |
24 | 25 | #include "mc/world/effect/MobEffectInstance.h" |
25 | 26 | #include "mc/world/events/BlockEventCoordinator.h" |
26 | 27 | #include "mc/world/events/EventResult.h" |
@@ -140,51 +141,26 @@ LL_TYPE_INSTANCE_HOOK( |
140 | 141 | } |
141 | 142 |
|
142 | 143 | LL_TYPE_INSTANCE_HOOK( |
143 | | - CloseContainerHook1, |
| 144 | + CloseContainerHook, |
144 | 145 | HookPriority::Normal, |
145 | | - ChestBlockActor, |
146 | | - &ChestBlockActor::$stopOpen, |
| 146 | + ServerPlayer, |
| 147 | + &ServerPlayer::doDeleteContainerManager, |
147 | 148 | void, |
148 | | - Actor& actor |
| 149 | + bool forceDisconnect |
149 | 150 | ) { |
150 | 151 | IF_LISTENED(EVENT_TYPES::onCloseContainer) { |
151 | | - if (checkClientIsServerThread() && actor.isPlayer()) { |
152 | | - Player& player = static_cast<Player&>(actor); |
153 | | - if (!CallEvent( |
154 | | - EVENT_TYPES::onCloseContainer, |
155 | | - PlayerClass::newPlayer(&player), |
156 | | - BlockClass::newBlock(mPosition, player.getDimensionId().id) |
157 | | - )) { |
158 | | - return; |
159 | | - } |
160 | | - } |
161 | | - } |
162 | | - IF_LISTENED_END(EVENT_TYPES::onCloseContainer); |
163 | | - origin(actor); |
164 | | -} |
165 | | - |
166 | | -LL_TYPE_INSTANCE_HOOK( |
167 | | - CloseContainerHook2, |
168 | | - HookPriority::Normal, |
169 | | - BarrelBlockActor, |
170 | | - &BarrelBlockActor::$stopOpen, |
171 | | - void, |
172 | | - Actor& actor |
173 | | -) { |
174 | | - IF_LISTENED(EVENT_TYPES::onCloseContainer) { |
175 | | - if (checkClientIsServerThread() && actor.isPlayer()) { |
176 | | - Player& player = static_cast<Player&>(actor); |
177 | | - if (!CallEvent( |
| 152 | + if (mContainerManager) { |
| 153 | + if (auto* pos = std::get_if<BlockPos>(&*mContainerManager->mScreenContext->mOwner); pos) { |
| 154 | + CallEvent( |
178 | 155 | EVENT_TYPES::onCloseContainer, |
179 | | - PlayerClass::newPlayer(&player), |
180 | | - BlockClass::newBlock(mPosition, player.getDimensionId().id) |
181 | | - )) { |
182 | | - return; |
| 156 | + PlayerClass::newPlayer(this), |
| 157 | + BlockClass::newBlock(*pos, getDimensionId().id) |
| 158 | + ); |
183 | 159 | } |
184 | 160 | } |
185 | 161 | } |
186 | 162 | IF_LISTENED_END(EVENT_TYPES::onCloseContainer); |
187 | | - origin(actor); |
| 163 | + origin(forceDisconnect); |
188 | 164 | } |
189 | 165 |
|
190 | 166 | LL_TYPE_INSTANCE_HOOK( |
@@ -659,10 +635,7 @@ void DropItem() { |
659 | 635 | DropItemHook2::hook(); |
660 | 636 | } |
661 | 637 | void OpenContainerEvent() { OpenContainerHook::hook(); } |
662 | | -void CloseContainerEvent() { |
663 | | - CloseContainerHook1::hook(); |
664 | | - CloseContainerHook2::hook(); |
665 | | -} |
| 638 | +void CloseContainerEvent() { CloseContainerHook::hook(); } |
666 | 639 | void ChangeSlotEvent() { ChangeSlotHook::hook(); } |
667 | 640 | void AttackBlockEvent() { StartDestroyBlockHook::hook(); } |
668 | 641 | void UseFrameEvent() { |
|
0 commit comments