simplified-mojang-api 0.0.7 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/afterEventsSimplifiedManager.d.ts +18 -0
- package/dist/events/afterEventsSimplifiedManager.js +18 -0
- package/dist/events/beforeEventsSimplifiedManager.d.ts +21 -0
- package/dist/events/beforeEventsSimplifiedManager.js +21 -0
- package/dist/events/fakePlysManagerSimplififed.d.ts +38 -0
- package/dist/events/fakePlysManagerSimplififed.js +50 -0
- package/dist/events/worldToolsSimplifiedManager.d.ts +69 -0
- package/dist/events/worldToolsSimplifiedManager.js +83 -0
- package/package.json +15 -20
- package/structures/ha/void.mcstructure +0 -0
|
@@ -18,6 +18,12 @@ declare class AfterEventsSimplified {
|
|
|
18
18
|
* @param {(args: mc.EntityDieAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
19
19
|
* @author HaJuegos - 11-03-2026
|
|
20
20
|
* @public
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* afterEventsSimplified.onEntityDie((event) => {
|
|
24
|
+
* console.warn(`La entidad ${args.entity.typeId} murio en ${args.location}`);
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
21
27
|
*/
|
|
22
28
|
onEntityDie(callback: (args: mc.EntityDieAfterEvent) => void): void;
|
|
23
29
|
/**
|
|
@@ -25,6 +31,12 @@ declare class AfterEventsSimplified {
|
|
|
25
31
|
* @param {(args: mc.PlayerSpawnAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
26
32
|
* @author HaJuegos - 11-03-2026
|
|
27
33
|
* @public
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* afterEventsSimplified.onPlayerSpawns((args) => {
|
|
37
|
+
* console.warn(`El Jugador ${args.player.name} spawneo en ${args.player.location}`);
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
28
40
|
*/
|
|
29
41
|
onPlayerSpawns(callback: (args: mc.PlayerSpawnAfterEvent) => void): void;
|
|
30
42
|
/**
|
|
@@ -32,6 +44,12 @@ declare class AfterEventsSimplified {
|
|
|
32
44
|
* @param {(args: mc.WorldLoadAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
33
45
|
* @author HaJuegos - 11-03-2026
|
|
34
46
|
* @public
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* afterEventsSimplified.onWorldReady(() => {
|
|
50
|
+
* console.warn(`El mundo se ha cargado correctamente`);
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
35
53
|
*/
|
|
36
54
|
onWorldReady(callback: (args: mc.WorldLoadAfterEvent) => void): void;
|
|
37
55
|
}
|
|
@@ -20,6 +20,12 @@ class AfterEventsSimplified {
|
|
|
20
20
|
* @param {(args: mc.EntityDieAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
21
21
|
* @author HaJuegos - 11-03-2026
|
|
22
22
|
* @public
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* afterEventsSimplified.onEntityDie((event) => {
|
|
26
|
+
* console.warn(`La entidad ${args.entity.typeId} murio en ${args.location}`);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
23
29
|
*/
|
|
24
30
|
onEntityDie(callback) {
|
|
25
31
|
this.entityDieManager.register(callback);
|
|
@@ -29,6 +35,12 @@ class AfterEventsSimplified {
|
|
|
29
35
|
* @param {(args: mc.PlayerSpawnAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
30
36
|
* @author HaJuegos - 11-03-2026
|
|
31
37
|
* @public
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* afterEventsSimplified.onPlayerSpawns((args) => {
|
|
41
|
+
* console.warn(`El Jugador ${args.player.name} spawneo en ${args.player.location}`);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
32
44
|
*/
|
|
33
45
|
onPlayerSpawns(callback) {
|
|
34
46
|
this.playerSpawnManager.register(callback);
|
|
@@ -38,6 +50,12 @@ class AfterEventsSimplified {
|
|
|
38
50
|
* @param {(args: mc.WorldLoadAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
39
51
|
* @author HaJuegos - 11-03-2026
|
|
40
52
|
* @public
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* afterEventsSimplified.onWorldReady(() => {
|
|
56
|
+
* console.warn(`El mundo se ha cargado correctamente`);
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
41
59
|
*/
|
|
42
60
|
onWorldReady(callback) {
|
|
43
61
|
this.worldLoadManager.register(callback);
|
|
@@ -19,6 +19,13 @@ declare class BeforeEventsSimplified {
|
|
|
19
19
|
* @param {(args: mc.StartupEvent) => void} callback Los argumentos del evento y su logica.
|
|
20
20
|
* @author HaJuegos - 11-03-2026
|
|
21
21
|
* @public
|
|
22
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* beforeEventsSimplified.onAddonStarts((args) => {
|
|
26
|
+
* console.warn('El addon esta iniciando');
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
22
29
|
*/
|
|
23
30
|
onAddonStarts(callback: (args: mc.StartupEvent) => void): void;
|
|
24
31
|
/**
|
|
@@ -26,6 +33,13 @@ declare class BeforeEventsSimplified {
|
|
|
26
33
|
* @param {(args: mc.ShutdownEvent) => void} callback Los argumentos del evento y su logica.
|
|
27
34
|
* @author HaJuegos - 11-03-2026
|
|
28
35
|
* @public
|
|
36
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* beforeEventsSimplified.onAddonStops((args) => {
|
|
40
|
+
* console.warn('El addon se esta detendiendo');
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
29
43
|
*/
|
|
30
44
|
onAddonStops(callback: (args: mc.ShutdownEvent) => void): void;
|
|
31
45
|
/**
|
|
@@ -33,6 +47,13 @@ declare class BeforeEventsSimplified {
|
|
|
33
47
|
* @param {(args: mc.PlayerInteractWithBlockBeforeEvent) => void} callback Los argumentos del evento y su logica.
|
|
34
48
|
* @author HaJuegos - 11-03-2026
|
|
35
49
|
* @public
|
|
50
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* beforeEventsSimplified.onInteractBlock((args) => {
|
|
54
|
+
* console.warn(`Se esta interactuando con el bloque ${args.block.typeId}`);
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
36
57
|
*/
|
|
37
58
|
onInteractBlock(callback: (args: mc.PlayerInteractWithBlockBeforeEvent) => void): void;
|
|
38
59
|
}
|
|
@@ -21,6 +21,13 @@ class BeforeEventsSimplified {
|
|
|
21
21
|
* @param {(args: mc.StartupEvent) => void} callback Los argumentos del evento y su logica.
|
|
22
22
|
* @author HaJuegos - 11-03-2026
|
|
23
23
|
* @public
|
|
24
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* beforeEventsSimplified.onAddonStarts((args) => {
|
|
28
|
+
* console.warn('El addon esta iniciando');
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
24
31
|
*/
|
|
25
32
|
onAddonStarts(callback) {
|
|
26
33
|
this.startUpManager.register(callback);
|
|
@@ -30,6 +37,13 @@ class BeforeEventsSimplified {
|
|
|
30
37
|
* @param {(args: mc.ShutdownEvent) => void} callback Los argumentos del evento y su logica.
|
|
31
38
|
* @author HaJuegos - 11-03-2026
|
|
32
39
|
* @public
|
|
40
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* beforeEventsSimplified.onAddonStops((args) => {
|
|
44
|
+
* console.warn('El addon se esta detendiendo');
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
33
47
|
*/
|
|
34
48
|
onAddonStops(callback) {
|
|
35
49
|
this.shutDownManager.register(callback);
|
|
@@ -39,6 +53,13 @@ class BeforeEventsSimplified {
|
|
|
39
53
|
* @param {(args: mc.PlayerInteractWithBlockBeforeEvent) => void} callback Los argumentos del evento y su logica.
|
|
40
54
|
* @author HaJuegos - 11-03-2026
|
|
41
55
|
* @public
|
|
56
|
+
* @beforeEvent Es un evento que se ejecuta antes de que pase dicho evento en concreto.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* beforeEventsSimplified.onInteractBlock((args) => {
|
|
60
|
+
* console.warn(`Se esta interactuando con el bloque ${args.block.typeId}`);
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
42
63
|
*/
|
|
43
64
|
onInteractBlock(callback) {
|
|
44
65
|
this.interactBlockManager.register(callback);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as mc from "@minecraft/server";
|
|
2
|
+
import * as gametest from "@minecraft/server-gametest";
|
|
3
|
+
/**
|
|
4
|
+
* Clase hijo que controla los eventos simplificados sobre jugadores falsos por medio de scripts.
|
|
5
|
+
* @author HaJuegos - 13-03-2026
|
|
6
|
+
*/
|
|
7
|
+
declare class FakePlysManager {
|
|
8
|
+
/**
|
|
9
|
+
* Variable privada que contiene la informacion de un gametest command generado.
|
|
10
|
+
* @type {?gametest.Test}
|
|
11
|
+
* @author HaJuegos - 14-03-2026
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private testContext?;
|
|
15
|
+
/**
|
|
16
|
+
* Eventos iniciales de la clase cuando es inicializada o llamada.
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Metodo auxiliar que crea un nuevo tipo de jugador falso para metodos de pruebas.
|
|
22
|
+
* @param {string} namePly Nombre a asignar al jugador de pruebas.
|
|
23
|
+
* @param {mc.GameMode} gamemodePly El modo de juego que tendra el jugador de pruebas.
|
|
24
|
+
* @param {?mc.Vector3} [defaultSpawnLocation] (Opcional) Coordenadas donde aparecera el jugador de pruebas. Por defecto, ira a un jugador aleatorio
|
|
25
|
+
* @returns {gametest.SimulatedPlayer} Los datos del jugador falso generado.
|
|
26
|
+
* @author HaJuegos - 13-03-2026
|
|
27
|
+
* @gametestEvent Es un metodo gametest, usando estructuras de pruebas por medio del comando /gametest run.
|
|
28
|
+
* @public
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Esto genera un jugador de pruebas con sus respectivos datos para usar.
|
|
32
|
+
* const fakePly = fakePlysSimplified.createFakePly('Jugador Prueba', mc.GameMode.Survival);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
createFakePly(namePly: string, gamemodePly: mc.GameMode, defaultSpawnLocation?: mc.Vector3): gametest.SimulatedPlayer | undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare const fakePlysSimplified: FakePlysManager;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as gametest from "@minecraft/server-gametest";
|
|
2
|
+
/**
|
|
3
|
+
* Clase hijo que controla los eventos simplificados sobre jugadores falsos por medio de scripts.
|
|
4
|
+
* @author HaJuegos - 13-03-2026
|
|
5
|
+
*/
|
|
6
|
+
class FakePlysManager {
|
|
7
|
+
/**
|
|
8
|
+
* Eventos iniciales de la clase cuando es inicializada o llamada.
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
gametest.register('ha', 'fakeplys', (test) => {
|
|
13
|
+
this.testContext = test;
|
|
14
|
+
})
|
|
15
|
+
.maxTicks(99999999)
|
|
16
|
+
.maxAttempts(1)
|
|
17
|
+
.structureName('ha:void');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Metodo auxiliar que crea un nuevo tipo de jugador falso para metodos de pruebas.
|
|
21
|
+
* @param {string} namePly Nombre a asignar al jugador de pruebas.
|
|
22
|
+
* @param {mc.GameMode} gamemodePly El modo de juego que tendra el jugador de pruebas.
|
|
23
|
+
* @param {?mc.Vector3} [defaultSpawnLocation] (Opcional) Coordenadas donde aparecera el jugador de pruebas. Por defecto, ira a un jugador aleatorio
|
|
24
|
+
* @returns {gametest.SimulatedPlayer} Los datos del jugador falso generado.
|
|
25
|
+
* @author HaJuegos - 13-03-2026
|
|
26
|
+
* @gametestEvent Es un metodo gametest, usando estructuras de pruebas por medio del comando /gametest run.
|
|
27
|
+
* @public
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // Esto genera un jugador de pruebas con sus respectivos datos para usar.
|
|
31
|
+
* const fakePly = fakePlysSimplified.createFakePly('Jugador Prueba', mc.GameMode.Survival);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
createFakePly(namePly, gamemodePly, defaultSpawnLocation) {
|
|
35
|
+
if (this.testContext) {
|
|
36
|
+
const fakePly = this.testContext.spawnSimulatedPlayer({ x: 0, y: 1, z: 0 }, namePly, gamemodePly);
|
|
37
|
+
if (defaultSpawnLocation) {
|
|
38
|
+
fakePly.teleport(defaultSpawnLocation);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
fakePly.runCommand(`tp @r[name=!"${fakePly.name}"]`);
|
|
42
|
+
}
|
|
43
|
+
return fakePly;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(`No se pudo generar el jugador de pruebas ${namePly}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const fakePlysSimplified = new FakePlysManager();
|
|
@@ -10,11 +10,70 @@ declare class WorldToolsSimplified {
|
|
|
10
10
|
* @constructor
|
|
11
11
|
*/
|
|
12
12
|
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Metodo auxiliar que establece una serie de eventos con un pequeño retraso determinado. Luego de terminar el retraso, elimina la tarea para no dejarlo en memoria.
|
|
15
|
+
* @param {() => void} callback Los eventos en cuestion a ejecutar.
|
|
16
|
+
* @param {number} ticksDelay Los tiempos en ticks que se tardara para ejecutarse.
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
* @author HaJuegos - 13-03-2026
|
|
19
|
+
* @async Es un metodo asincrono, debido a que se limpia despues de la ejecucion.
|
|
20
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
21
|
+
* @public
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* worldToolsSimplified.setDelay(() => {
|
|
25
|
+
* console.warn('Este evento se ejecutara despues de 5 segundos');
|
|
26
|
+
* } worldToolsSimplified.convertSecondsToTicks(5))
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
setDelay(callback: () => void, ticksDelay: number): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Metodo auxiliar que establece una serie de eventos en concreto que se mantendran en loop.
|
|
32
|
+
* @param {() => void} callback Los eventos en concreto.
|
|
33
|
+
* @param {number} loopTicks El numero en ticks que se repetira este loop.
|
|
34
|
+
* @returns {number} Devuelve el ID de la memoria, del proceso loop creado.
|
|
35
|
+
* @author HaJuegos - 13-03-2026
|
|
36
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
37
|
+
* @public
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* worldToolsSimplified.setLoop(() => {
|
|
41
|
+
* console.warn('Este evento se ejecutara cada 1 segundo');
|
|
42
|
+
* } worldToolsSimplified.convertSecondsToTicks(1))
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
setLoop(callback: () => void, loopTicks: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Metodo auxiliar que detiene un proceso looping creado previamente por medio de su ID generado en memoria.
|
|
48
|
+
* @param {number} runID ID del proceso generado.
|
|
49
|
+
* @author HaJuegos - 13-03-2026
|
|
50
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
51
|
+
* @public
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Se crea el evento primero, generado su ID en memoria.
|
|
55
|
+
* const idLoop = worldToolsSimplified.setLoop(() => {
|
|
56
|
+
* console.warn('este evento se esta repitiendo cada 1 segundo');
|
|
57
|
+
* } worldToolsSimplified.convertSecondsToTicks(1))
|
|
58
|
+
*
|
|
59
|
+
* // Con el ID generado en memoria, lo usamos para detenerlo cuando queramos.
|
|
60
|
+
* worldToolsSimplified.stopLoop(idLoop);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
stopLoop(runID: number): void;
|
|
13
64
|
/**
|
|
14
65
|
* Metodo auxiliar que envia un mensaje global al mundo en formato string o rawmessage.
|
|
15
66
|
* @public
|
|
16
67
|
* @param {(string | mc.RawMessage)} message Mensaje o RawMessage en concreto a enviar.
|
|
17
68
|
* @author HaJuegos - 12-03-2026
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* // Este es un mensaje simple
|
|
72
|
+
* worldToolsSimplified.sendMessageGlobal('hola soy un mensaje');
|
|
73
|
+
*
|
|
74
|
+
* // Este es un mensaje RawText
|
|
75
|
+
* worldToolsSimplified.sendMessageGlobal({ rawtext: 'chat.test.message' });
|
|
76
|
+
* ```
|
|
18
77
|
*/
|
|
19
78
|
sendMessageGlobal(message: string | mc.RawMessage): void;
|
|
20
79
|
/**
|
|
@@ -23,6 +82,11 @@ declare class WorldToolsSimplified {
|
|
|
23
82
|
* @param {number} seconds Los segundos a convertir.
|
|
24
83
|
* @returns {number} Los ticks convertidos.
|
|
25
84
|
* @author HaJuegos - 12-03-2026
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // 15 segundos son 300 ticks (20 ticks por segundo)
|
|
88
|
+
* const ticks = worldToolsSimplified.convertSecondsToTicks(15); // 300
|
|
89
|
+
* ```
|
|
26
90
|
*/
|
|
27
91
|
convertSecondsToTicks(seconds: number): number;
|
|
28
92
|
/**
|
|
@@ -31,6 +95,11 @@ declare class WorldToolsSimplified {
|
|
|
31
95
|
* @param {number} ticks Los ticks a convertir.
|
|
32
96
|
* @returns {number} Los segundos convertidos.
|
|
33
97
|
* @author HaJuegos - 12-03-2026
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* // 300 ticks son 15 segundos (20 ticks por segundo)
|
|
101
|
+
* const seconds = worldToolsSimplified.convertTicksToSeconds(300); // 15
|
|
102
|
+
* ```
|
|
34
103
|
*/
|
|
35
104
|
convertTicksToSeconds(ticks: number): number;
|
|
36
105
|
}
|
|
@@ -10,11 +10,84 @@ class WorldToolsSimplified {
|
|
|
10
10
|
* @constructor
|
|
11
11
|
*/
|
|
12
12
|
constructor() { }
|
|
13
|
+
/**
|
|
14
|
+
* Metodo auxiliar que establece una serie de eventos con un pequeño retraso determinado. Luego de terminar el retraso, elimina la tarea para no dejarlo en memoria.
|
|
15
|
+
* @param {() => void} callback Los eventos en cuestion a ejecutar.
|
|
16
|
+
* @param {number} ticksDelay Los tiempos en ticks que se tardara para ejecutarse.
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
* @author HaJuegos - 13-03-2026
|
|
19
|
+
* @async Es un metodo asincrono, debido a que se limpia despues de la ejecucion.
|
|
20
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
21
|
+
* @public
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* worldToolsSimplified.setDelay(() => {
|
|
25
|
+
* console.warn('Este evento se ejecutara despues de 5 segundos');
|
|
26
|
+
* } worldToolsSimplified.convertSecondsToTicks(5))
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
async setDelay(callback, ticksDelay) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
const currentJob = mc.system.runTimeout(() => {
|
|
32
|
+
callback();
|
|
33
|
+
mc.system.clearRun(currentJob);
|
|
34
|
+
resolve();
|
|
35
|
+
}, ticksDelay);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
;
|
|
39
|
+
/**
|
|
40
|
+
* Metodo auxiliar que establece una serie de eventos en concreto que se mantendran en loop.
|
|
41
|
+
* @param {() => void} callback Los eventos en concreto.
|
|
42
|
+
* @param {number} loopTicks El numero en ticks que se repetira este loop.
|
|
43
|
+
* @returns {number} Devuelve el ID de la memoria, del proceso loop creado.
|
|
44
|
+
* @author HaJuegos - 13-03-2026
|
|
45
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
46
|
+
* @public
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* worldToolsSimplified.setLoop(() => {
|
|
50
|
+
* console.warn('Este evento se ejecutara cada 1 segundo');
|
|
51
|
+
* } worldToolsSimplified.convertSecondsToTicks(1))
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
setLoop(callback, loopTicks) {
|
|
55
|
+
return mc.system.runInterval(callback, loopTicks);
|
|
56
|
+
}
|
|
57
|
+
;
|
|
58
|
+
/**
|
|
59
|
+
* Metodo auxiliar que detiene un proceso looping creado previamente por medio de su ID generado en memoria.
|
|
60
|
+
* @param {number} runID ID del proceso generado.
|
|
61
|
+
* @author HaJuegos - 13-03-2026
|
|
62
|
+
* @systemEvent Este metodo usa los eventos system donde posiblemente puede ser beforeEvent, permitiendo la ejecucion antes de que pase.
|
|
63
|
+
* @public
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* // Se crea el evento primero, generado su ID en memoria.
|
|
67
|
+
* const idLoop = worldToolsSimplified.setLoop(() => {
|
|
68
|
+
* console.warn('este evento se esta repitiendo cada 1 segundo');
|
|
69
|
+
* } worldToolsSimplified.convertSecondsToTicks(1))
|
|
70
|
+
*
|
|
71
|
+
* // Con el ID generado en memoria, lo usamos para detenerlo cuando queramos.
|
|
72
|
+
* worldToolsSimplified.stopLoop(idLoop);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
stopLoop(runID) {
|
|
76
|
+
mc.system.clearRun(runID);
|
|
77
|
+
}
|
|
13
78
|
/**
|
|
14
79
|
* Metodo auxiliar que envia un mensaje global al mundo en formato string o rawmessage.
|
|
15
80
|
* @public
|
|
16
81
|
* @param {(string | mc.RawMessage)} message Mensaje o RawMessage en concreto a enviar.
|
|
17
82
|
* @author HaJuegos - 12-03-2026
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* // Este es un mensaje simple
|
|
86
|
+
* worldToolsSimplified.sendMessageGlobal('hola soy un mensaje');
|
|
87
|
+
*
|
|
88
|
+
* // Este es un mensaje RawText
|
|
89
|
+
* worldToolsSimplified.sendMessageGlobal({ rawtext: 'chat.test.message' });
|
|
90
|
+
* ```
|
|
18
91
|
*/
|
|
19
92
|
sendMessageGlobal(message) {
|
|
20
93
|
mc.world.sendMessage(message);
|
|
@@ -25,6 +98,11 @@ class WorldToolsSimplified {
|
|
|
25
98
|
* @param {number} seconds Los segundos a convertir.
|
|
26
99
|
* @returns {number} Los ticks convertidos.
|
|
27
100
|
* @author HaJuegos - 12-03-2026
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* // 15 segundos son 300 ticks (20 ticks por segundo)
|
|
104
|
+
* const ticks = worldToolsSimplified.convertSecondsToTicks(15); // 300
|
|
105
|
+
* ```
|
|
28
106
|
*/
|
|
29
107
|
convertSecondsToTicks(seconds) {
|
|
30
108
|
return mc.TicksPerSecond * seconds;
|
|
@@ -35,6 +113,11 @@ class WorldToolsSimplified {
|
|
|
35
113
|
* @param {number} ticks Los ticks a convertir.
|
|
36
114
|
* @returns {number} Los segundos convertidos.
|
|
37
115
|
* @author HaJuegos - 12-03-2026
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* // 300 ticks son 15 segundos (20 ticks por segundo)
|
|
119
|
+
* const seconds = worldToolsSimplified.convertTicksToSeconds(300); // 15
|
|
120
|
+
* ```
|
|
38
121
|
*/
|
|
39
122
|
convertTicksToSeconds(ticks) {
|
|
40
123
|
return ticks / mc.TicksPerSecond;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simplified-mojang-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "About Public repository to simplify the event logic of Mojang's Script API, for informal or professional use",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,22 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/HaJuegos/simplified-mojang-API#readme",
|
|
16
16
|
"files": [
|
|
17
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"structures"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "tsc",
|
|
21
22
|
"prepare": "npm run build"
|
|
22
23
|
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@minecraft/debug-utilities": "^1.0.0-beta.1.26.0-stable",
|
|
25
|
-
"@minecraft/gameplay-utilities": "^1.3.0",
|
|
26
|
-
"@minecraft/server": "^2.6.0-beta.1.26.0-stable",
|
|
27
|
-
"@minecraft/server-gametest": "^1.0.0-beta.1.26.0-stable",
|
|
28
|
-
"@minecraft/server-graphics": "^1.0.0-beta.1.26.0-stable",
|
|
29
|
-
"@minecraft/server-net": "^1.0.0-beta.1.26.0-stable",
|
|
30
|
-
"@minecraft/server-ui": "^2.1.0-beta.1.26.0-stable",
|
|
31
|
-
"@minecraft/vanilla-data": "^1.26.2"
|
|
32
|
-
},
|
|
33
24
|
"author": "HaJuegos",
|
|
34
25
|
"license": "MIT",
|
|
35
26
|
"keywords": [
|
|
@@ -43,15 +34,19 @@
|
|
|
43
34
|
"mojang"
|
|
44
35
|
],
|
|
45
36
|
"devDependencies": {
|
|
46
|
-
"@minecraft/debug-utilities": "^1.0.0-beta.1.26.0-stable",
|
|
47
|
-
"@minecraft/gameplay-utilities": "^1.3.0",
|
|
48
|
-
"@minecraft/server": "^2.6.0-beta.1.26.0-stable",
|
|
49
|
-
"@minecraft/server-gametest": "^1.0.0-beta.1.26.0-stable",
|
|
50
|
-
"@minecraft/server-graphics": "^1.0.0-beta.1.26.0-stable",
|
|
51
|
-
"@minecraft/server-net": "^1.0.0-beta.1.26.0-stable",
|
|
52
|
-
"@minecraft/server-ui": "^2.1.0-beta.1.26.0-stable",
|
|
53
|
-
"@minecraft/vanilla-data": "^1.26.2",
|
|
54
37
|
"@types/node": "^25.4.0",
|
|
38
|
+
"esbuild": "^0.27.3",
|
|
39
|
+
"nodemon": "^3.1.14",
|
|
55
40
|
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@minecraft/debug-utilities": "1.0.0-beta.1.26.0-stable",
|
|
44
|
+
"@minecraft/gameplay-utilities": "1.3.0",
|
|
45
|
+
"@minecraft/server": "2.6.0-beta.1.26.0-stable",
|
|
46
|
+
"@minecraft/server-gametest": "1.0.0-beta.1.26.0-stable",
|
|
47
|
+
"@minecraft/server-graphics": "1.0.0-beta.1.26.0-stable",
|
|
48
|
+
"@minecraft/server-net": "1.0.0-beta.1.26.0-stable",
|
|
49
|
+
"@minecraft/server-ui": "2.1.0-beta.1.26.0-stable",
|
|
50
|
+
"@minecraft/vanilla-data": "1.26.2"
|
|
56
51
|
}
|
|
57
52
|
}
|
|
Binary file
|