Skip to content

Commit 389d66b

Browse files
committed
fix: fix onOpenContainerScreen
1 parent 7c668e7 commit 389d66b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/lse/events/PlayerEvents.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "mc/world/events/EventResult.h"
2525
#include "mc/world/events/PlayerOpenContainerEvent.h"
2626
#include "mc/world/gamemode/InteractionResult.h"
27-
#include "mc/world/inventory/network/ItemStackNetManagerBase.h"
27+
#include "mc/world/inventory/network/ItemStackNetManagerServer.h"
2828
#include "mc/world/inventory/transaction/ComplexInventoryTransaction.h"
2929
#include "mc/world/inventory/transaction/InventoryAction.h"
3030
#include "mc/world/inventory/transaction/InventorySource.h"
@@ -355,8 +355,8 @@ LL_TYPE_INSTANCE_HOOK(
355355
LL_TYPE_INSTANCE_HOOK(
356356
OpenContainerScreenHook,
357357
HookPriority::Normal,
358-
ItemStackNetManagerBase,
359-
&ItemStackNetManagerBase::$onContainerScreenOpen,
358+
ItemStackNetManagerServer,
359+
&ItemStackNetManagerServer::$onContainerScreenOpen,
360360
void,
361361
ContainerScreenContext const& screenContext
362362
) {
@@ -383,17 +383,15 @@ LL_TYPE_INSTANCE_HOOK(
383383
if (isServerThread()) {
384384
// 原版逻辑:手持萤石且未满时 _tryCharge 会优先充能并短路;
385385
// 充能大于 0 且位于下界(维度 1)时 _trySetSpawn 才会设置重生点,重生点已是此锚时无事发生
386-
auto& block = eventData.mPlayer.getDimensionBlockSource().getBlock(eventData.mPos);
387-
int charge = block.getState<int>(VanillaStates::RespawnAnchorCharge().mID).value_or(0);
388-
auto& item = eventData.mPlayer.getSelectedItem();
386+
auto& block = eventData.mPlayer.getDimensionBlockSource().getBlock(eventData.mPos);
387+
int charge = block.getState<int>(VanillaStates::RespawnAnchorCharge().mID).value_or(0);
388+
auto& item = eventData.mPlayer.getSelectedItem();
389389
auto* itemBlockType = item.mItem ? item.mItem->mBlockType.get().get() : nullptr;
390-
bool isCharging = itemBlockType
391-
&& *itemBlockType->mNameInfo->mFullName == VanillaBlockTypeIds::Glowstone()
392-
&& charge < static_cast<int>(VanillaStates::RespawnAnchorCharge().mVariationCount) - 1;
390+
bool isCharging = itemBlockType && *itemBlockType->mNameInfo->mFullName == VanillaBlockTypeIds::Glowstone()
391+
&& charge < static_cast<int>(VanillaStates::RespawnAnchorCharge().mVariationCount) - 1;
393392
auto& spawnPoint = eventData.mPlayer.mPlayerRespawnPoint;
394393
if (charge > 0 && !isCharging && eventData.mPlayer.getDimensionId() == 1
395-
&& !(spawnPoint->mDimension->mValue == 1
396-
&& *spawnPoint->mSpawnBlockPos == *eventData.mPos)) {
394+
&& !(spawnPoint->mDimension->mValue == 1 && *spawnPoint->mSpawnBlockPos == *eventData.mPos)) {
397395
if (!CallEvent(
398396
EVENT_TYPES::onUseRespawnAnchor,
399397
PlayerClass::newPlayer(&eventData.mPlayer),

0 commit comments

Comments
 (0)