Skip to content

Commit ac95464

Browse files
author
Picoseconds
committed
Remove XP, health and food bars when in creative mode
1 parent b28d84b commit ac95464

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/client/scripts/InventoryBar.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ var InventoryBar = class InventoryBar {
1414
}
1515
}
1616

17+
setGamemode(gamemode) {
18+
// mineflayer doesn't currently include support for spectator mode
19+
if (gamemode === "creative") {
20+
$((gamemode === "spectator" ? ".inv_bar, .inv_cursor" : "") + ".player_hp, .player_food, .xp_bar_empty, xp_bar").css("display", "none");
21+
} else {
22+
$(".player_hp, .player_food, .xp_bar_empty, xp_bar").css("display", "initial");
23+
}
24+
}
25+
1726
setHp(points) {
1827
var lista = {};
1928
for (let i = 1; i <= 10; i++) {

src/client/scripts/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class Game {
122122
this.socket.on("mapChunk", function (sections, x, z) {
123123
_this.world.computeSections(sections, x, z);
124124
});
125+
this.socket.on("game", function (gameData) {
126+
_this.inv_bar.setGamemode(gameData.gameMode);
127+
});
125128
this.socket.on("hp", function (points) {
126129
_this.inv_bar.setHp(points);
127130
});

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ io.sockets.on("connection", function (socket) {
9595
bot.on("diggingAborted", function (block) {
9696
socket.emit("diggingAborted", block);
9797
});
98+
bot.on("game", function () {
99+
socket.emit("game", bot.game);
100+
});
98101
var inv = "";
99102
var interval = setInterval(function () {
100103
var inv_new = JSON.stringify(bot.inventory.slots);

0 commit comments

Comments
 (0)