Skip to content

Commit fecf536

Browse files
committed
Clean up code
1 parent 1d4225d commit fecf536

29 files changed

+613
-1122
lines changed

.eslintrc.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
module.exports = {
2-
"extends": [
3-
"eslint:recommended",
4-
"plugin:prettier/recommended"
5-
],
6-
"env": {
7-
"browser": true,
8-
"es6": true,
9-
"node": true,
10-
"jquery":true
11-
},
12-
"parserOptions": {
13-
"ecmaVersion": 8,
14-
"sourceType": "module",
15-
},
16-
"rules":{
17-
"no-empty": ["error", { "allowEmptyCatch": true }]
18-
},
19-
"globals": {
20-
"PRODUCTION": true
21-
}
22-
};
2+
extends: ["eslint:recommended", "plugin:prettier/recommended"],
3+
env: {
4+
browser: true,
5+
es6: true,
6+
node: true,
7+
jquery: true,
8+
},
9+
parserOptions: {
10+
ecmaVersion: 8,
11+
sourceType: "module",
12+
},
13+
rules: {
14+
"no-empty": ["error", { allowEmptyCatch: true }],
15+
},
16+
globals: {
17+
PRODUCTION: true,
18+
},
19+
};

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"tabWidth": 4
3-
}
3+
}

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## About
88

9-
**Web-minecraft is minecraft client written in CoffeeScript.** From web browser this client connects to node.js server and then to real minecraft server, so you can play minecraft in the browser.
9+
**Web-minecraft is minecraft client written in Javascript.** From web browser this client connects to node.js server and then to real minecraft server, so you can play minecraft in the browser.
1010

1111
## Instructions
1212

@@ -73,15 +73,6 @@ npm start
7373

7474

7575

76-
<details>
77-
<summary>Browser support</summary>
78-
79-
It is preferred to run this game on [Google Chrome](https://www.google.pl/chrome/) (best performance), but it could work on other browsers.
80-
</details>
81-
82-
83-
84-
8576

8677
## Screenshots
8778
[<img src="https://i.ibb.co/bPh99MV/hypixel.png" alt="screen6" width="100%">](https://i.ibb.co/bPh99MV/hypixel.png)

package-lock.json

Lines changed: 21 additions & 148 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"jssoup": "0.0.12",
2727
"lodash-webpack-plugin": "^0.11.6",
2828
"mineflayer": "^3.0.0",
29-
"opn": "^6.0.0",
29+
"open": "^7.4.2",
3030
"popper.js": "^1.16.1",
3131
"prismarine-block": "^1.7.3",
3232
"prismarine-chunk": "^1.22.0",
@@ -42,7 +42,6 @@
4242
"worker-loader": "^3.0.7"
4343
},
4444
"devDependencies": {
45-
"@types/node": "^14.14.28",
4645
"autoprefixer": "^9.0.0",
4746
"copy-webpack-plugin": "^6.3.1",
4847
"css-loader": "^5.0.1",
@@ -56,7 +55,6 @@
5655
"prettier": "^2.2.1",
5756
"sass-loader": "^10.1.1",
5857
"style-loader": "^2.0.0",
59-
"ts-loader": "^8.0.17",
6058
"typescript": "^4.1.5",
6159
"webpack": "^5.9.0",
6260
"webpack-cli": "^4.2.0",

src/atlasCreator.js

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
var AtlasCreator, Canvas, fs, path;
1+
var path = require("path");
22

3-
path = require("path");
3+
var fs = require("fs");
44

5-
fs = require("fs");
5+
var Canvas = require("canvas");
66

7-
Canvas = require("canvas");
8-
9-
AtlasCreator = class AtlasCreator {
7+
var AtlasCreator = class AtlasCreator {
108
constructor(options) {
119
this.pref = options.pref;
1210
this.oneFrame = options.oneFrame;
@@ -36,11 +34,9 @@ AtlasCreator = class AtlasCreator {
3634
}
3735

3836
firstLoad() {
39-
var _this;
40-
_this = this;
37+
var _this = this;
4138
fs.readdir(this.loadPath, function (err, files) {
42-
var totalImages;
43-
totalImages = 0;
39+
var totalImages = 0;
4440
files.forEach(function (file) {
4541
if (path.extname(file) === ".png") {
4642
totalImages += 1;
@@ -59,9 +55,8 @@ AtlasCreator = class AtlasCreator {
5955
}
6056

6157
addImageToLoad(filePath, name) {
62-
var _this, img;
63-
_this = this;
64-
img = new Canvas.Image();
58+
var _this = this;
59+
var img = new Canvas.Image();
6560
img.onload = function () {
6661
_this.images[name] = img;
6762
_this.loadedImages++;
@@ -73,8 +68,7 @@ AtlasCreator = class AtlasCreator {
7368
}
7469

7570
forEachToxel() {
76-
var _this;
77-
_this = this;
71+
var _this = this;
7872
Object.keys(this.images).forEach(function (name) {
7973
var img;
8074
img = _this.images[name];
@@ -84,9 +78,8 @@ AtlasCreator = class AtlasCreator {
8478
}
8579

8680
addToxelToAtlas(img, name) {
87-
var h, i, j, k, l, ref, ref1, w;
88-
w = img.width / this.toxelSize;
89-
h = img.height / this.toxelSize;
81+
var w = img.width / this.toxelSize;
82+
var h = img.height / this.toxelSize;
9083
if (this.oneFrame) {
9184
this.ctx.drawImage(
9285
img,
@@ -106,20 +99,12 @@ AtlasCreator = class AtlasCreator {
10699
this.moveToxel();
107100
} else {
108101
if (w > 1 || h > 1) {
109-
for (
110-
i = k = 0, ref = w - 1;
111-
0 <= ref ? k <= ref : k >= ref;
112-
i = 0 <= ref ? ++k : --k
113-
) {
114-
for (
115-
j = l = 0, ref1 = h - 1;
116-
0 <= ref1 ? l <= ref1 : l >= ref1;
117-
j = 0 <= ref1 ? ++l : --l
118-
) {
102+
for (let _i = 0; _i < w; _i++) {
103+
for (let _j = 0; _j < h; _j++) {
119104
this.ctx.drawImage(
120105
img,
121-
i * this.toxelSize,
122-
j * this.toxelSize,
106+
_i * this.toxelSize,
107+
_j * this.toxelSize,
123108
this.toxelSize,
124109
this.toxelSize,
125110
(this.toxelX - 1) * this.toxelSize,
@@ -128,7 +113,7 @@ AtlasCreator = class AtlasCreator {
128113
this.toxelSize
129114
);
130115
this.textureMapping[
131-
`${name.substr(0, name.length - 4)}@${i}@${j}`
116+
`${name.substr(0, name.length - 4)}@${_i}@${_j}`
132117
] = {
133118
x: this.toxelX,
134119
y: this.toxelY,

0 commit comments

Comments
 (0)