rework contributing to outline all scripts, remove postinstall

This commit is contained in:
Vitaly Turovsky 2024-08-04 23:42:51 +03:00
commit 573e025de2
4 changed files with 49 additions and 10 deletions

View file

@ -8,14 +8,50 @@ After forking the repository, run the following commands to get started:
## Project Structure
There are 3 main parts of the project:
### Core (`src`)
This is the main app source code which reuses all the other parts of the project.
> The first version used Webpack, then was migrated to Esbuild and now is using Rsbuild!
- Scripts:
- Start: `pnpm start`, `pnpm dev-rsbuild` (if you don't need proxy server also running)
- Build: `pnpm build` (note that `build` script builds only the core app, not the whole project!)
Paths:
- `src` - main app source code
- `src/react` - React components - almost all UI is in this folder. Almost every component has its base (reused in app and storybook) and `Provider` - which is a component that provides context to its children. Consider looking at DeathScreen component to see how it's used.
- `src/menus` - Old Lit Element GUI. In the process of migration to React.
- `prismarine-viewer` - Improved version of <https://github.com/prismarineJS/prismarine-viewer>. Here is everything related to rendering the game world itself (no ui at all). Two most important parts here are:
### Renderer: Playground & Mesher (`prismarine-viewer`)
- Playground Scripts:
- Start: `pnpm run-playground` (playground, mesher + server) or `pnpm watch-playground`
- Build: `pnpm build-playground` or `node prismarine-viewer/esbuild.mjs`
- Mesher Scripts:
- Start: `pnpm watch-mesher`
- Build: `pnpm build-mesher`
Paths:
- `prismarine-viewer` - Improved and refactored version of <https://github.com/prismarineJS/prismarine-viewer>. Here is everything related to rendering the game world itself (no ui at all). Two most important parts here are:
- `prismarine-viewer/viewer/lib/worldrenderer.ts` - adding new objects to three.js happens here (sections)
- `prismarine-viewer/viewer/lib/models.ts` - preparing data for rendering (blocks) - happens in worker: out file - `worker.js`, building - `prismarine-viewer/buildWorker.mjs`
- `prismarine-viewer/examples/playground.ts` - Playground (source of <mcraft.fun/playground.html>) Use this for testing render changes. You can also modify playground code.
- `prismarine-viewer/examples/playground.ts` - Playground (source of <mcraft.fun/playground.html>) Use this for testing any rendering changes. You can also modify the playground code.
### Storybook (`.storybook`)
Storybook is a tool for easier developing and testing React components.
Path of all Storybook stories is `src/react/**/*.stories.tsx`.
- Scripts:
- Start: `pnpm storybook`
- Build: `pnpm build-storybook`
## Core-related
How different modules are used:

View file

@ -2,17 +2,18 @@
![banner](./docs-assets/banner.jpg)
A true Minecraft client running in your browser! A port of the original game to the web, written in JavaScript using modern web technologies.
If you encounter any bugs or usability issues, please report them! For development, see [development](#development--debugging).
A true Minecraft client running in your browser! A port of the original game to the web, written in JavaScript using the best modern web technologies.
You can try this out at [mcraft.fun](https://mcraft.fun/), [pcm.gg](https://pcm.gg) (short link) [mcon.vercel.app](https://mcon.vercel.app/) or the GitHub pages deploy. Every commit from the `develop` (default) branch is deployed to [s.mcraft.fun](https://s.mcraft.fun/) - so it's usually newer, but might be less stable.
For building the project yourself / contributing, see [Development, Debugging & Contributing](#development-debugging--contributing). If you encounter any bugs or usability issues, please report them!
### Big Features
- Open any zip world file or even folder in read-write mode!
- Connect to Java servers running in both offline (cracked) and online mode* (it's possible because of proxy servers, see below)
- Singleplayer mode with simple world generations!
- Google Drive support for reading / saving worlds
- Works offline
- Play with friends over internet! (P2P is powered by Peer.js discovery servers)
- First-class touch (mobile) & controller support
@ -82,13 +83,13 @@ There are many many settings, that are not exposed in the UI yet. You can find o
To open the console, press `F12`, or if you are on mobile, you can type `#dev` in the URL (browser address bar), it wont't reload the page, but you will see a button to open the console. This way you can change advanced settings and see all errors or warnings. Also this way you can access global variables (described below).
### Development & Debugging
### Development, Debugging & Contributing
It should be easy to build/start the project locally. See [CONTRIBUTING.MD](./CONTRIBUTING.md) for more info. Also you can look at Dockerfile for reference.
There is world renderer playground ([link](https://mcon.vercel.app/playground.html)).
However, there are many things that can be done in online version. You can access some global variables in the console and useful examples:
However, there are many things that can be done in online production version (like debugging actual source code). Also you can access some global variables in the console and there are a few useful examples:
- `localStorage.debug = '*'` - Enables all debug messages! Warning: this will start all packets spam.
Instead I recommend setting `options.debugLogNotFrequentPackets`. Also you can use `debugTopPackets` (with JSON.stringify) to see what packets were received/sent by name

View file

@ -14,7 +14,6 @@
"test-unit": "vitest",
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
"prod-start": "node server.js --prod",
"postinstall": "tsx scripts/optimizeBlockCollisions.ts && pnpm build-mesher",
"test-mc-server": "tsx cypress/minecraft-server.mjs",
"lint": "eslint \"{src,cypress}/**/*.{ts,js,jsx,tsx}\"",
"storybook": "storybook dev -p 6006",

View file

@ -101,6 +101,9 @@ export default defineConfig({
if (!fs.existsSync('./generated/minecraft-data-data.js')) {
childProcess.execSync('tsx ./scripts/genShims.ts', { stdio: 'inherit' })
}
if (!fs.existsSync('./generated/latestBlockCollisionsShapes.json')) {
childProcess.execSync('tsx ./scripts/optimizeBlockCollisions.ts', { stdio: 'inherit' })
}
fsExtra.copySync('./node_modules/mc-assets/dist/other-textures/latest/entity', './dist/textures/entity')
fsExtra.copySync('./assets/background', './dist/background')
fs.copyFileSync('./assets/favicon.png', './dist/favicon.png')
@ -115,7 +118,7 @@ export default defineConfig({
// childProcess.execSync('./scripts/prepareSounds.mjs', { stdio: 'inherit' })
// childProcess.execSync('tsx ./scripts/genMcDataTypes.ts', { stdio: 'inherit' })
// childProcess.execSync('tsx ./scripts/genPixelartTypes.ts', { stdio: 'inherit' })
if (fs.existsSync('./prismarine-viewer/public/mesher.js')) {
if (fs.existsSync('./prismarine-viewer/public/mesher.js') && dev) {
// copy mesher
fs.copyFileSync('./prismarine-viewer/public/mesher.js', './dist/mesher.js')
} else {