Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit f3cf1bc

Browse files
authored
fix: Fix event PlayerPlaceBlock (#1329)
1 parent ba63d7f commit f3cf1bc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

LiteLoader/src/llapi/EventAPI.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,31 @@ TInstanceHook(char, "?checkBlockPermissions@BlockSource@@QEAA_NAEAVActor@@AEBVBl
658658
auto player = (Player*)ac;
659659
PlayerPlaceBlockEvent ev{};
660660
ev.mPlayer = player;
661-
ev.mBlockInstance = this->getBlockInstance(*blockPosPtr);
661+
int x = blockPosPtr->x;
662+
int y = blockPosPtr->y;
663+
int z = blockPosPtr->z;
664+
switch (facing) {
665+
case 0:
666+
--y;
667+
break;
668+
case 1:
669+
++y;
670+
break;
671+
case 2:
672+
--z;
673+
break;
674+
case 3:
675+
++z;
676+
break;
677+
case 4:
678+
--x;
679+
break;
680+
case 5:
681+
++x;
682+
break;
683+
}
684+
BlockPos pos(x, y, z);
685+
ev.mBlockInstance = this->getBlockInstance(pos);
662686
if (!ev.call()) { // this pointer is not used.
663687
((ItemUseInventoryTransaction*)nullptr)->resendBlocksAroundArea(*player, *blockPosPtr, facing);
664688
return false;

0 commit comments

Comments
 (0)