forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_0.3.0.2.js
More file actions
91 lines (84 loc) · 2.23 KB
/
test_0.3.0.2.js
File metadata and controls
91 lines (84 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// test script for server-editor-bindings 0.3.1
import {
ActionTypes,
InputModifier,
KeyboardKey,
registerEditorExtension,
} from "@minecraft/server-editor";
registerEditorExtension("jayly", (session) => {
const tool = session.toolRail.addTool({
displayString: "Test button",
tooltip: "Left mouse click or drag-to-paint",
icon: "pack://textures/editor/Cube.png?filtering=point",
});
const menu = session.createMenu({
name: "test",
displayStringLocId: "test.mc",
});
tool.onModalToolActivation.subscribe((event) => {
if (!event.isActiveTool) return;
const clipboardManager = session.extensionContext.clipboardManager;
const selectionManager = session.extensionContext.selectionManager;
const {
peekLastVolume,
borderColor,
boundingBox,
isEmpty,
visible,
fillColor,
} = selectionManager.createSelection();
peekLastVolume.boundingBox.center;
borderColor.red;
borderColor.green;
borderColor.blue;
borderColor.alpha;
boundingBox.center.x;
isEmpty.valueOf();
visible.valueOf;
fillColor.green;
tool.registerKeyBinding(
{
actionType: ActionTypes.NoArgsAction,
id: "testid",
onExecute() {
console.warn("test");
},
},
KeyboardKey.F4,
InputModifier.Alt
);
tool.registerMouseButtonBinding(
session.actionManager.createAction({
actionType: ActionTypes.MouseRayCastAction,
onExecute(mouseRay, mouseProps) {
console.warn(mouseProps.inputType, mouseRay.location);
},
})
);
tool.registerMouseDragBinding(
session.actionManager.createAction({
actionType: ActionTypes.NoArgsAction,
onExecute() {},
})
);
tool.registerMouseWheelBinding(
session.actionManager.createAction({
actionType: ActionTypes.NoArgsAction,
onExecute() {},
})
);
menu.addItem(
{
name: "e",
displayStringLocId: "e",
},
session.actionManager.createAction({
actionType: ActionTypes.MouseRayCastAction,
onExecute(mouseRay, mouseProps) {
mouseProps.inputType;
mouseRay.cursorBlockLocation.x;
},
})
);
});
});