Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Fix PlayerPlaceBlockEvent for doors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjlintkh committed Feb 13, 2022
1 parent 7015992 commit f8922e8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bdsx/bdsx-lxl",
"version": "1.1.0",
"version": "1.1.1",
"description": "LiteXLoader ported into BDSX",
"main": "index.js",
"keywords": [],
Expand Down
45 changes: 16 additions & 29 deletions src/api/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,39 +526,26 @@ events.playerDropItem.on(event => {
});
}
{
let doors: Block[];
bedrockServer.afterOpen().then(()=> {
doors = [
daccess(MCAPI.VanillaBlocks.mWoodenDoor, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWoodenDoorSpruce, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWoodenDoorBirch, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWoodenDoorJungle, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWoodenDoorAcacia, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWoodenDoorDarkOak, Block.ref()),
daccess(MCAPI.VanillaBlocks.mIronDoor, Block.ref()),
daccess(MCAPI.VanillaBlocks.mCrimsonDoor, Block.ref()),
daccess(MCAPI.VanillaBlocks.mWarpedDoor, Block.ref()),
];
});

const original = symhook("?_useOn@DoorItem@@EEBA_NAEAVItemStack@@AEAVActor@@VBlockPos@@EAEBVVec3@@@Z",
bool_t, null, StaticPointer, ItemStack, Actor, BlockPos, uint8_t, Vec3)
((thiz, instance, entity, pos, face, clickPos) => {
if (entity.isPlayer()) {
let block!: Block;
switch (daccess(thiz, int32_t, 552)) {
case 0:
block = Block.constructWith("minecraft:wooden_door")!;
break;
case 1:
block = Block.constructWith("minecraft:spruce_door")!;
break;
case 2:
block = Block.constructWith("minecraft:birch_door")!;
break;
case 3:
block = Block.constructWith("minecraft:jungle_door")!;
break;
case 4:
block = Block.constructWith("minecraft:acacia_door")!;
break;
case 5:
block = Block.constructWith("minecraft:dark_oak_door")!;
break;
case 6:
block = Block.constructWith("minecraft:iron_door")!;
break;
case 7:
block = Block.constructWith("minecraft:crimson_door")!;
break;
case 8:
block = Block.constructWith("minecraft:warped_door")!;
}
const block = doors[daccess(thiz, int32_t, 552)];
if (!block) {
return false;
}
Expand Down
20 changes: 20 additions & 0 deletions src/dep/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ const RVAs = pdb.getList(path.join(__dirname, "pdb.ini"), {}, [
// TridentItem
"?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z",
// VanillaBlocks
"?mWoodenDoor@VanillaBlocks@@3PEBVBlock@@EB",
"?mWoodenDoorSpruce@VanillaBlocks@@3PEBVBlock@@EB",
"?mWoodenDoorBirch@VanillaBlocks@@3PEBVBlock@@EB",
"?mWoodenDoorJungle@VanillaBlocks@@3PEBVBlock@@EB",
"?mWoodenDoorAcacia@VanillaBlocks@@3PEBVBlock@@EB",
"?mWoodenDoorDarkOak@VanillaBlocks@@3PEBVBlock@@EB",
"?mIronDoor@VanillaBlocks@@3PEBVBlock@@EB",
"?mCrimsonDoor@VanillaBlocks@@3PEBVBlock@@EB",
"?mWarpedDoor@VanillaBlocks@@3PEBVBlock@@EB",

"?mWallSign@VanillaBlocks@@3PEBVBlock@@EB",
"?mSign@VanillaBlocks@@3PEBVBlock@@EB",
"?mSpruceWallSign@VanillaBlocks@@3PEBVBlock@@EB",
Expand Down Expand Up @@ -513,6 +523,16 @@ export namespace MCAPI {
}
}
export namespace VanillaBlocks {
export const mWoodenDoor = dlsym("?mWoodenDoor@VanillaBlocks@@3PEBVBlock@@EB");
export const mWoodenDoorSpruce = dlsym("?mWoodenDoorSpruce@VanillaBlocks@@3PEBVBlock@@EB");
export const mWoodenDoorBirch = dlsym("?mWoodenDoorBirch@VanillaBlocks@@3PEBVBlock@@EB");
export const mWoodenDoorJungle = dlsym("?mWoodenDoorJungle@VanillaBlocks@@3PEBVBlock@@EB");
export const mWoodenDoorAcacia = dlsym("?mWoodenDoorAcacia@VanillaBlocks@@3PEBVBlock@@EB");
export const mWoodenDoorDarkOak = dlsym("?mWoodenDoorDarkOak@VanillaBlocks@@3PEBVBlock@@EB");
export const mIronDoor = dlsym("?mIronDoor@VanillaBlocks@@3PEBVBlock@@EB");
export const mCrimsonDoor = dlsym("?mCrimsonDoor@VanillaBlocks@@3PEBVBlock@@EB");
export const mWarpedDoor = dlsym("?mWarpedDoor@VanillaBlocks@@3PEBVBlock@@EB");

export const mWallSign = dlsym("?mWallSign@VanillaBlocks@@3PEBVBlock@@EB");
export const mSign = dlsym("?mSign@VanillaBlocks@@3PEBVBlock@@EB");
export const mSpruceWallSign = dlsym("?mSpruceWallSign@VanillaBlocks@@3PEBVBlock@@EB");
Expand Down
9 changes: 9 additions & 0 deletions src/dep/pdb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,12 @@
?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z = 0x1363E10
?resetPlayerLevel@Player@@QEAAXXZ = 0xCA8A20
?maintainOldData@TransformationComponent@@QEAAXAEAVActor@@0AEBUTransformationDescription@@AEBUActorUniqueID@@AEBVLevel@@@Z = 0x8BB8F0
?mWoodenDoorDarkOak@VanillaBlocks@@3PEBVBlock@@EB = 0x229EC18
?mWoodenDoorJungle@VanillaBlocks@@3PEBVBlock@@EB = 0x229EC08
?mWoodenDoorAcacia@VanillaBlocks@@3PEBVBlock@@EB = 0x229EC10
?mWoodenDoorSpruce@VanillaBlocks@@3PEBVBlock@@EB = 0x229EBF8
?mWoodenDoorBirch@VanillaBlocks@@3PEBVBlock@@EB = 0x229EC00
?mCrimsonDoor@VanillaBlocks@@3PEBVBlock@@EB = 0x229F538
?mWoodenDoor@VanillaBlocks@@3PEBVBlock@@EB = 0x229E7D8
?mWarpedDoor@VanillaBlocks@@3PEBVBlock@@EB = 0x229F540
?mIronDoor@VanillaBlocks@@3PEBVBlock@@EB = 0x229E810

0 comments on commit f8922e8

Please sign in to comment.