Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

must release #106

Merged
merged 56 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7884b5c
three shake three.js (#94)
zardoy Mar 25, 2024
07491fd
feat: effects + system indicators in hud! (#95)
gguio Mar 26, 2024
1c45ded
fix page loadeding indicator showing sometimes
zardoy Mar 27, 2024
f2803b9
remove alias set
zardoy Apr 6, 2024
b89aab7
ci: text aliases
zardoy Apr 9, 2024
ac3448c
ci: set custom mcraft aliases for PRs! (#99)
zardoy Apr 9, 2024
0b15ac9
ci: improve aliases set
zardoy Apr 9, 2024
2a396d1
ci: disable next checkout as its not available in some repoes
zardoy Apr 9, 2024
bf655b0
ci: try sticky messages
zardoy Apr 11, 2024
be87a57
fix indicator not disappearing sometimes
zardoy Apr 11, 2024
df0bf14
ci: post deploy message on each deploy
zardoy Apr 11, 2024
4d74730
ci: fix pull url in the preview script
zardoy Apr 11, 2024
da44ad4
feat: allow to setup temporary options & commands overrides in QS tha…
zardoy Apr 14, 2024
889e652
fix: Make hideable vercel live feedback
zardoy Apr 14, 2024
aafdb64
outdated commit hints in ci!! (#101)
zardoy Apr 15, 2024
954169d
enable outdated deps check only on next
zardoy Apr 15, 2024
10662bc
feat: Add auto jump (disabled by default for PC & Gamepad users) (#100)
zardoy Apr 16, 2024
219f525
support for custom input keys / gamepad buttons (no ui yet)
zardoy Apr 16, 2024
f747ff1
feat: auto parkour mode! (implies auto-jump)
zardoy Apr 16, 2024
a2b23b6
fix setting name
zardoy Apr 16, 2024
930d972
feat: add jump button to new controls type
zardoy Apr 16, 2024
2cc524a
rewrite renderers to allow custom ones! worker -> mesher (#102)
zardoy Apr 16, 2024
53a6d78
feat: Add lighting support for < 1.12 with smooth lighting (#98)
zardoy Apr 16, 2024
19a5d03
fix: fix critical position audio play memory leak
zardoy Apr 16, 2024
7aeb13f
up autojump
zardoy Apr 16, 2024
9a8ff32
a few minor but important world renderer fixes & impr
zardoy Apr 17, 2024
dd3c331
fix: super critical performance fix for some blocks like snow/soul sand
zardoy Apr 17, 2024
17e13d3
add mc data types
zardoy Apr 17, 2024
d604ff1
a few important regression fixes
zardoy Apr 17, 2024
fd42c9c
fix test in ci
zardoy Apr 18, 2024
2d3ab6c
feat: Almost full entities rendering. Mobs are now rendered correctly
zardoy Apr 18, 2024
d47a92b
add new entity models
zardoy Apr 18, 2024
18b6661
fix some items rendering
zardoy Apr 18, 2024
b121cc3
fix regression for some sides rendering when connected to unsupported…
zardoy Apr 18, 2024
eba9fc2
fix: fix all known digging issues including fastdigging detection
zardoy Apr 18, 2024
1c78fd1
do the check earlier for message
zardoy Apr 18, 2024
4fb2de5
fix entities render & crash
zardoy Apr 19, 2024
0acaa65
big worlds refactor with more scalable api, which allows hmr workers
zardoy Apr 20, 2024
d17e1b2
make bundle smaller and debugger run faster
zardoy Apr 20, 2024
2303770
up pnpm lockfile
zardoy Apr 20, 2024
d35eb04
The packageManager field must be joke...
zardoy Apr 20, 2024
976f6ca
add mesher HMR!
zardoy Apr 20, 2024
2ca66d6
add devReload addition
zardoy Apr 20, 2024
bade195
fix eruda!
zardoy Apr 20, 2024
54b37c0
update test
zardoy Apr 20, 2024
18aba6e
feat: add in water blue fog
zardoy Apr 20, 2024
0886af9
feat: Migrate HUD to React, new hotbar and bars (#107)
zardoy Apr 20, 2024
7a28dfc
fix water fog
zardoy Apr 20, 2024
241e5d3
do not override pnpm ver
zardoy Apr 24, 2024
619aa5b
optimize light update in single chunks
zardoy Apr 24, 2024
d7f5e98
update typescript to 5.5
zardoy Apr 26, 2024
cf83844
fix annoying f3 issue
zardoy Apr 26, 2024
b9aa449
fix ios hotbar, fix item name display, fix item select, fix inv open
zardoy Apr 27, 2024
6615984
fix water rendering
zardoy Apr 27, 2024
a504d3f
disable some useless warnings
zardoy Apr 27, 2024
9322e09
fix: "modern" controls now correctly works with flying
zardoy Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@master
- name: Install pnpm
run: npm i -g pnpm
# todo this needs investigating fixing
run: npm i -g [email protected]
- uses: actions/setup-node@v4
with:
node-version: 18
# cache: "pnpm"
- run: pnpm install
- run: pnpm lint
- run: pnpm check-build
- run: pnpm test-unit
- run: pnpm lint
- run: nohup pnpm prod-start &
- run: nohup pnpm test-mc-server &
- uses: cypress-io/github-action@v5
Expand All @@ -24,3 +28,7 @@ jobs:
with:
name: cypress-images
path: cypress/integration/__image_snapshots__/
- run: node scripts/outdatedGitPackages.mjs
if: github.ref == 'refs/heads/next'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions .github/workflows/next-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Vercel Deploy Next
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
ALIASES: ${{ vars.ALIASES }}
on:
push:
branches:
Expand All @@ -15,7 +16,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Install Global Dependencies
run: npm install --global vercel pnpm
run: npm install --global vercel pnpm@9.0.4
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand All @@ -31,7 +32,7 @@ jobs:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
id: deploy
- name: Set deployment alias
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }}
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
# - uses: mshick/add-pr-comment@v2
# with:
# message: |
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Vercel Deploy Preview
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
ALIASES: ${{ vars.ALIASES }}
on:
issue_comment:
types: [created]
Expand All @@ -21,13 +22,13 @@ jobs:
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- run: npm i -g pnpm
- run: npm i -g pnpm@9.0.4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install Global Dependencies
run: npm install --global vercel pnpm
run: npm install --global vercel
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand All @@ -42,13 +43,20 @@ jobs:
with:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
id: deploy
- name: Set deployment alias
# only if on branch next
if: github.ref == 'refs/heads/next'
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }}
- uses: mshick/add-pr-comment@v2
with:
allow-repeats: true
message: |
Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }}
[Playground](${{ steps.deploy.outputs.stdout }}/playground.html)
[Storybook](${{ steps.deploy.outputs.stdout }}/storybook/)
# - run: git checkout next scripts/githubActions.mjs
- name: Get deployment alias
run: node scripts/githubActions.mjs getAlias
id: alias
env:
ALIASES: ${{ env.ALIASES }}
PULL_URL: ${{ github.event.issue.pull_request.url }}
- name: Set deployment alias
if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }}
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@master
- name: Install pnpm
run: npm i -g vercel pnpm
run: npm i -g vercel pnpm@9.0.4
# - run: pnpm install
# - run: pnpm build
- run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dist
.DS_Store
.idea/
world
data*.json
out
*.iml
.vercel
Expand Down
15 changes: 8 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

