Rename to Construct

This commit is contained in:
ForestOfLight
2025-04-19 14:15:19 -07:00
Unverified
parent 53438f3c60
commit 5e2da6e3ab
46 changed files with 102 additions and 57 deletions
@@ -0,0 +1,27 @@
import { Command } from '../lib/canopy/CanopyExtension';
import { extension } from '../config';
import { world, system } from '@minecraft/server';
import { MenuForm } from '../classes/MenuForm';
const ACTION_ITEM = 'minecraft:paper';
const menuCmd = new Command({
name: 'structool',
description: { text: 'Opens the StrucTool Menu. Using a paper will also open the menu.' },
usage: 'structool',
callback: (sender) => openMenu(sender)
});
extension.addCommand(menuCmd);
world.beforeEvents.itemUse.subscribe((event) => {
if (!event.source || event.itemStack?.typeId !== ACTION_ITEM) return;
event.cancel = true;
system.run(() => openMenu(event.source, event));
});
function openMenu(sender, event = void 0) {
const options = { jumpToInstance: true }
if (event)
options.instanceName = event.itemStack?.typeId;
new MenuForm(sender, options);
}