Skip to content

Commit 124c9d5

Browse files
committed
Development and Production servers
1 parent 232fe79 commit 124c9d5

File tree

6 files changed

+46
-37
lines changed

6 files changed

+46
-37
lines changed

src/client/scripts/AssetLoader.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as THREE from "three";
2-
import {FBXLoader} from "three/examples/jsm/loaders/FBXLoader.js";
2+
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
33

44
class AssetLoader {
55
constructor() {
@@ -20,12 +20,10 @@ class AssetLoader {
2020
var assetsLoaded = 0;
2121

2222
for (const assetName in assets) {
23-
if (!assets.hasOwnProperty(assetName))
24-
continue;
23+
if (!assets.hasOwnProperty(assetName)) continue;
2524

2625
let asset = assets[assetName];
2726

28-
2927
switch (asset.type) {
3028
case "texture":
3129
textureLoader.load(asset.path, (texture) => {
@@ -46,7 +44,7 @@ class AssetLoader {
4644
});
4745
break;
4846
case "image":
49-
let img = new Image();
47+
var img = new Image();
5048
img.onload = () => {
5149
this.assets.set(assetName, img);
5250
assetsLoaded++;
@@ -67,13 +65,12 @@ class AssetLoader {
6765
break;
6866
}
6967
}
70-
})
71-
68+
});
7269
}
7370

7471
get(assetName) {
7572
return this.assets.get(assetName);
7673
}
7774
}
7875

79-
export {AssetLoader};
76+
export { AssetLoader };

src/client/scripts/EventHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class EventHandler {
5353
if (z.code === "Enter" && this.gameState === "chat") {
5454
this.game.chat.command($(".com_i").val());
5555
$(".com_i").val("");
56-
this.setState("game")
56+
this.setState("game");
5757
}
5858
if (
5959
z.code === "KeyE" &&

src/client/scripts/Setup.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import TWEEN from "@tweenjs/tween.js";
33
import Stats from "stats-js";
44
import * as dat from "dat.gui";
55
import io from "socket.io-client";
6-
import {DistanceBasedFog} from "./DistanceBasedFog.js";
7-
import {UrlParams} from "./UrlParams.js";
8-
import {gpuInfo} from "./gpuInfo.js";
9-
import {World} from "./World/World.js";
10-
import {InventoryBar} from "./InventoryBar.js";
11-
import {Chat} from "./Chat.js";
12-
import {Entities} from "./Entities.js";
13-
import {PlayerInInventory} from "./PlayerInInventory.js";
14-
import {BlockBreak} from "./BlockBreak.js";
15-
import {BlockPlace} from "./BlockPlace.js";
16-
import {EventHandler} from "./EventHandler.js";
6+
import { DistanceBasedFog } from "./DistanceBasedFog.js";
7+
import { UrlParams } from "./UrlParams.js";
8+
import { gpuInfo } from "./gpuInfo.js";
9+
import { World } from "./World/World.js";
10+
import { InventoryBar } from "./InventoryBar.js";
11+
import { Chat } from "./Chat.js";
12+
import { Entities } from "./Entities.js";
13+
import { PlayerInInventory } from "./PlayerInInventory.js";
14+
import { BlockBreak } from "./BlockBreak.js";
15+
import { BlockPlace } from "./BlockPlace.js";
16+
import { EventHandler } from "./EventHandler.js";
1717

18-
async function Setup(game, cb) {
18+
async function Setup(game) {
1919
return new Promise((resolve) => {
2020
game.canvas = document.querySelector("#c");
2121
game.pcanvas = document.querySelector("#c_player");
@@ -25,7 +25,12 @@ async function Setup(game, cb) {
2525
});
2626
game.renderer.sortObjects = true;
2727
game.scene = new THREE.Scene();
28-
game.camera = new THREE.PerspectiveCamera(game.fov.normal, 2, 0.1, 1000);
28+
game.camera = new THREE.PerspectiveCamera(
29+
game.fov.normal,
30+
2,
31+
0.1,
32+
1000
33+
);
2934
game.camera.rotation.order = "YXZ";
3035
game.camera.position.set(26, 26, 26);
3136
game.scene.add(new THREE.AmbientLight(0xdddddd));
@@ -62,7 +67,9 @@ async function Setup(game, cb) {
6267
};
6368
game.distanceBasedFog.farnear.x = (game.params.chunkdist - 1) * 16;
6469
game.distanceBasedFog.farnear.y = game.params.chunkdist * 16;
65-
gui.add(game.world.material, "wireframe").name("Wireframe").listen();
70+
gui.add(game.world.material, "wireframe")
71+
.name("Wireframe")
72+
.listen();
6673
var chunkDist = gui
6774
.add(game.params, "chunkdist", 0, 10, 1)
6875
.name("Render distance")
@@ -85,7 +92,7 @@ async function Setup(game, cb) {
8592
};
8693
resolve();
8794
});
88-
})
95+
});
8996
}
9097

91-
export {Setup};
98+
export { Setup };

src/client/scripts/UrlParams.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,15 @@ var UrlParams = function (game, cb) {
190190
}
191191
if (game.server === "" || game.server === null) {
192192
reload = true;
193-
game.server = "185.228.139.97";
193+
game.server = game.production
194+
? game.servers.production[0]
195+
: game.servers.development[0];
194196
}
195197
if (game.serverPort === "" || game.serverPort === null) {
196198
reload = true;
197-
game.serverPort = "25564";
199+
game.serverPort = game.production
200+
? game.servers.production[1]
201+
: game.servers.development[1];
198202
}
199203
if (game.premium === "" || game.premium === null) {
200204
reload = true;

src/client/scripts/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import * as THREE from "three";
22
import TWEEN from "@tweenjs/tween.js";
33
import swal from "sweetalert";
4-
import {AssetLoader} from "./AssetLoader.js";
5-
import {Setup} from "./Setup.js";
4+
import { AssetLoader } from "./AssetLoader.js";
5+
import { Setup } from "./Setup.js";
66

77
class Game {
88
constructor() {
9-
10-
if (PRODUCTION) {
9+
this.production = PRODUCTION;
10+
if (this.production) {
1111
console.log("Running in production mode");
1212
} else {
1313
console.log("Running in development mode");
1414
}
15+
this.servers = {
16+
production: ["185.228.139.97", "25564"],
17+
development: ["localhost", "25565"],
18+
};
1519
this.fov = {
1620
normal: 70,
1721
sprint: 80,
@@ -30,8 +34,6 @@ class Game {
3034
};
3135
this.headHeight = 17;
3236
this.gamemode = null;
33-
34-
3537
}
3638

3739
async init() {
@@ -192,4 +194,4 @@ class Game {
192194
window.onload = () => {
193195
let game = new Game();
194196
game.init();
195-
}
197+
};

src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ io.sockets.on("connection", function (socket) {
7676
socket.emit("kicked", reason);
7777
});
7878
bot.on("message", function (msg) {
79-
let message = msg.toAnsi()
79+
let message = msg.toAnsi();
8080

8181
const replacements = [
8282
[/&/g, "&"],
@@ -180,8 +180,7 @@ io.sockets.on("connection", function (socket) {
180180
clearInterval(interval);
181181
console.log(`[\x1b[31m-\x1b[0m] ${query.nick}`);
182182
bot.end();
183-
} catch (error) {
184-
}
183+
} catch (error) {}
185184
});
186185
socket.on("dig", function (pos) {
187186
var block = bot.blockAt(vec3(pos[0], pos[1] - 16, pos[2]));

0 commit comments

Comments
 (0)