CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/lib/bossbar.js
Views: 789
1
const colors = ['pink', 'blue', 'red', 'green', 'yellow', 'purple', 'white']
2
const divisions = [0, 6, 10, 12, 20]
3
4
function loader (registry) {
5
const ChatMessage = require('prismarine-chat')(registry)
6
return class BossBar {
7
constructor (uuid, title, health, dividers, color, flags) {
8
this._entityUUID = uuid
9
this._title = ChatMessage.fromNotch(title)
10
this._health = health
11
this._dividers = divisions[dividers]
12
this._color = colors[color]
13
this._shouldDarkenSky = flags & 0x1
14
this._isDragonBar = flags & 0x2
15
this._createFog = flags & 0x4
16
}
17
18
set entityUUID (uuid) {
19
this._entityUUID = uuid
20
}
21
22
set title (title) {
23
this._title = ChatMessage.fromNotch(title)
24
}
25
26
set health (health) {
27
this._health = health
28
}
29
30
set dividers (dividers) {
31
this._dividers = divisions[dividers]
32
}
33
34
set color (color) {
35
this._color = colors[color]
36
}
37
38
set flags (flags) {
39
this._shouldDarkenSky = flags & 0x1
40
this._isDragonBar = flags & 0x2
41
this._createFog = flags & 0x4
42
}
43
44
get flags () {
45
return (this._shouldDarkenSky) | (this._isDragonBar << 1) | (this._createFog << 2)
46
}
47
48
set shouldDarkenSky (darkenSky) {
49
this._shouldDarkenSky = darkenSky
50
}
51
52
set isDragonBar (dragonBar) {
53
this._isDragonBar = dragonBar
54
}
55
56
get createFog () {
57
return this._createFog
58
}
59
60
set createFog (createFog) {
61
this._createFog = createFog
62
}
63
64
get entityUUID () {
65
return this._entityUUID
66
}
67
68
get title () {
69
return this._title
70
}
71
72
get health () {
73
return this._health
74
}
75
76
get dividers () {
77
return this._dividers
78
}
79
80
get color () {
81
return this._color
82
}
83
84
get shouldDarkenSky () {
85
return this._shouldDarkenSky
86
}
87
88
get isDragonBar () {
89
return this._isDragonBar
90
}
91
92
get shouldCreateFog () {
93
return this._createFog
94
}
95
}
96
}
97
98
module.exports = loader
99
100