Skip to content

Commit a8bf81d

Browse files
committed
Update definitions
1 parent 5c29411 commit a8bf81d

File tree

202 files changed

+6472
-1997
lines changed

Some content is hidden

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

202 files changed

+6472
-1997
lines changed

definitions/feature/module.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,13 @@ declare class Module {
120120
* @param defVal The default value
121121
*/
122122
addTextSetting(name: string, displayName: string, description: string, defVal: string): Setting;
123+
124+
/**
125+
Adds a setting.
126+
* @param name The internal name
127+
* @param displayName The name that shows in the menu
128+
* @param description A short description of what the setting does
129+
* @param defVal The default value
130+
*/
131+
addColorSetting(name: string, displayName: string, description: string, defVal: Color): Setting;
123132
}

definitions/game.d.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ interface Game {
4242
getPort(): number;
4343

4444
/**
45-
* Get the current world that you're in.
45+
* @deprecated use `world`
46+
* Get the World object.
4647
*/
47-
getWorld() : World | null;
48+
getWorld() : World;
49+
50+
51+
/**
52+
* @deprecated use `dimension`
53+
* Get the Dimension object.
54+
*/
55+
getDimension(): Dimension;
4856

4957
/**
5058
* Get whether you are in a UI screen

definitions/gfx/graphics.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ declare interface Graphics {
118118
drawRect(rect: Rect, color: Color, thickness: number): void;
119119
fillRect(rect: Rect, color: Color): void;
120120

121+
getTextSize(text: string, textSize: number): Vector2;
122+
123+
setClippingRect(rect: Rect): void;
124+
restoreClippingRect(): void;
125+
121126
/**
122127
* Draws text on the position specified
123128
* @param pos The position to draw the text

definitions/gfx/graphics3.d.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
interface Graphics3DObject {
2-
drawLine(p1: Vector3, p2: Vector3, color: Color): void;
3-
drawBox(p1: Vector3, p2: Vector3, color: Color): void;
4-
}
5-
61
declare interface Graphics3D {
2+
3+
/**
4+
* Sets the color.
5+
* @param color The color to set
6+
*/
7+
setColor(color: Color): void;
8+
9+
/**
10+
* Sets the colors. (allows for gradients)
11+
* @param color The color to set
12+
*/
13+
setColors(vec1: Color, vec2: Color, vec3: Color, vec4: Color): void;
14+
15+
/**
16+
* Draws a line into the world (adds a line into the vertex buffer)
17+
* @param p1
18+
* @param p2
19+
*/
20+
drawLine(p1: Vector3, p2: Vector3): void;
21+
22+
/**
23+
* Draws a triangle into the world (adds a triangle into the vertex buffer)
24+
* @param p1
25+
* @param p2
26+
* @param p3
27+
*/
28+
drawTriangle(p1: Vector3, p2: Vector3, p3: Vector3): void;
29+
30+
/**
31+
* Draws a quad into the world (adds a quad into the vertex buffer)
32+
* @param p1
33+
* @param p2
34+
* @param p3
35+
* @param p4
36+
*/
37+
drawQuad(p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3): void;
38+
739
/**
8-
* Draws a mesh.
9-
* @param func
40+
* Call this every time you're done rendering. (batched renders the current vertex buffer into the world)
41+
* @param cull `true` for rendering through blocks, `false` to not render through blocks
1042
*/
11-
draw(func: (obj: Graphics3DObject) => void): void;
43+
finish(cull?: boolean): void;
1244
}
1345

14-
declare const gfx3d: Graphics3D;
46+
declare const graphics3D: Graphics3D;

definitions/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/// <reference path="./game.d.ts" />
44
/// <reference path="./latite.d.ts" />
55

6+
/// <reference path="./world/block.d.ts" />
7+
/// <reference path="./world/dimension.d.ts" />
68
/// <reference path="./world/world.d.ts" />
79
/// <reference path="./world/item.d.ts" />
810
/// <reference path="./world/entity.d.ts" />

definitions/latite.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,14 @@ interface ClientEvents {
225225
"text-input": TextInputEvent;
226226

227227
/**
228-
* Called whenever the player joins or changes worlds (does not fire when the player leaves the world).
228+
* Called whenever the server transfers a player into another server.
229229
*/
230-
"world-change": LatiteEvent;
230+
"transfer": LatiteEvent;
231+
232+
/**
233+
* Calls whenever the player goes into a different dimension.
234+
*/
235+
"change-dimension": LatiteEvent;
231236
}
232237

