Skip to content

Commit 8c5a40d

Browse files
JaylyDevbot174
andauthored
Merge editor scripts to 1.20.10.21 (JaylyDev#254)
* merge editor scripts * resolve merge --------- Co-authored-by: bot174 <[email protected]>
1 parent 050e58a commit 8c5a40d

58 files changed

Lines changed: 595 additions & 452 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/JaylyDev/ScriptAPI#readme",
2121
"dependencies": {
22-
"@jayly/minecraft-editor": "0.3.6-3",
22+
"@jayly/minecraft-editor": "0.3.6-4",
2323
"@minecraft/server": "1.4.0-beta.1.20.10-preview.21",
2424
"@minecraft/server-admin": "1.0.0-beta.1.20.10-preview.21",
2525
"@minecraft/server-gametest": "1.0.0-beta.1.20.10-preview.21",

packages/minecraft-editor/@minecraft/server-editor.d.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* ```
1111
*/
1212
declare module "@minecraft/server-editor" {
13-
import { AfterEvents, Player, System, Vector3 } from "@minecraft/server";
13+
import { WorldAfterEvents, BlockType, Player, System, Vector3 } from "@minecraft/server";
1414
import { Extension, ExtensionContext, Selection, ExtensionOptionalParameters, Logger } from "@minecraft/server-editor-bindings";
1515
export * from "@minecraft/server-editor-bindings";
1616
class BaseControl {
@@ -28,13 +28,13 @@ declare module "@minecraft/server-editor" {
2828
}
2929
export interface ToolParams {
3030
name?: string;
31-
displayString?: string;
32-
displayStringLocId?: string;
31+
displayAltText?: string;
32+
displayStringId?: string;
3333
icon?: string;
34-
tooltip?: string;
35-
tooltipLocId?: string;
34+
tooltipAltText?: string;
35+
tooltipStringId?: string;
3636
}
37-
class EventToken<H extends keyof AfterEvents = keyof AfterEvents, K extends AfterEvents[H] = AfterEvents[H]> {
37+
class EventToken<H extends keyof WorldAfterEvents = keyof WorldAfterEvents, K extends WorldAfterEvents[H] = WorldAfterEvents[H]> {
3838
constructor(_event: K);
3939
unsubscribe(): void;
4040
}
@@ -126,7 +126,7 @@ declare module "@minecraft/server-editor" {
126126
}
127127
export interface MenuProps {
128128
name?: string;
129-
displayStringLocId?: string;
129+
displayStringId?: string;
130130
}
131131
class Menu extends BaseControl {
132132
constructor(props: any, _dispatcher: any, _actionId: any, _parent: any);
@@ -139,7 +139,7 @@ declare module "@minecraft/server-editor" {
139139
private _name: string;
140140
get id(): string;
141141
get submenu(): Menu[];
142-
get displayStringLocId(): string;
142+
get displayStringId(): string;
143143
get name(): string;
144144
set name(value: string);
145145
dispose(): void;
@@ -189,14 +189,14 @@ declare module "@minecraft/server-editor" {
189189
removePropertyPane(paneToRemove: PropertyPane): boolean;
190190
hide(): void;
191191
show(): void;
192-
addString(obj: Record<string, any>, property: string, options: PaneOptions): PropertyItem;
193-
addBool(obj: Record<string, any>, property: string, options: BoolPaneOptions): PropertyItem;
194-
addNumber(obj: Record<string, any>, property: string, options: NumberPaneOptions): PropertyItem;
195-
addBlockPicker(obj: Record<string, any>, property: string, options: BlockPickerPaneOptions): PropertyItem;
196-
addButton(action: Record<string, any>, options: ButtonPaneOptions): PropertyItem;
197-
addDropdown<T>(obj: Record<string, any>, property: string, options: DropdownPaneOptions<T>): PropertyItem;
192+
addString<K extends string, T extends Record<K, string> & Record<string, any>>(obj: T, property: K, options: PaneOptions): PropertyItem;
193+
addBool<K extends string, T extends Record<K, boolean> & Record<string, any>>(obj: T, property: K, options: BoolPaneOptions<T, K>): PropertyItem;
194+
addNumber<K extends string, T extends Record<K, number> & Record<string, any>>(obj: T, property: K, options: NumberPaneOptions<T, K>): PropertyItem;
195+
addBlockPicker<K extends string, T extends Record<K, BlockType> & Record<string, any>>(obj: T, property: K, options: BlockPickerPaneOptions): PropertyItem;
196+
addButton(action: Action<ActionTypes>, options: ButtonPaneOptions): PropertyItem;
197+
addDropdown<T, K extends string, H extends Record<K, T> & Record<string, any>>(obj: H, property: K, options: DropdownPaneOptions<T, H, K>): PropertyItem;
198198
addDivider(): PropertyItem;
199-
addVec3(obj: Record<string, any>, property: string, options: Vec3PaneOptions): PropertyItem;
199+
addVector3<K extends string, T extends Record<K, Vector3> & Record<string, any>>(obj: T, property: K, options: Vec3PaneOptions): PropertyItem;
200200
}
201201
class StatusBarItem extends BaseControl {
202202
private _id: string;
@@ -297,24 +297,24 @@ declare module "@minecraft/server-editor" {
297297
visible?: boolean;
298298
width?: number;
299299
}
300-
export interface BoolPaneOptions extends PaneOptions {
301-
onChange?: (_obj: object, _property: string, _oldValue: boolean, _newValue: boolean) => void;
300+
export interface BoolPaneOptions<T, K> extends PaneOptions {
301+
onChange?: (_obj: T, _property: K, _oldValue: boolean, _newValue: boolean) => void;
302302
}
303303
export interface BlockPickerPaneOptions extends PaneOptions {
304304
allowedBlocks?: string[];
305305
}
306306
export interface ButtonPaneOptions extends PaneOptions {
307307
variant?: string;
308308
}
309-
export interface DropdownPaneOptions<T> extends PaneOptions {
310-
onChange?: (_obj: object, _property: string, _oldValue: T, _newValue: T) => void;
309+
export interface DropdownPaneOptions<T, H, K> extends PaneOptions {
310+
onChange?: (_obj: H, _property: K, _oldValue: T, _newValue: T) => void;
311311
dropdownItems: DropdownItem<T>[];
312312
}
313-
export interface NumberPaneOptions extends PaneOptions {
313+
export interface NumberPaneOptions<T, K> extends PaneOptions {
314314
min?: number;
315315
max?: number;
316316
showSlider?: boolean;
317-
onChange?: (_obj: object, _property: string, _oldValue: number, _newValue: number) => void;
317+
onChange?: (_obj: T, _property: K, _oldValue: number, _newValue: number) => void;
318318
}
319319
export interface Vec3PaneOptions extends PaneOptions {
320320
minX: number;
@@ -329,7 +329,7 @@ declare module "@minecraft/server-editor" {
329329
* Represents a UI session for a given player
330330
* @internal
331331
*/
332-
class PlayerUISession {
332+
class PlayerUISession<T = unknown>{
333333
private _builtInUIManager: BuiltInUIManagerImpl;
334334
private _actionManager: ActionManagerImpl;
335335
private _modalToolContainer: ModalToolContainer;
@@ -341,7 +341,7 @@ declare module "@minecraft/server-editor" {
341341
private _inputManager: GlobalInputManager;
342342
private _logger: Logger;
343343
private createPropertyPaneInternal(options: PaneOptions, parentPaneId: string): PropertyPane;
344-
scratchStorage?: Record<string, any>;
344+
scratchStorage?: T;
345345
teardown(): void;
346346
get toolRail(): ModalToolContainer;
347347
createMenu(props: MenuProps): Menu;
@@ -369,7 +369,7 @@ declare module "@minecraft/server-editor" {
369369
* @beta
370370
*/
371371
export class BedrockEventSubscriptionCache {
372-
constructor(mEvents: AfterEvents);
372+
constructor(mEvents: WorldAfterEvents);
373373
/**
374374
* Subcribes to a bedrock event using the key of the desired event. When subscribed, the event handler
375375
* is both returned, but also cached internally for unsubscription. This means the caller of the subscription
@@ -379,9 +379,9 @@ declare module "@minecraft/server-editor" {
379379
* @param event - The event on the bedrock APIs to which to subscribe
380380
* @param params - The parameters to the subscription method for the event. Auto complete will display this for you
381381
*/
382-
subscribeToBedrockEvent<T extends keyof AfterEvents>(event: T, ...params: Parameters<AfterEvents[T]["subscribe"]>): ReturnType<AfterEvents[T]["subscribe"]>;
382+
subscribeToBedrockEvent<T extends keyof WorldAfterEvents>(event: T, ...params: Parameters<WorldAfterEvents[T]["subscribe"]>): ReturnType<WorldAfterEvents[T]["subscribe"]>;
383383
teardown(): void;
384-
private mEvents: AfterEvents;
384+
private mEvents: WorldAfterEvents;
385385
private subscribedEvents: object;
386386
}
387387
/**
@@ -604,7 +604,7 @@ declare module "@minecraft/server-editor" {
604604
* Takes the input object and bind it to the pane.
605605
* @beta
606606
*/
607-
export function createPaneBindingObject<T>(propertyPane: PropertyPane, target: T): T;
607+
export function bindDataSource<T>(propertyPane: PropertyPane, target: T): T;
608608
/**
609609
* Executes an operation over a selection via chunks to allow splitting operation over multiple game ticks
610610
* @param selection - the selection to iterator over
@@ -632,7 +632,7 @@ declare module "@minecraft/server-editor" {
632632
/**
633633
* Interface for internal PlayerUISession class
634634
*/
635-
export interface IPlayerUISession extends PlayerUISession {
635+
export interface IPlayerUISession<T = unknown> extends PlayerUISession<T> {
636636
}
637637
/**
638638
* Interface for internal ModalTool class

packages/minecraft-editor/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/minecraft-editor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jayly/minecraft-editor",
3-
"version": "0.3.6-2",
3+
"version": "0.3.6-4",
44
"description": "Unofficial Minecraft Bedrock Editor API modules type definitions.",
55
"types": "index.d.ts",
66
"main": "",
@@ -15,6 +15,6 @@
1515
},
1616
"homepage": "https://github.com/JaylyDev/ScriptAPI#readme",
1717
"dependencies": {
18-
"@minecraft/server": "1.4.0-beta.1.20.10-preview.20"
18+
"@minecraft/server": "1.4.0-beta.1.20.10-preview.21"
1919
}
2020
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export const Shutdown = (/** @type {import("@minecraft/server-editor").IPlayerUISession} */ uiSession) => uiSession.log.debug( `Shutting down ${uiSession.extensionContext.extensionName} extension` );
1+
/**
2+
* @param {import("@minecraft/server-editor").IPlayerUISession} uiSession
3+
*/
4+
export const Shutdown = (uiSession) => uiSession.log.debug( `Shutting down ${uiSession.extensionContext.extensionName} extension` );

scripts/editor-extensions/Extensions/Actions/NightVision/Start.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as Server from "@minecraft/server";
22
import * as Editor from "@minecraft/server-editor";
3-
export const Start = (/** @type {import("@minecraft/server-editor").IPlayerUISession} */ uiSession) => {
3+
/**
4+
* @param {import("@minecraft/server-editor").IPlayerUISession} uiSession
5+
*/
6+
export const Start = (uiSession) => {
47
const menu = uiSession.createMenu(
58
{ name: "Night Vision" },
69
);

scripts/editor-extensions/Extensions/Divider.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
export default (/** @type {import("@minecraft/server-editor").IPlayerUISession} */ uiSession) => {
1+
/**
2+
* @param {import("@minecraft/server-editor").IPlayerUISession} uiSession
3+
*/
4+
export default (uiSession) => {
25
uiSession.toolRail.addTool(
36
{
4-
displayString: "Divider",
7+
displayAltText: "Divider",
58
icon: "pack://textures/editor/divider.png?filtering=point",
69
},
710
);

scripts/editor-extensions/Extensions/StatusBars/PlayerPosition/Shutdown.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as Server from "@minecraft/server";
2-
export const Shutdown = (/** @type {import("@minecraft/server-editor").IPlayerUISession} */ uiSession) => {
2+
/**
3+
* @param {import("@minecraft/server-editor").IPlayerUISession} uiSession
4+
*/
5+
export const Shutdown = (uiSession) => {
36
if (
47
uiSession.scratchStorage
58
&& uiSession.scratchStorage.latestRunId !== -1

scripts/editor-extensions/Extensions/StatusBars/PlayerPosition/Start.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ const dimensions = {
77
"minecraft:the_end": "The End",
88
};
99

10-
const areLocationsEqual = (/** @type {Server.Vector3} */ a, /** @type {Server.Vector3} */ b) => a.x === b.x && a.y === b.y && a.z === b.z;
11-
export const Start = (/** @type {import("@minecraft/server-editor").IPlayerUISession} */ uiSession) => {
10+
const areLocationsEqual = (a, b) => a.x === b.x && a.y === b.y && a.z === b.z;
11+
/**
12+
* @param {import("@minecraft/server-editor").IPlayerUISession} uiSession
13+
*/
14+
export const Start = (uiSession) => {
1215
console.log(`Initializing ${uiSession.extensionContext.extensionName} extension`);
1316
uiSession.scratchStorage = {
1417
isDisposed: false,

0 commit comments

Comments
 (0)