Skip to content

Commit 9033b13

Browse files
committed
remove premium (not working with proxy)
1 parent 9c84695 commit 9033b13

File tree

9 files changed

+139
-156
lines changed

9 files changed

+139
-156
lines changed

assets/mineflayer.tar.xz

96 Bytes
Binary file not shown.

src/scripts/EventHandler.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ class EventHandler {
3535
this.game.inv_bar.setFocus(focus)
3636
}
3737
})
38+
const playerUpdateHeight = () => {
39+
const to = {
40+
x: this.game.playerPos[0],
41+
y: this.game.playerPos[1] + this.game.headHeight,
42+
z: this.game.playerPos[2]
43+
}
44+
new TWEEN.Tween(this.game.camera.position)
45+
.to(to, 100)
46+
.easing(TWEEN.Easing.Quadratic.Out)
47+
.start()
48+
}
3849
$(document).on('keydown', (z) => {
3950
this.keys[z.code] = true
4051
for (let i = 1; i < 10; i++) {
@@ -123,7 +134,7 @@ class EventHandler {
123134

124135
case 'sneak':
125136
this.game.headHeight = 16.7
126-
this.game.playerImpulse()
137+
playerUpdateHeight()
127138
break
128139
}
129140
}
@@ -151,7 +162,7 @@ class EventHandler {
151162

152163
case 'sneak':
153164
this.game.headHeight = 17
154-
this.game.playerImpulse()
165+
playerUpdateHeight()
155166
break
156167
}
157168
}

src/scripts/Setup.js

Lines changed: 63 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { WebGLRenderer, Scene, PerspectiveCamera, AmbientLight } from 'three'
2-
import { TWEEN } from 'three/examples/jsm/libs/tween.module.min.js'
31
import Stats from 'three/examples/jsm/libs/stats.module.js'
42
import * as dat from 'three/examples/jsm/libs/dat.gui.module.js'
3+
import { WebGLRenderer, Scene, PerspectiveCamera, AmbientLight } from 'three'
54
import { DistanceBasedFog } from './rendering/DistanceBasedFog.js'
65
import { UrlParams } from './UrlParams.js'
76
import { gpuInfo } from './additional/gpuInfo.js'
@@ -15,85 +14,70 @@ import { BlockPlace } from './rendering/BlockPlace.js'
1514
import { EventHandler } from './EventHandler.js'
1615
import { Socket } from './proxy/Socket.js'
1716
import { TabList } from './gui/TabList.js'
18-
import $ from 'jquery'
17+
import { LoadingScreen } from './gui/LoadingScreen.js'
1918

20-
async function Setup (game) {
21-
return new Promise((resolve) => {
22-
game.canvas = document.querySelector('#c')
23-
game.pcanvas = document.querySelector('#c_player')
24-
game.renderer = new WebGLRenderer({
25-
canvas: game.canvas,
26-
PixelRatio: window.devicePixelRatio
27-
})
28-
game.renderer.sortObjects = true
29-
game.scene = new Scene()
30-
game.camera = new PerspectiveCamera(game.fov.normal, 2, 0.1, 1000)
31-
game.camera.rotation.order = 'YXZ'
32-
game.camera.position.set(26, 26, 26)
33-
game.scene.add(new AmbientLight(0xdddddd))
34-
if (!game.production) {
35-
game.stats = new Stats()
36-
game.drawcalls = game.stats.addPanel(
37-
new Stats.Panel('calls', '#ff8', '#221')
38-
)
39-
game.stats.showPanel(0)
40-
document.body.appendChild(game.stats.dom)
41-
}
42-
game.distanceBasedFog = new DistanceBasedFog(game)
43-
game.servers = {
44-
production: game.al.get('config').minecraftProduction,
45-
development: game.al.get('config').minecraftDevelopment
46-
}
47-
UrlParams(game).then((password) => {
48-
game.password = password
49-
$('.loadingText').text(`Connecting to ${game.server}...`)
50-
console.warn(gpuInfo())
51-
game.socket = new Socket(game)
52-
game.pii = new PlayerInInventory(game)
53-
game.bb = new BlockBreak(game)
54-
game.bp = new BlockPlace(game)
55-
game.world = new World(game)
56-
game.ent = new Entities(game)
57-
game.chat = new Chat(game)
58-
game.inv_bar = new InventoryBar(game)
59-
game.tl = new TabList(game)
60-
game.distanceBasedFog.addShaderToMaterial(game.world.material)
61-
game.distanceBasedFog.addShaderToMaterial(game.ent.mobMaterial)
62-
game.distanceBasedFog.addShaderToMaterial(game.ent.playerMaterial)
63-
game.distanceBasedFog.addShaderToMaterial(game.ent.objectMaterial)
64-
const gui = new dat.GUI()
65-
game.params = {
66-
chunkdist: 4
67-
}
68-
game.distanceBasedFog.farnear.x = (game.params.chunkdist - 2) * 16
69-
game.distanceBasedFog.farnear.y = (game.params.chunkdist - 1) * 16
70-
gui.add(game.world.material, 'wireframe')
71-
.name('Wireframe')
72-
.listen()
73-
const chunkDist = gui
74-
.add(game.params, 'chunkdist', 2, 10, 1)
75-
.name('Render distance')
76-
.listen()
77-
chunkDist.onChange(function (val) {
78-
game.distanceBasedFog.farnear.x = (val - 2) * 16
79-
game.distanceBasedFog.farnear.y = (val - 1) * 16
80-
console.log(val)
81-
})
82-
game.playerImpulse = function () {
83-
const to = {
84-
x: game.playerPos[0],
85-
y: game.playerPos[1] + game.headHeight,
86-
z: game.playerPos[2]
87-
}
88-
new TWEEN.Tween(game.camera.position)
89-
.to(to, 100)
90-
.easing(TWEEN.Easing.Quadratic.Out)
91-
.start()
92-
}
93-
game.eh = new EventHandler(game)
94-
resolve()
95-
})
19+
function Setup (game) {
20+
game.canvas = document.querySelector('#c')
21+
game.pcanvas = document.querySelector('#c_player')
22+
game.renderer = new WebGLRenderer({
23+
canvas: game.canvas,
24+
PixelRatio: window.devicePixelRatio
9625
})
26+
game.renderer.sortObjects = true
27+
game.scene = new Scene()
28+
game.camera = new PerspectiveCamera(game.fov.normal, 2, 0.1, 1000)
29+
game.camera.rotation.order = 'YXZ'
30+
game.camera.position.set(26, 26, 26)
31+
game.scene.add(new AmbientLight(0xdddddd))
32+
if (!game.production) {
33+
game.stats = new Stats()
34+
game.drawcalls = game.stats.addPanel(
35+
new Stats.Panel('calls', '#ff8', '#221')
36+
)
37+
game.stats.showPanel(0)
38+
document.body.appendChild(game.stats.dom)
39+
}
40+
game.distanceBasedFog = new DistanceBasedFog(game)
41+
game.servers = {
42+
production: game.al.get('config').minecraftProduction,
43+
development: game.al.get('config').minecraftDevelopment
44+
}
45+
UrlParams(game)
46+
console.warn(gpuInfo())
47+
game.socket = new Socket(game)
48+
game.pii = new PlayerInInventory(game)
49+
game.bb = new BlockBreak(game)
50+
game.bp = new BlockPlace(game)
51+
game.world = new World(game)
52+
game.ent = new Entities(game)
53+
game.chat = new Chat(game)
54+
game.inv_bar = new InventoryBar(game)
55+
game.tl = new TabList(game)
56+
game.ls = new LoadingScreen(game)
57+
game.ls.show(`Connecting to ${game.server}...`)
58+
game.distanceBasedFog.addShaderToMaterials([
59+
game.world.material,
60+
game.ent.mobMaterial,
61+
game.ent.playerMaterial,
62+
game.ent.objectMaterial
63+
])
64+
const gui = new dat.GUI()
65+
game.params = {
66+
chunkdist: 4
67+
}
68+
game.distanceBasedFog.farnear.x = (game.params.chunkdist - 2) * 16
69+
game.distanceBasedFog.farnear.y = (game.params.chunkdist - 1) * 16
70+
gui.add(game.world.material, 'wireframe').name('Wireframe').listen()
71+
gui
72+
.add(game.params, 'chunkdist', 2, 10, 1)
73+
.name('Render distance')
74+
.onChange(function (val) {
75+
game.distanceBasedFog.farnear.x = (val - 2) * 16
76+
game.distanceBasedFog.farnear.y = (val - 1) * 16
77+
console.log(val)
78+
})
79+
.listen()
80+
game.eh = new EventHandler(game)
9781
}
9882

9983
export { Setup }

src/scripts/UrlParams.js

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,33 @@
1-
import swal from 'sweetalert'
2-
31
function UrlParams (game) {
4-
return new Promise((resolve) => {
5-
const nameList = game.al.get('nameList').split('\n')
6-
const finalName = nameList[Math.floor(Math.random() * nameList.length)]
7-
game.nick = new URL(document.location).searchParams.get('nick')
8-
game.server = new URL(document.location).searchParams.get('server')
9-
game.premium = new URL(document.location).searchParams.get('premium')
10-
game.proxy = new URL(document.location).searchParams.get('proxy')
11-
let reload = false
12-
if (game.nick === '' || game.nick === null) {
13-
reload = true
14-
game.nick = finalName
15-
}
16-
if (game.server === '' || game.server === null) {
17-
reload = true
18-
game.server = game.production ? game.servers.production : game.servers.development
19-
}
20-
if (game.premium === '' || game.premium === null) {
21-
reload = true
22-
game.premium = 'false'
23-
}
24-
if (game.proxy === '' || game.proxy === null) {
25-
reload = true
26-
if (game.production) {
27-
if (document.location.protocol === 'https:') {
28-
game.proxy = game.al.get('config').proxyHTTPS
29-
} else {
30-
game.proxy = game.al.get('config').proxyHTTP
31-
}
2+
const nameList = game.al.get('nameList').split('\n')
3+
const finalName = nameList[Math.floor(Math.random() * nameList.length)]
4+
game.nick = new URL(document.location).searchParams.get('nick')
5+
game.server = new URL(document.location).searchParams.get('server')
6+
game.proxy = new URL(document.location).searchParams.get('proxy')
7+
let reload = false
8+
if (game.nick === '' || game.nick === null) {
9+
reload = true
10+
game.nick = finalName
11+
}
12+
if (game.server === '' || game.server === null) {
13+
reload = true
14+
game.server = game.production ? game.servers.production : game.servers.development
15+
}
16+
if (game.proxy === '' || game.proxy === null) {
17+
reload = true
18+
if (game.production) {
19+
if (document.location.protocol === 'https:') {
20+
game.proxy = game.al.get('config').proxyHTTPS
3221
} else {
33-
game.proxy = 'local'
22+
game.proxy = game.al.get('config').proxyHTTP
3423
}
35-
}
36-
if (reload) {
37-
document.location.href = `?server=${game.server}&nick=${game.nick}&premium=${game.premium}&proxy=${game.proxy}`
3824
} else {
39-
if (game.premium === 'true') {
40-
swal({
41-
text: 'Enter password for premium account',
42-
content: 'input',
43-
button: {
44-
text: 'Login'
45-
}
46-
}).then((password) => {
47-
resolve(password)
48-
})
49-
} else {
50-
resolve(null)
51-
}
25+
game.proxy = 'local'
5226
}
53-
})
27+
}
28+
if (reload) {
29+
document.location.href = `?server=${game.server}&nick=${game.nick}&proxy=${game.proxy}`
30+
}
5431
}
5532

5633
export { UrlParams }

src/scripts/gui/LoadingScreen.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import $ from 'jquery'
2+
3+
class LoadingScreen {
4+
constructor (game) {
5+
this.game = game
6+
}
7+
8+
show (text) {
9+
$('.loadingText').text(text)
10+
$('.initLoading').css('display', 'block')
11+
}
12+
13+
hide () {
14+
$('.initLoading').css('display', 'none')
15+
}
16+
}
17+
18+
export { LoadingScreen }

src/scripts/index.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { TWEEN } from 'three/examples/jsm/libs/tween.module.min.js'
33
import swal from 'sweetalert'
44
import { AssetLoader } from './AssetLoader.js'
55
import { Setup } from './Setup.js'
6-
import $ from 'jquery'
76

87
class Game {
98
constructor () {
@@ -36,13 +35,13 @@ class Game {
3635

3736
async init () {
3837
await this.al.init()
39-
await Setup(this)
38+
Setup(this)
4039
this.socket.on('blockUpdate', (block) => {
4140
this.world.setBlock(block[0], block[1] + 16, block[2], block[3])
4241
})
4342
this.socket.on('spawn', (yaw, pitch) => {
4443
console.log('Player spawned')
45-
$('.initLoading').css('display', 'none')
44+
this.ls.hide()
4645
this.camera.rotation.y = yaw
4746
this.camera.rotation.x = pitch
4847
})
@@ -62,8 +61,8 @@ class Game {
6261
this.distanceBasedFog.color.y = bg[1]
6362
this.distanceBasedFog.color.z = bg[2]
6463
this.distanceBasedFog.color.w = 1
65-
$('.initLoading').css('display', 'block')
66-
$('.loadingText').html('Loading terrain...')
64+
65+
this.ls.show('Loading terrain...')
6766
})
6867
this.socket.on('mapChunk', (sections, biomes, x, z) => {
6968
this.world.computeSections(sections, biomes, x, z)
@@ -127,13 +126,9 @@ class Game {
127126
}
128127

129128
animate () {
130-
if (this.stats) {
131-
this.stats.begin()
132-
this.render()
133-
this.stats.end()
134-
} else {
135-
this.render()
136-
}
129+
this.stats.begin()
130+
this.render()
131+
this.stats.end()
137132
window.requestAnimationFrame(() => {
138133
this.animate()
139134
})
@@ -158,15 +153,15 @@ class Game {
158153
}
159154
})
160155
this.world.updateChunksAroundPlayer(this.params.chunkdist)
156+
this.inv_bar.updateItems()
157+
this.distanceBasedFog.update()
161158
TWEEN.update()
162159
if (!this.production) {
163160
this.drawcalls.update(this.renderer.info.render.calls, 100)
164161
}
165162
if (this.eh.gameState === 'inventory') {
166163
this.pii.render()
167164
}
168-
this.inv_bar.updateItems()
169-
this.distanceBasedFog.update()
170165
this.renderer.render(this.scene, this.camera)
171166
}
172167
}

src/scripts/proxy/Socket.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class Socket {
2626
port,
2727
nick: this.game.nick,
2828
server: server[0],
29-
serverPort: server[1],
30-
password: this.game.password
29+
serverPort: server[1]
3130
})
3231
this.worker.onmessage = (msg) => {
3332
const type = msg.data.type

0 commit comments

Comments
 (0)