Skip to content

Commit 801d7d8

Browse files
committed
fix prop selection
1 parent 9e57a48 commit 801d7d8

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

pack/items/debug_stick.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"minecraft:hand_equipped": true,
1717
"minecraft:display_name": { "value": "§dDebug Stick§r" },
1818
"minecraft:max_stack_size": 1,
19-
"minecraft:can_destroy_in_creative": false,
2019
"minecraft:glint": true
2120
}
2221
}

src/index.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
world,
2323
system,
2424
ItemCustomComponent,
25-
ItemComponentMineBlockEvent,
2625
ItemComponentUseOnEvent,
2726
} from "@minecraft/server";
2827

@@ -45,19 +44,9 @@ const DEBUG_STICK_ID = "vyt:debug_stick";
4544
class DebugStickEvents implements ItemCustomComponent {
4645

4746
constructor() {
48-
this.onMineBlock = safeCallWrapper(this.onMineBlock).bind(this);
4947
this.onUseOn = safeCallWrapper(this.onUseOn).bind(this);
5048
}
5149

52-
onMineBlock(ev: ItemComponentMineBlockEvent) {
53-
if (ev.source.typeId != "minecraft:player")
54-
return;
55-
const player = getPlayerByID(ev.source.id);
56-
if (!player)
57-
return;
58-
changeSelectedProperty(player, ev.block);
59-
}
60-
6150
onUseOn(ev: ItemComponentUseOnEvent) {
6251
if (ev.source.typeId != "minecraft:player")
6352
return;
@@ -72,13 +61,6 @@ class DebugStickEvents implements ItemCustomComponent {
7261
}
7362

7463

75-
system.beforeEvents.startup.subscribe((ev) => {
76-
ev.itemComponentRegistry.registerCustomComponent(
77-
DEBUG_STICK_ID, new DebugStickEvents());
78-
});
79-
80-
81-
8264
// Players should not be able to break blocks using
8365
// the debug stick in survival
8466
//
@@ -87,9 +69,16 @@ world.beforeEvents.playerBreakBlock.subscribe(safeCallWrapper((ev) => {
8769
if (ev.itemStack?.typeId != DEBUG_STICK_ID)
8870
return;
8971
ev.cancel = true;
72+
changeSelectedProperty(ev.player, ev.block);
9073
}));
9174

9275

76+
system.beforeEvents.startup.subscribe((ev) => {
77+
ev.itemComponentRegistry.registerCustomComponent(
78+
DEBUG_STICK_ID, new DebugStickEvents());
79+
});
80+
81+
9382
/*============================================================================*\
9483
+* Action functions
9584
\*============================================================================*/

0 commit comments

Comments
 (0)