After forking the repository, run the following commands to get started:

0. Ensure you have [Node.js](https://nodejs.org) and `pnpm` installed. To install pnpm run `npm i -g pnpm`.
0. Ensure you have [Node.js](https://nodejs.org) and `pnpm` installed. To install pnpm run `npm i -g pnpm@9.0.4`.
1. Install dependencies: `pnpm i`
2. Start the project in development mode: `pnpm start`

Expand All @@ -27,16 +27,17 @@ You can get a description of packets for the latest protocol version from <https

Also there are [src/generatedClientPackets.ts](src/generatedClientPackets.ts) and [src/generatedServerPackets.ts](src/generatedServerPackets.ts) files that have definitions of packets that come from the server and the client respectively. These files are generated from the protocol files. Protocol, blocks info and other data go from <https://github.com/prismarineJS/minecraft-data> repository.

### Would be useful to have

- cleanup folder & modules structure, cleanup playground code

A few other notes:
## A few other notes

- Use `next` branch for development and as base & target branch for pull requests if possible.
- To link dependency locally e.g. flying-squid add this to `pnpm` > `overrides` of root package.json: `"flying-squid": "file:../space-squid",` (with some modules `pnpm link` also works)

- Press `Y` to reload application into the same world (server, local world or random singleplayer world)
- To start React profiling disable `REACT_APP_PROFILING` code first.
- It's recommended to use debugger for debugging. VSCode has a great debugger built-in. If debugger is slow, you can use `--no-sources` flag that would allow browser to speedup .map file parsing.
- Some data are cached between restarts. If you see something doesn't work after upgrading dependencies, try to clear the by simply removing the `dist` folder.
- The same folder `dist` is used for both development and production builds, so be careful when deploying the project.
- Use `start-prod` script to start the project in production mode after running the `build` script to build the project.

### Would be useful to have

- cleanup folder & modules structure, cleanup playground code
23 changes: 19 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ You can try this out at [mcraft.fun](https://mcraft.fun/), [pcm.gg](https://pcm.

### Big Features

- Connect to any offline server* (it's possible because of proxy servers, see below)
- Open any zip world file or even folder in read-write mode!
- Singleplayer mode with simple world generation
- Connect to cracked servers* (it's possible because of proxy servers, see below)
- Singleplayer mode with simple world generations!
- Works offline
- Play with friends over global network! (P2P is powered by Peer.js servers)
- Play with friends over internet! (P2P is powered by Peer.js discovery servers)
- First-class touch (mobile) & controller support
- Resource pack support
- even even more!

### Recommended Settings

- Controls -> **Raw Input** -> **On** - This will make the controls more precise
- Controls -> **Touch Controls Type** -> **Joystick**
- Controls -> **Auto Full Screen** -> **On** - To avoid ctrl+w issue
- Interface -> **Chat Select** -> **On** - To select chat messages

### World Loading

Zip files and folders are supported. Just drag and drop them into the browser window. You can open folders in readonly and read-write mode. New chunks may be generated incorrectly for now.
Expand All @@ -32,6 +39,14 @@ See the [Mineflayer](https://github.com/PrismarineJS/mineflayer) repo for the li
There is a builtin proxy, but you can also host a your one! Just clone the repo, run `pnpm i` (following CONTRIBUTING.MD) and run `pnpm prod-start`, then you can specify `http://localhost:8080` in the proxy field.
MS account authentication will be supported soon.

### Rendering

#### Three.js Renderer

- Uses WebGL2. Chunks are rendered using Geometry Buffers prepared by 4 mesher workers.
- Supports FXAA
- Doesn't support culling

<!-- TODO proxy server communication graph -->

### Things that are not planned yet
Expand Down Expand Up @@ -63,7 +78,7 @@ Instead I recommend setting `options.debugLogNotFrequentPackets`. Also you can u
- `viewer.world.sectionObjects` - Object with all active chunk sections (geometries) in the world. Each chunk section is a Three.js mesh or group.
- `debugSceneChunks` - The same as above, but relative to current bot position (e.g. 0,0 is the current chunk).
- `debugChangedOptions` - See what options are changed. Don't change options here.
- `localServer` - Only for singleplayer mode/host. Flying Squid server instance, see it's documentation for more.
- `localServer`/`server` - Only for singleplayer mode/host. Flying Squid server instance, see it's documentation for more.
- `localServer.overworld.storageProvider.regions` - See ALL LOADED region files with all raw data.

- `nbt.simplify(someNbt)` - Simplifies nbt data, so it's easier to read.
Expand Down
23 changes: 22 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,28 @@ export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
setupNodeEvents (on, config) {
// https://medium.com/automation-with-donald/get-memory-consumption-of-web-app-with-cypress-84e2656e5a0f
on('before:browser:launch', (browser = {
name: "",
family: "chromium",
channel: "",
displayName: "",
version: "",
majorVersion: "",
path: "",
isHeaded: false,
isHeadless: false
}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
// auto open devtools
launchOptions.args.push('--enable-precise-memory-info')
}

return launchOptions

})

return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:8080',
Expand Down
22 changes: 12 additions & 10 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@ import * as esbuild from 'esbuild'
import fs from 'fs'
// import htmlPlugin from '@chialab/esbuild-plugin-html'
import server from './server.js'
import { clients, plugins } from './scripts/esbuildPlugins.mjs'
import { clients, plugins, startWatchingHmr } from './scripts/esbuildPlugins.mjs'
import { generateSW } from 'workbox-build'
import { getSwAdditionalEntries } from './scripts/build.js'
import { build } from 'esbuild'

//@ts-ignore
try { await import('./localSettings.mjs') } catch { }

fs.writeFileSync('dist/index.html', fs.readFileSync('index.html', 'utf8').replace('<!-- inject script -->', '<script src="index.js"></script>'), 'utf8')
const entrypoint = 'index.ts'

fs.writeFileSync('dist/index.html', fs.readFileSync('index.html', 'utf8').replace('<!-- inject script -->', `<script src="${entrypoint.replace(/\.tsx?/, '.js')}"></script>`), 'utf8')

const watch = process.argv.includes('--watch') || process.argv.includes('-w')
const prod = process.argv.includes('--prod')
const dev = !prod

const banner = [
'window.global = globalThis;',
// report reload time
dev && 'if (sessionStorage.lastReload) { const [rebuild, reloadStart] = sessionStorage.lastReload.split(","); const now = Date.now(); console.log(`rebuild + reload:`, +rebuild, "+", now - reloadStart, "=", ((+rebuild + (now - reloadStart)) / 1000).toFixed(1) + "s");sessionStorage.lastReload = ""; }',
// auto-reload
dev && 'window.noAutoReload ??= false;(() => new EventSource("/esbuild").onmessage = ({ data: _data }) => { if (!_data) return; const data = JSON.parse(_data); if (!data.update) return;console.log("[esbuild] Page is outdated");document.title = `[O] ${document.title}`;if (window.noAutoReload || localStorage.noAutoReload) return; if (localStorage.autoReloadVisible && document.visibilityState !== "visible") return; sessionStorage.lastReload = `${data.update.time},${Date.now()}`; location.reload() })();'
].filter(Boolean)
]

const buildingVersion = new Date().toISOString().split(':')[0]

/** @type {import('esbuild').BuildOptions} */
const buildOptions = {
bundle: true,
entryPoints: ['src/index.ts'],
entryPoints: [`src/${entrypoint}`],
target: ['es2020'],
jsx: 'automatic',
jsxDev: dev,
// logLevel: 'debug',
logLevel: 'info',
platform: 'browser',
sourcemap: prod ? true : 'inline',
sourcemap: prod ? true : 'linked',
outdir: 'dist',
mainFields: [
'browser', 'module', 'main'
Expand Down Expand Up @@ -76,7 +74,10 @@ const buildOptions = {
loader: {
// todo use external or resolve issues with duplicating
'.png': 'dataurl',
'.map': 'empty'
'.map': 'empty',
'.vert': 'text',
'.frag': 'text',
'.obj': 'text',
},
write: false,
// todo would be better to enable?
Expand All @@ -86,6 +87,7 @@ const buildOptions = {
if (watch) {
const ctx = await esbuild.context(buildOptions)
await ctx.watch()
startWatchingHmr()
server.app.get('/esbuild', (req, res, next) => {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
Expand Down
4 changes: 0 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@
<body>
<div id="react-root"></div>
<div id="ui-root">
<pmui-hud id="hud" style="display: none;"></pmui-hud>
<pmui-pausescreen id="pause-screen" style="display: none;"></pmui-pausescreen>
<pmui-playscreen id="play-screen" style="display: none;"></pmui-playscreen>
<pmui-notification></pmui-notification>
<context-menu id="context-menu"></context-menu>
</div>
<!-- inject script -->
</body>
Expand Down
Loading
Loading