Skip to content

Commit 3377ec3

Browse files
committed
update development setup
1 parent 85f541e commit 3377ec3

File tree

7 files changed

+34
-67
lines changed

7 files changed

+34
-67
lines changed

.gitpod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tasks:
2+
- command: npm install

.gitpod.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,24 @@
55
[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/michaljaz/web-minecraft)
66
## About
77

8-
**Web-minecraft is minecraft client written in Javascript.** From web browser this client connects to proxy that translates Websocket connection to TCP and then to real minecraft server (https://github.com/michaljaz/web-minecraft-proxy), so you can play minecraft in the browser. <br>
8+
**Web-minecraft is minecraft client written in Javascript.** From web browser this client connects to proxy(https://github.com/michaljaz/web-minecraft-proxy) that translates Websocket connection to TCP and then to real minecraft server, so you can play minecraft in the browser. Web-minecraft now only supports minecraft 1.16.5.
9+
10+
## Demo
911
Live demo with no installation: https://michaljaz.github.io/web-minecraft.
1012

11-
## Setup
13+
## Development setup
1214

1315
```bash
14-
#Install node modules
15-
npm i
16-
17-
#Building app bundle
18-
npm run build
1916

20-
#Start node server and serve bundle files
17+
npm install
2118
npm start
22-
2319
```
20+
This will start express and webpack in development mode: whenever you save a file, the build will be redone (it takes 2s), and you can refresh the page to get the new result.
2421

25-
</details>
22+
Connect to http://localhost:8080 in your browser. Also specify correct server(1.16.5) ip in url param.
2623

27-
## Screenshots
2824

29-
[<img src="https://i.ibb.co/bPh99MV/hypixel.png" alt="screen6" width="100%">](https://i.ibb.co/bPh99MV/hypixel.png)
30-
[<img src="https://i.ibb.co/jzZVrT2/Screenshot-from-2021-01-27-21-13-37.png" alt="screen6" width="100%">](https://i.ibb.co/jzZVrT2/Screenshot-from-2021-01-27-21-13-37.png)
31-
[<img src="https://i.ibb.co/tKmnJ8D/Screenshot-from-2021-01-27-21-16-12.png" alt="screen6" width="100%">](https://i.ibb.co/tKmnJ8D/Screenshot-from-2021-01-27-21-16-12.png)
25+
## Screenshots
26+
![hypixel](https://i.ibb.co/bPh99MV/hypixel.png "hypixel")
27+
![nether](https://i.ibb.co/jzZVrT2/Screenshot-from-2021-01-27-21-13-37.png "nether")
28+
![end](https://i.ibb.co/tKmnJ8D/Screenshot-from-2021-01-27-21-16-12.png "end")

index.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,16 @@ const compression = require('compression')
55
const port = process.env.PORT || 8080
66
const netApi = require('@misioxd/net-browserify')
77
const path = require('path')
8+
const webpack = require('webpack')
9+
const middleware = require('webpack-dev-middleware')
10+
const devconfig = require('./src/webpack.dev.js')
11+
const compiler = webpack(devconfig)
812

9-
app.use(
10-
helmet({
11-
contentSecurityPolicy: false
12-
})
13-
)
14-
app.use(netApi({ allowOrigin: '*' }))
13+
app.use(helmet({ contentSecurityPolicy: false }))
1514
app.use(compression())
15+
app.use(netApi({ allowOrigin: '*' }))
16+
app.use(middleware(compiler))
1617

17-
const mode = process.argv[2]
18-
if (mode === 'production') {
19-
app.use(express.static(path.join(__dirname, 'src/dist')))
20-
} else if (mode === 'development') {
21-
const webpack = require('webpack')
22-
const middleware = require('webpack-dev-middleware')
23-
const devconfig = require('./src/webpack.dev.js')
24-
const compiler = webpack(devconfig)
25-
app.use(middleware(compiler))
26-
} else {
27-
console.log('Incorrect mode!')
28-
}
2918
app.listen(port, function () {
3019
return console.log(`Server is running on \x1b[34m*:${port}\x1b[0m`)
3120
})

lib/atlasCreator.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const path = require('path')
2-
32
const fs = require('fs')
4-
53
const Canvas = require('canvas')
64

75
const AtlasCreator = class AtlasCreator {
@@ -148,19 +146,10 @@ const AtlasCreator = class AtlasCreator {
148146
`${this.buildPath}/${this.pref}-Atlas.png`,
149147
this.canvas.toBuffer('image/png')
150148
)
151-
console.log(
152-
`\x1b[33mFull atlas: ${this.buildPath}/${this.pref}-Atlas.png`
153-
)
154-
fs.writeFileSync(
155-
`${this.buildPath}/${this.pref}-Mapping.json`,
156-
JSON.stringify(this.textureMapping, null, 2)
157-
)
158-
console.log(
159-
`\x1b[33mFull atlas mapping: ${this.buildPath}/${this.pref}-Mapping.json`
160-
)
161-
console.log(
162-
`\x1b[32mSuccessfully generated ${this.canvas.width}x${this.canvas.height} Texture Atlas!\n\x1b[0m`
163-
)
149+
console.log(`\x1b[33mFull atlas: ${this.buildPath}/${this.pref}-Atlas.png`)
150+
fs.writeFileSync(`${this.buildPath}/${this.pref}-Mapping.json`, JSON.stringify(this.textureMapping, null, 2))
151+
console.log(`\x1b[33mFull atlas mapping: ${this.buildPath}/${this.pref}-Mapping.json`)
152+
console.log(`\x1b[32mSuccessfully generated ${this.canvas.width}x${this.canvas.height} Texture Atlas!\n\x1b[0m`)
164153
}
165154
}
166155

lib/postinstall.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
const decompress = require('decompress')
2+
const decompressTarxz = require('decompress-tarxz')
23
const path = require('path')
34

45
decompress(
56
path.join(__dirname, '../assets/pack.zip'),
67
path.join(__dirname, '../assets/pack')
7-
).then(() => {
8-
console.log('done!')
9-
})
10-
const decompressTarxz = require('decompress-tarxz');
8+
)
119

12-
(async () => {
13-
await decompress(
14-
path.join(__dirname, '../assets/mineflayer.tar.xz'),
15-
path.join(__dirname, '../src/assets'),
16-
{
17-
plugins: [decompressTarxz()]
18-
}
19-
)
20-
21-
console.log('Files decompressed')
22-
})()
10+
decompress(
11+
path.join(__dirname, '../assets/mineflayer.tar.xz'),
12+
path.join(__dirname, '../src/assets'),
13+
{
14+
plugins: [decompressTarxz()]
15+
}
16+
)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"version": "1.0.0",
44
"description": "Minecraft client written in Javascript",
55
"scripts": {
6-
"start": "node index.js production",
7-
"dev": "npm run prebuild && node index.js development",
6+
"start": "npm run prebuild && node index.js",
87
"build": "npm run clean && cd src && webpack --config webpack.prod.js",
98
"prebuild": "node lib/prebuild.js",
109
"clean": "rimraf src/dist/*",

0 commit comments

Comments
 (0)