From 573e025de2cc7e2adc5e64dbfcec7da3ced5c9b1 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 4 Aug 2024 23:42:51 +0300 Subject: [PATCH] rework contributing to outline all scripts, remove postinstall --- CONTRIBUTING.md | 42 +++++++++++++++++++++++++++++++++++++++--- README.MD | 11 ++++++----- package.json | 1 - rsbuild.config.ts | 5 ++++- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eaf77b66..e1e4dfc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 . 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 . 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 ) Use this for testing render changes. You can also modify playground code. +- `prismarine-viewer/examples/playground.ts` - Playground (source of ) 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: diff --git a/README.MD b/README.MD index b1bc1296..69b6386c 100644 --- a/README.MD +++ b/README.MD @@ -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 diff --git a/package.json b/package.json index 91b42f87..f09c8f19 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/rsbuild.config.ts b/rsbuild.config.ts index 28a16ec3..621e4ed6 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -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 {