233238
interface Latite {

definitions/script.d.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ interface EngineLibraries {
55
}
66

77
/**
8-
* Prints to chat.
9-
* @param contents The contents to log.
8+
* Adds chat message(s) to the chat.
9+
* @param contents The contents to send to chat. They will be separated into different chat messages.
1010
*/
11-
declare function clientMessage(... contents: any[]): void;
11+
declare function clientMessage(... messages: any[]): void;
1212

1313
/**
1414
* Load a specified library.
15-
* @param path The filepath, HTTP or HTTPS link to the JS file.
16-
* @throws Invalid filepath or Non-OK HTTP/HTTPS error code
15+
* @param library The Latite Scripting engine built-in library.
1716
*/
18-
declare function require<K extends keyof EngineLibraries>(path: K): EngineLibraries[K];
17+
declare function require<K extends keyof EngineLibraries>(library: K): EngineLibraries[K];
1918

2019
/**
21-
*
22-
* @param path The path to load the library
20+
* Load and run a specified JavaScript module. This returns whatever is in `exports` or `module.exports` of the JavaScript module.
21+
* @param path The path to load the JavaScript file.
2322
*/
2423
declare function require(path: string): any;
2524

@@ -43,10 +42,22 @@ declare function setTimeout(func: () => void, timeout: number): number;
4342
* Calls a function every x milliseconds.
4443
* @param func The function to call
4544
* @param timeout The time in milliseconds
46-
* @returns The Timeout ID
45+
* @returns The Interval ID
4746
*/
4847
declare function setInterval(func: () => void, timeout: number): number;
4948

49+
/**
50+
* Cancels a timeout with a specified ID (stops it from executing.) No effect if the id is invalid.
51+
* @param timeoutId A valid Timeout ID. It is the return value of the `setTimeout` function.
52+
*/
53+
declare function clearTimeout(timeoutId: number): void;
54+
55+
/**
56+
* Cancels an interval with a specified ID (stops it from executing.) No effect if the id is invalid.
57+
* @param intervalId A valid Interval ID. It is the return value of the `setInterval` function.
58+
*/
59+
declare function clearInterval(intervalId: number): void;
60+
5061
interface ScriptModule {
5162
/**
5263
* What the script exports.

definitions/world/block.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
declare class Block {
2+
/**
3+
* Example: minecraft:deepslate_diamond_ore
4+
*/
5+
public readonly name: string;
6+
/**
7+
* Examle: tile.stone.stone
8+
*/
9+
public readonly translateName: string;
10+
11+
/**
12+
* Example: itemGroup.name.ore
13+
*/
14+
public readonly itemGroupName: string;
15+
}

definitions/world/dimension.d.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
declare interface Dimension {
2+
/**
3+
* Returns `true` if in a dimension, returns `false` if not. You will only be able to use the Dimension methods if you are in a world.
4+
*/
5+
exists(): boolean;
6+
7+
/**
8+
* Gets a block at the specified position. Will return null if no block was found. (If it's air, it will also return a Block)
9+
* @param x Integer for x coordinate
10+
* @param y Integer for y coordinate
11+
* @param z Integer for z coordinate
12+
*/
13+
getBlock(x: number, y: number, z: number): Block;
14+
15+
16+
/**
17+
* Gets the dimension's name, for example, `"Overworld"`
18+
*/
19+
getName(): string;
20+
}
21+
22+
23+
declare const dimension: Dimension;

definitions/world/entity.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ declare class Entity {
1818
* @throws
1919
*/
2020
getPosition(): Vector3;
21+
22+
/**
23+
* Get the interpolated position. Use this in the context of rendering based on entity position.
24+
*/
25+
getPositionInterpolated(): Vector3;
26+
27+
/**
28+
* Get the position the entity was in the last tick.
29+
*/
30+
getPreviousPosition(): Vector3;
31+
2132
/**
2233
* Get the rotation. Note that this will fail if you dont have permission to get the rotation
2334
* @throws

0 commit comments

Comments
 (0)