simplified-mojang-api 0.0.11 → 0.0.13
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.
|
@@ -39,6 +39,17 @@ declare class DebugToolsSimplified {
|
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
41
|
stopHitboxes(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Metodo que altera el estado de activo o desactivado del watchDogTerminate, en caso de lag spikes con scripts, para permitir el cierre o no del mundo o servidor cuando pase. Esto es solo recomendable usarlo en testeos, no se recomienda desactivarlo en mundos/servidores casuales o normales.
|
|
44
|
+
* @param {boolean} turnOn El estado proximo a cambiar.
|
|
45
|
+
* @author HaJuegos - 14-03-2026
|
|
46
|
+
* @public
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* debugToolsSimplified.watchDogState(false) // ya no habra cierre por lag spikes o problemas con scripts
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
watchDogState(turnOn: boolean): void;
|
|
42
53
|
}
|
|
43
54
|
export declare const debugToolsSimplified: DebugToolsSimplified;
|
|
44
55
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as mc from '@minecraft/server';
|
|
1
2
|
import * as debug from '@minecraft/debug-utilities';
|
|
2
3
|
import { worldToolsSimplified } from './worldToolsSimplifiedManager';
|
|
3
4
|
/**
|
|
@@ -25,7 +26,7 @@ class DebugToolsSimplified {
|
|
|
25
26
|
*/
|
|
26
27
|
showHitboxes(ply, maxRadiusHitboxs = 50) {
|
|
27
28
|
const activeBoxes = new Map();
|
|
28
|
-
|
|
29
|
+
worldToolsSimplified.setLoop(() => {
|
|
29
30
|
const nearbyMobs = ply.dimension.getEntities({
|
|
30
31
|
location: ply.location,
|
|
31
32
|
maxDistance: maxRadiusHitboxs
|
|
@@ -38,24 +39,48 @@ class DebugToolsSimplified {
|
|
|
38
39
|
box.scale = 1;
|
|
39
40
|
box.color = { red: 255, green: 255, blue: 255 };
|
|
40
41
|
box.visibleTo = [ply];
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const isPlayer = mob.typeId == 'minecraft:player';
|
|
43
|
+
if (isPlayer) {
|
|
44
|
+
box.setLocation({
|
|
45
|
+
x: mob.location.x - bb.extent.x,
|
|
46
|
+
y: bb.center.y - bb.extent.y,
|
|
47
|
+
z: mob.location.z - bb.extent.z
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
box.attachedTo = mob;
|
|
52
|
+
box.setLocation({ x: -bb.extent.x, y: 0, z: -bb.extent.z });
|
|
53
|
+
}
|
|
43
54
|
debug.debugDrawer.addShape(box, ply.dimension);
|
|
44
55
|
activeBoxes.set(mob, box);
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
for (const [mob, box] of activeBoxes) {
|
|
59
|
+
if (!mob.isValid) {
|
|
60
|
+
box.remove();
|
|
61
|
+
activeBoxes.delete(mob);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
48
64
|
const dx = mob.location.x - ply.location.x;
|
|
49
65
|
const dy = mob.location.y - ply.location.y;
|
|
50
66
|
const dz = mob.location.z - ply.location.z;
|
|
51
|
-
if (
|
|
67
|
+
if (Math.sqrt(dx * dx + dy * dy + dz * dz) > maxRadiusHitboxs) {
|
|
52
68
|
box.remove();
|
|
53
69
|
activeBoxes.delete(mob);
|
|
54
70
|
continue;
|
|
55
71
|
}
|
|
56
72
|
const bb = mob.getAABB();
|
|
57
73
|
box.bound = { x: bb.extent.x * 2, y: bb.extent.y * 2, z: bb.extent.z * 2 };
|
|
58
|
-
|
|
74
|
+
if (mob.typeId == 'minecraft:player') {
|
|
75
|
+
box.setLocation({
|
|
76
|
+
x: mob.location.x - bb.extent.x,
|
|
77
|
+
y: bb.center.y - bb.extent.y,
|
|
78
|
+
z: mob.location.z - bb.extent.z
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
box.setLocation({ x: -bb.extent.x, y: 0, z: -bb.extent.z });
|
|
83
|
+
}
|
|
59
84
|
}
|
|
60
85
|
}, 1);
|
|
61
86
|
}
|
|
@@ -75,5 +100,20 @@ class DebugToolsSimplified {
|
|
|
75
100
|
}
|
|
76
101
|
debug.debugDrawer.removeAll();
|
|
77
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Metodo que altera el estado de activo o desactivado del watchDogTerminate, en caso de lag spikes con scripts, para permitir el cierre o no del mundo o servidor cuando pase. Esto es solo recomendable usarlo en testeos, no se recomienda desactivarlo en mundos/servidores casuales o normales.
|
|
105
|
+
* @param {boolean} turnOn El estado proximo a cambiar.
|
|
106
|
+
* @author HaJuegos - 14-03-2026
|
|
107
|
+
* @public
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* debugToolsSimplified.watchDogState(false) // ya no habra cierre por lag spikes o problemas con scripts
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
watchDogState(turnOn) {
|
|
114
|
+
mc.system.beforeEvents.watchdogTerminate.subscribe((arg) => {
|
|
115
|
+
arg.cancel = turnOn;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
78
118
|
}
|
|
79
119
|
export const debugToolsSimplified = new DebugToolsSimplified();
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export * from "./core/eventsManager";
|
|
|
2
2
|
export * from "./events/afterEventsSimplifiedManager";
|
|
3
3
|
export * from "./events/beforeEventsSimplifiedManager";
|
|
4
4
|
export * from "./events/worldToolsSimplifiedManager";
|
|
5
|
+
export * from "./events/debugToolsSimplified";
|
|
6
|
+
export * from "./events/fakePlysManagerSimplififed";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
// base
|
|
1
2
|
export * from "./core/eventsManager";
|
|
3
|
+
// @minecraft/server events
|
|
2
4
|
export * from "./events/afterEventsSimplifiedManager";
|
|
3
5
|
export * from "./events/beforeEventsSimplifiedManager";
|
|
4
6
|
export * from "./events/worldToolsSimplifiedManager";
|
|
7
|
+
// @minecraft/debug events
|
|
8
|
+
export * from "./events/debugToolsSimplified";
|
|
9
|
+
// @minecraft/gametest events
|
|
10
|
+
export * from "./events/fakePlysManagerSimplififed";
|
package/package.json
CHANGED