-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathEyeLevel.js
More file actions
33 lines (28 loc) · 1.12 KB
/
Copy pathEyeLevel.js
File metadata and controls
33 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { DebugDisplayShapeElement } from "./DebugDisplayShapeElement";
import { Vector } from "../../../lib/Vector";
import { DebugBox } from "@minecraft/debug-utilities";
export class EyeLevel extends DebugDisplayShapeElement {
eyeLevel;
createShapes() {
const eyeLevelData = this.getEyeLevelBoxBounds();
const dimensionLocation = { ...eyeLevelData.location, dimension: this.entity.dimension };
const eyeLevel = new DebugBox(dimensionLocation);
eyeLevel.bound = eyeLevelData.size;
eyeLevel.color = { red: 1, green: 0, blue: 0 };
this.drawShape(eyeLevel);
}
update() {
const eyeLevelData = this.getEyeLevelBoxBounds();
this.shapes[0].bound = eyeLevelData.size;
}
getEyeLevelBoxBounds() {
const AABB = this.entity.getAABB();
return {
location: new Vector(-AABB.extent.x, this.entity.getHeadLocation().y - this.entity.location.y, -AABB.extent.z),
size: new Vector(AABB.extent.x * 2, 0, AABB.extent.z * 2)
}
}
getClientSideLocation() {
return this.getEyeLevelBoxBounds().location;
}
}