simplified-mojang-api 0.0.19 → 0.0.21
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.
|
@@ -11,6 +11,11 @@ declare class AfterEventsSimplified {
|
|
|
11
11
|
private chatSendManager;
|
|
12
12
|
private itemUseManager;
|
|
13
13
|
private explosionManager;
|
|
14
|
+
private onProjectileHitEntityManager;
|
|
15
|
+
private onProjectileHitBlockManager;
|
|
16
|
+
private onHitEntityManager;
|
|
17
|
+
private onEntityHurtManager;
|
|
18
|
+
private onHealthEntityChangeManager;
|
|
14
19
|
/**
|
|
15
20
|
* Eventos que se inicializan cuando la clase es llamada o inicializada.
|
|
16
21
|
* @constructor
|
|
@@ -104,6 +109,90 @@ declare class AfterEventsSimplified {
|
|
|
104
109
|
* ```
|
|
105
110
|
*/
|
|
106
111
|
onExplodes(callback: (args: mc.ExplosionAfterEvent) => void): void;
|
|
112
|
+
/**
|
|
113
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un proyectil golpea una entidad de forma simplificada.
|
|
114
|
+
* @param {(args: mc.ProjectileHitEntityAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
115
|
+
* @author HaJuegos - 18-03-2026
|
|
116
|
+
* @public
|
|
117
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* afterEventsSimplified.onProjectileHitEntity((args) => {
|
|
121
|
+
* const sourceEntity = args.source;
|
|
122
|
+
* const hitEntity = args.getEntityHit().entity;
|
|
123
|
+
*
|
|
124
|
+
* console.warn(`${source?.typeId} ha golpeado a ${hitEntity.typeId}.`);
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
onProjectileHitEntity(callback: (args: mc.ProjectileHitEntityAfterEvent) => void): void;
|
|
129
|
+
/**
|
|
130
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un proyectil golpea un bloque de forma simplificada.
|
|
131
|
+
* @param {(args: mc.ProjectileHitBlockAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
132
|
+
* @author HaJuegos - 18-03-2026
|
|
133
|
+
* @public
|
|
134
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* afterEventsSimplified.onProjectileHitBlock((args) => {
|
|
138
|
+
* const sourceEntity = args.source;
|
|
139
|
+
* const hitBlock = args.getBlockHit().entity;
|
|
140
|
+
*
|
|
141
|
+
* console.warn(`${source.typeId} ha golpeado al bloque ${hitBlock.typeId}.`);
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
onProjectileHitBlock(callback: (args: mc.ProjectileHitBlockAfterEvent) => void): void;
|
|
146
|
+
/**
|
|
147
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se golpea una entidad de forma simplificada.
|
|
148
|
+
* @param {(args: mc.EntityHitEntityAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
149
|
+
* @author HaJuegos - 18-03-2026
|
|
150
|
+
* @public
|
|
151
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* afterEventsSimplified.onHitEntity((args) => {
|
|
155
|
+
* const sourceEntity = args.damagingEntity;
|
|
156
|
+
* const hitEntity = args.hitEntity;
|
|
157
|
+
*
|
|
158
|
+
* console.warn(`${sourceEntity.typeId} ha golpeado a ${hitEntity.typeId}`);
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
onHitEntity(callback: (args: mc.EntityHitEntityAfterEvent) => void): void;
|
|
163
|
+
/**
|
|
164
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se lastima una entidad de forma simplificada.
|
|
165
|
+
* @param {(args: mc.EntityHurtAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
166
|
+
* @author HaJuegos - 18-03-2026
|
|
167
|
+
* @public
|
|
168
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* afterEventsSimplified.onHurtEntity((args) => {
|
|
172
|
+
* const source = args.damageSource;
|
|
173
|
+
* const sourceEntity = source.damagingEntity;
|
|
174
|
+
* const cause = source.cause;
|
|
175
|
+
* const hitEntity = args.hurtEntity;
|
|
176
|
+
*
|
|
177
|
+
* console.warn(`${sourceEntity.typeId} ha lastimado a ${hitEntity.typeId} mediante ${cause}`);
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
onHurtEntity(callback: (args: mc.EntityHurtAfterEvent) => void): void;
|
|
182
|
+
/**
|
|
183
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando la vida de una entidad cambia de forma simplificada.
|
|
184
|
+
* @param {(args: mc.EntityHealthChangedAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
185
|
+
* @author HaJuegos - 19-03-2026
|
|
186
|
+
* @public
|
|
187
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* afterEventsSimplified.onHealthEntityChange((args) => {
|
|
191
|
+
* console.warn(`${args.entity.typeId} tenia ${args.oldValue} de vida y ahora tiene ${args.newValue}.`);
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
onHealthEntityChange(callback: (args: mc.EntityHealthChangedAfterEvent) => void): void;
|
|
107
196
|
}
|
|
108
197
|
export declare const afterEventsSimplified: AfterEventsSimplified;
|
|
109
198
|
export {};
|
|
@@ -17,6 +17,11 @@ class AfterEventsSimplified {
|
|
|
17
17
|
this.chatSendManager = new BaseEventManager(mc.world.afterEvents.chatSend, "AfterChatSend");
|
|
18
18
|
this.itemUseManager = new BaseEventManager(mc.world.afterEvents.itemUse, "AfterItemUse");
|
|
19
19
|
this.explosionManager = new BaseEventManager(mc.world.afterEvents.explosion, "AfterExplodes");
|
|
20
|
+
this.onProjectileHitEntityManager = new BaseEventManager(mc.world.afterEvents.projectileHitEntity, "AfterProyectileHitEntity");
|
|
21
|
+
this.onProjectileHitBlockManager = new BaseEventManager(mc.world.afterEvents.projectileHitBlock, "AfterProyectileHitBlock");
|
|
22
|
+
this.onHitEntityManager = new BaseEventManager(mc.world.afterEvents.entityHitEntity, "AfterHitEntity");
|
|
23
|
+
this.onEntityHurtManager = new BaseEventManager(mc.world.afterEvents.entityHurt, "AfterHurtEntity");
|
|
24
|
+
this.onHealthEntityChangeManager = new BaseEventManager(mc.world.afterEvents.entityHealthChanged, "AfterHealthChangeEntity");
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Metodo auxiliar que ejecuta los eventos relacionado cuando una entidad muere de forma simplificada.
|
|
@@ -118,5 +123,99 @@ class AfterEventsSimplified {
|
|
|
118
123
|
onExplodes(callback) {
|
|
119
124
|
this.explosionManager.register(callback);
|
|
120
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un proyectil golpea una entidad de forma simplificada.
|
|
128
|
+
* @param {(args: mc.ProjectileHitEntityAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
129
|
+
* @author HaJuegos - 18-03-2026
|
|
130
|
+
* @public
|
|
131
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* afterEventsSimplified.onProjectileHitEntity((args) => {
|
|
135
|
+
* const sourceEntity = args.source;
|
|
136
|
+
* const hitEntity = args.getEntityHit().entity;
|
|
137
|
+
*
|
|
138
|
+
* console.warn(`${source?.typeId} ha golpeado a ${hitEntity.typeId}.`);
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
onProjectileHitEntity(callback) {
|
|
143
|
+
this.onProjectileHitEntityManager.register(callback);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un proyectil golpea un bloque de forma simplificada.
|
|
147
|
+
* @param {(args: mc.ProjectileHitBlockAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
148
|
+
* @author HaJuegos - 18-03-2026
|
|
149
|
+
* @public
|
|
150
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* afterEventsSimplified.onProjectileHitBlock((args) => {
|
|
154
|
+
* const sourceEntity = args.source;
|
|
155
|
+
* const hitBlock = args.getBlockHit().entity;
|
|
156
|
+
*
|
|
157
|
+
* console.warn(`${source.typeId} ha golpeado al bloque ${hitBlock.typeId}.`);
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
onProjectileHitBlock(callback) {
|
|
162
|
+
this.onProjectileHitBlockManager.register(callback);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se golpea una entidad de forma simplificada.
|
|
166
|
+
* @param {(args: mc.EntityHitEntityAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
167
|
+
* @author HaJuegos - 18-03-2026
|
|
168
|
+
* @public
|
|
169
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* afterEventsSimplified.onHitEntity((args) => {
|
|
173
|
+
* const sourceEntity = args.damagingEntity;
|
|
174
|
+
* const hitEntity = args.hitEntity;
|
|
175
|
+
*
|
|
176
|
+
* console.warn(`${sourceEntity.typeId} ha golpeado a ${hitEntity.typeId}`);
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
onHitEntity(callback) {
|
|
181
|
+
this.onHitEntityManager.register(callback);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se lastima una entidad de forma simplificada.
|
|
185
|
+
* @param {(args: mc.EntityHurtAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
186
|
+
* @author HaJuegos - 18-03-2026
|
|
187
|
+
* @public
|
|
188
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* afterEventsSimplified.onHurtEntity((args) => {
|
|
192
|
+
* const source = args.damageSource;
|
|
193
|
+
* const sourceEntity = source.damagingEntity;
|
|
194
|
+
* const cause = source.cause;
|
|
195
|
+
* const hitEntity = args.hurtEntity;
|
|
196
|
+
*
|
|
197
|
+
* console.warn(`${sourceEntity.typeId} ha lastimado a ${hitEntity.typeId} mediante ${cause}`);
|
|
198
|
+
* });
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
onHurtEntity(callback) {
|
|
202
|
+
this.onEntityHurtManager.register(callback);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando la vida de una entidad cambia de forma simplificada.
|
|
206
|
+
* @param {(args: mc.EntityHealthChangedAfterEvent) => void} callback Los eventos relacionados a ejecutar.
|
|
207
|
+
* @author HaJuegos - 19-03-2026
|
|
208
|
+
* @public
|
|
209
|
+
* @afterEvent Metodo que detecta el evento despues de que suceda. Obteniendo la informacion sin permitir modificarla en su mayoria.
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* afterEventsSimplified.onHealthEntityChange((args) => {
|
|
213
|
+
* console.warn(`${args.entity.typeId} tenia ${args.oldValue} de vida y ahora tiene ${args.newValue}.`);
|
|
214
|
+
* });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
onHealthEntityChange(callback) {
|
|
218
|
+
this.onHealthEntityChangeManager.register(callback);
|
|
219
|
+
}
|
|
121
220
|
}
|
|
122
221
|
export const afterEventsSimplified = new AfterEventsSimplified();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as mc from '@minecraft/server';
|
|
2
|
+
import * as vanilla from '@minecraft/vanilla-data';
|
|
2
3
|
/**
|
|
3
4
|
* Clase que contiene todos los metodos de mecanicas universales usadas en sus add-ons.
|
|
4
5
|
* @author HaJuegos - 15-03-2026
|
|
@@ -14,7 +15,6 @@ declare class CustomEventsSimplified {
|
|
|
14
15
|
* @param {(mc.ItemStack[] | string[])} listOfItems La lista de items a validar para este sistema.
|
|
15
16
|
* @author HaJuegos - 15-03-2026
|
|
16
17
|
* @public
|
|
17
|
-
* @beforeEvent Metodo que detecta el evento antes de que suceda. Permitiendo cancelar o personalizar el evento antes de que se vea en el juego.
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
20
|
* customEventsManager.fastItemsSystem(['totem']); // Ahora el totem es conciderado un fast item para cambiar a la mano secundaria con un click.
|
|
@@ -25,16 +25,45 @@ declare class CustomEventsSimplified {
|
|
|
25
25
|
* Metodo auxiliar que simplifica la logica de reducir o dañar items manualmente, esto principalmente se creo para los custom components para la interaccion de items o bloques. Por ej: Para reducir un item a 24 manzanas para pasar a ser 23 manzanas. O dañar un poco un casco de diamante bajando su durabilidad.
|
|
26
26
|
* @param {mc.Player} ply Jugador en cuestion a quien es afectado.
|
|
27
27
|
* @param {mc.ItemStack} item Item en cuestion a eliminar o dañar.
|
|
28
|
-
* @param {mc.Container} invPly Inventario del jugador en cuestion.
|
|
29
28
|
* @author HaJuegos - 17-03-2026
|
|
30
29
|
* @public
|
|
31
30
|
* @example
|
|
32
31
|
* ```ts
|
|
33
32
|
* // Esto hara que un item reduzca su stock o sino, sea dañado bajando su durabilidad.
|
|
34
|
-
* customEventsManager.manualDamageItem(player, item
|
|
33
|
+
* customEventsManager.manualDamageItem(player, item);
|
|
35
34
|
* ```
|
|
36
35
|
*/
|
|
37
|
-
manualDamageItem(ply: mc.Player, item: mc.ItemStack
|
|
36
|
+
manualDamageItem(ply: mc.Player, item: mc.ItemStack): void;
|
|
37
|
+
/**
|
|
38
|
+
* Metodo auxiliar que simplifica la logica de detectar en el inventario del jugador, si tiene uno o varios items en concreto.
|
|
39
|
+
* @param {mc.Player} plySource Jugador en cuestion.
|
|
40
|
+
* @param {(string | string[] | vanilla.MinecraftItemTypes | vanilla.MinecraftItemTypes[] )} itemsToDetect Item o items a buscar.
|
|
41
|
+
* @returns {boolean} Devuelve true en caso de tener ese item, sino, sera false.
|
|
42
|
+
* @author HaJuegos - 18-03-2026
|
|
43
|
+
* @public
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // Esto es true si el jugador tiene un item en su inventario.
|
|
47
|
+
* customEventsManager.plyHasItems(player, vanilla.MinecraftItemTypes.TotemOfUndying);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
plyHasItems(plySource: mc.Player, itemsToDetect: string | string[] | vanilla.MinecraftItemTypes | vanilla.MinecraftItemTypes[]): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Metodo auxiliar que simplifica loa logica al detectar el uso de un totem en un jugaodor, ejecutando los eventos relacionados.
|
|
53
|
+
* @param {(ply: mc.Player) => void} callback Los eventos relacionados a ejecutar.
|
|
54
|
+
* @author HaJuegos - 19-03-2026
|
|
55
|
+
* @public
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* // Este evento solo se va a ejecutar cuando un jugador usa un totem.
|
|
59
|
+
* customEventsManager.playerUseTotemSystem((args) => {
|
|
60
|
+
* const ply = args.player;
|
|
61
|
+
*
|
|
62
|
+
* console.warn(`${ply.name} ha usado un totem.`);
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
onPlayerUseTotem(callback: (player: mc.Player) => void): void;
|
|
38
67
|
}
|
|
39
68
|
export declare const customEventsManager: CustomEventsSimplified;
|
|
40
69
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as mc from '@minecraft/server';
|
|
2
2
|
import { beforeEventsSimplified } from './beforeEventsSimplifiedManager';
|
|
3
3
|
import { worldToolsSimplified } from './worldToolsSimplifiedManager';
|
|
4
|
+
import { afterEventsSimplified } from './afterEventsSimplifiedManager';
|
|
4
5
|
/**
|
|
5
6
|
* Clase que contiene todos los metodos de mecanicas universales usadas en sus add-ons.
|
|
6
7
|
* @author HaJuegos - 15-03-2026
|
|
@@ -17,7 +18,6 @@ class CustomEventsSimplified {
|
|
|
17
18
|
* @param {(mc.ItemStack[] | string[])} listOfItems La lista de items a validar para este sistema.
|
|
18
19
|
* @author HaJuegos - 15-03-2026
|
|
19
20
|
* @public
|
|
20
|
-
* @beforeEvent Metodo que detecta el evento antes de que suceda. Permitiendo cancelar o personalizar el evento antes de que se vea en el juego.
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
23
|
* customEventsManager.fastItemsSystem(['totem']); // Ahora el totem es conciderado un fast item para cambiar a la mano secundaria con un click.
|
|
@@ -60,16 +60,16 @@ class CustomEventsSimplified {
|
|
|
60
60
|
* Metodo auxiliar que simplifica la logica de reducir o dañar items manualmente, esto principalmente se creo para los custom components para la interaccion de items o bloques. Por ej: Para reducir un item a 24 manzanas para pasar a ser 23 manzanas. O dañar un poco un casco de diamante bajando su durabilidad.
|
|
61
61
|
* @param {mc.Player} ply Jugador en cuestion a quien es afectado.
|
|
62
62
|
* @param {mc.ItemStack} item Item en cuestion a eliminar o dañar.
|
|
63
|
-
* @param {mc.Container} invPly Inventario del jugador en cuestion.
|
|
64
63
|
* @author HaJuegos - 17-03-2026
|
|
65
64
|
* @public
|
|
66
65
|
* @example
|
|
67
66
|
* ```ts
|
|
68
67
|
* // Esto hara que un item reduzca su stock o sino, sea dañado bajando su durabilidad.
|
|
69
|
-
* customEventsManager.manualDamageItem(player, item
|
|
68
|
+
* customEventsManager.manualDamageItem(player, item);
|
|
70
69
|
* ```
|
|
71
70
|
*/
|
|
72
|
-
manualDamageItem(ply, item
|
|
71
|
+
manualDamageItem(ply, item) {
|
|
72
|
+
const invPly = ply.getComponent(mc.EntityComponentTypes.Inventory)?.container;
|
|
73
73
|
const slot = ply.selectedSlotIndex;
|
|
74
74
|
const newItem = item.clone();
|
|
75
75
|
if (!item.isStackable) {
|
|
@@ -93,5 +93,72 @@ class CustomEventsSimplified {
|
|
|
93
93
|
invPly.setItem(slot, newItem);
|
|
94
94
|
}
|
|
95
95
|
;
|
|
96
|
+
/**
|
|
97
|
+
* Metodo auxiliar que simplifica la logica de detectar en el inventario del jugador, si tiene uno o varios items en concreto.
|
|
98
|
+
* @param {mc.Player} plySource Jugador en cuestion.
|
|
99
|
+
* @param {(string | string[] | vanilla.MinecraftItemTypes | vanilla.MinecraftItemTypes[] )} itemsToDetect Item o items a buscar.
|
|
100
|
+
* @returns {boolean} Devuelve true en caso de tener ese item, sino, sera false.
|
|
101
|
+
* @author HaJuegos - 18-03-2026
|
|
102
|
+
* @public
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* // Esto es true si el jugador tiene un item en su inventario.
|
|
106
|
+
* customEventsManager.plyHasItems(player, vanilla.MinecraftItemTypes.TotemOfUndying);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
plyHasItems(plySource, itemsToDetect) {
|
|
110
|
+
const invPly = plySource.getComponent(mc.EntityComponentTypes.Inventory)?.container;
|
|
111
|
+
const armorPly = plySource.getComponent(mc.EntityComponentTypes.Equippable);
|
|
112
|
+
const targetItems = Array.isArray(itemsToDetect) ? itemsToDetect : [itemsToDetect];
|
|
113
|
+
if (invPly) {
|
|
114
|
+
for (let i = 0; i < invPly.size; i++) {
|
|
115
|
+
const item = invPly.getItem(i);
|
|
116
|
+
if (item && targetItems.some((target) => item.typeId.includes(target))) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (armorPly) {
|
|
122
|
+
const equipmentSlots = [
|
|
123
|
+
mc.EquipmentSlot.Head,
|
|
124
|
+
mc.EquipmentSlot.Chest,
|
|
125
|
+
mc.EquipmentSlot.Legs,
|
|
126
|
+
mc.EquipmentSlot.Feet,
|
|
127
|
+
mc.EquipmentSlot.Offhand
|
|
128
|
+
];
|
|
129
|
+
for (const slot of equipmentSlots) {
|
|
130
|
+
const item = armorPly.getEquipment(slot);
|
|
131
|
+
if (item && targetItems.some((target) => item.typeId.includes(target))) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Metodo auxiliar que simplifica loa logica al detectar el uso de un totem en un jugaodor, ejecutando los eventos relacionados.
|
|
140
|
+
* @param {(ply: mc.Player) => void} callback Los eventos relacionados a ejecutar.
|
|
141
|
+
* @author HaJuegos - 19-03-2026
|
|
142
|
+
* @public
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* // Este evento solo se va a ejecutar cuando un jugador usa un totem.
|
|
146
|
+
* customEventsManager.playerUseTotemSystem((args) => {
|
|
147
|
+
* const ply = args.player;
|
|
148
|
+
*
|
|
149
|
+
* console.warn(`${ply.name} ha usado un totem.`);
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
onPlayerUseTotem(callback) {
|
|
154
|
+
afterEventsSimplified.onHealthEntityChange((args) => {
|
|
155
|
+
const entity = args.entity;
|
|
156
|
+
const newValue = args.newValue;
|
|
157
|
+
const oldValue = args.oldValue;
|
|
158
|
+
if (entity instanceof mc.Player && oldValue <= 0 && newValue >= 1) {
|
|
159
|
+
callback(entity);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
96
163
|
}
|
|
97
164
|
export const customEventsManager = new CustomEventsSimplified();
|
package/package.json
CHANGED