Skip to content

Commit 1b8c7e6

Browse files
committed
some inventoryBar fixes
1 parent 0eea97c commit 1b8c7e6

File tree

5 files changed

+227
-217
lines changed

5 files changed

+227
-217
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.watcherExclude": {
3+
"**/.git/objects/**": true,
4+
"**/node_modules/**": true
5+
}
6+
}

src/client/scripts/InventoryBar.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ class InventoryBar {
1414
}
1515
}
1616

17-
setGamemode(gamemode) {
17+
updateGamemode(gamemode) {
1818
// mineflayer doesn't currently include support for spectator mode
1919
if (gamemode === "creative") {
2020
$(
2121
(gamemode === "spectator" ? ".inv_bar, .inv_cursor" : "") +
22-
".player_hp, .player_food, .xp_bar_empty, xp_bar"
22+
".player_hp, .player_food, .xp_bar_empty, .xp_bar, .player_xp"
2323
).css("display", "none");
2424
} else {
25-
$(".player_hp, .player_food, .xp_bar_empty, xp_bar").css(
26-
"display",
27-
"initial"
28-
);
25+
$(
26+
".player_hp, .player_food, .xp_bar_empty, .xp_bar, .player_xp"
27+
).css("display", "block");
2928
}
3029
}
3130

@@ -89,11 +88,11 @@ class InventoryBar {
8988

9089
setXp(level, progress) {
9190
if (level === 0) {
92-
$(".player_xp").hide();
91+
$(".player_xp").text("");
9392
} else {
94-
$(".player_xp").show();
9593
$(".player_xp").text(level);
9694
}
95+
9796
return $(".xp_bar").css("width", `${500 * progress}px`);
9897
}
9998

@@ -122,7 +121,7 @@ class InventoryBar {
122121
}
123122
}
124123

125-
update() {
124+
updateItems() {
126125
var list = $(".item");
127126
for (var i = 0; i < list.length; i++) {
128127
var url;

src/client/scripts/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Game {
1414
}
1515
this.fov = {
1616
normal: 70,
17-
sprint: 85,
17+
sprint: 80,
1818
};
1919
this.toxelSize = 27;
2020
this.dimension = null;
@@ -28,6 +28,7 @@ class Game {
2828
"minecraft:nether": [133 / 255, 40 / 255, 15 / 255],
2929
};
3030
this.headHeight = 17;
31+
this.gamemode = null;
3132

3233
Setup(this, () => {
3334
this.init();
@@ -38,7 +39,7 @@ class Game {
3839
init() {
3940
this.socket.on("connect", () => {
4041
console.log("Connected to server!");
41-
$(".loadingText").text("Joining server...");
42+
$(".loadingText").text(`Connecting to ${this.server}`);
4243
console.log(`User nick: ${this.nick}`);
4344
console.log(`Server ip: ${this.server}:${this.serverPort}`);
4445
this.socket.emit("initClient", {
@@ -72,7 +73,7 @@ class Game {
7273
this.world.computeSections(sections, x, z);
7374
});
7475
this.socket.on("game", (gameData) => {
75-
this.inv_bar.setGamemode(gameData.gameMode);
76+
this.inv_bar.updateGamemode(gameData.gameMode);
7677
});
7778
this.socket.on("hp", (points) => {
7879
this.inv_bar.setHp(points);
@@ -182,7 +183,7 @@ class Game {
182183
if (this.eh.gameState === "inventory") {
183184
this.pii.render();
184185
}
185-
this.inv_bar.update();
186+
this.inv_bar.updateItems();
186187
this.distanceBasedFog.update();
187188
this.renderer.render(this.scene, this.camera);
188189
}

0 commit comments

Comments
 (0)