No description
  • TypeScript 92.9%
  • JavaScript 3.3%
  • CSS 2.8%
  • HTML 1%
Find a file
2024-08-05 03:18:49 +03:00
.github/workflows feat: Microsoft authentication! (#150) 2024-07-06 00:54:03 +03:00
.storybook feat: improve scaling in portrait mobile. Add close button for mobile chat (#157) 2024-07-08 03:49:10 +03:00
.vscode feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
assets feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
cypress feat: Microsoft authentication! (#150) 2024-07-06 00:54:03 +03:00
docs-assets add handled packets stats 2024-07-13 06:17:47 +03:00
experiments feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
patches feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
prismarine-viewer fix: fix water rendering when plant was neihbor 2024-08-02 01:53:51 +03:00
scripts fix item tooltips on mobile 2024-08-05 03:18:49 +03:00
src fix: always disable all default touch actions in mobile browser to fix certain critical touch issues 2024-08-05 02:58:39 +03:00
.dockerignore finally update dockerfile to a working one! uses 6gb of ram to build btw. image size: 2.4gb, ~200mb when running 2024-07-07 00:32:04 +03:00
.eslintignore feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
.eslintrc.json feat: Add a way to view / sign books (#158) 2024-07-17 02:53:26 +03:00
.gitignore more basic tests. test joining to a local java vanilla server, movement! 2024-06-13 19:47:48 +03:00
.npmignore fix package.json 2021-02-27 22:28:08 +00:00
.npmrc a few fixes (#20) 2023-09-19 03:18:01 +03:00
config.json rm manimali, replace with a better server 2024-06-11 03:26:24 +03:00
CONTRIBUTING.md rework contributing to outline all scripts, remove postinstall 2024-08-04 23:42:51 +03:00
cypress.config.ts a few minor but important world renderer fixes & impr 2024-04-17 05:34:20 +03:00
Dockerfile feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
Dockerfile.proxy make main docker build 5x smaller, add only proxy dockerfile 2024-07-14 01:55:41 +03:00
index.html feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
LICENSE Initial commit 2021-02-27 22:27:59 +01:00
package.json rework contributing to outline all scripts, remove postinstall 2024-08-04 23:42:51 +03:00
package.npm.json feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
pnpm-lock.yaml fix item tooltips on mobile 2024-08-05 03:18:49 +03:00
pnpm-workspace.yaml feat: signs rendering support! 2023-10-07 11:17:29 +03:00
README.MD rework contributing to outline all scripts, remove postinstall 2024-08-04 23:42:51 +03:00
README.NPM.MD feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
rsbuild.config.ts fix build: create generated dir 2024-08-05 03:09:27 +03:00
screenshot.png [ImgBot] Optimize images (#348) 2023-07-22 14:55:20 +02:00
server.js feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
tsconfig.json feat: migrate to mc-assets & Rsbuild better resource pack support (#164) 2024-07-26 13:12:28 +03:00
tsconfig.npm.json feat: publish all stories UI components to npm! (#111) 2024-05-05 03:25:08 +03:00
vercel.json disable silent 2023-09-04 11:48:39 +03:00
vitest.config.ts fix: super critical performance fix for some blocks like snow/soul sand 2024-04-17 07:24:40 +03:00

Minecraft Web Client

banner

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, pcm.gg (short link) mcon.vercel.app or the GitHub pages deploy. Every commit from the develop (default) branch is deployed to s.mcraft.fun - so it's usually newer, but might be less stable.

For building the project yourself / contributing, see 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
  • FULL Resource pack support: Custom GUI, all textures & custom models! Server resource packs are also supported.
  • Builtin JEI with recipes & guides for every item (also replaces creative inventory)
  • even even more!

All components that are in Storybook are published as npm module and can be used in other projects: minecraft-react

  • 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. In case of opening zip files they are stored in your ram entirely, so there is a ~300mb file limit on IOS. Whatever offline mode you used (zip, folder, just single player), you can always export world with the /export command typed in the game chat.

docs-assets/singleplayer-future-city-1-10-2.jpg

Servers

You can play almost on any Java server, vanilla servers are fully supported. See the Mineflayer repo for the list of supported versions (should support majority of versions). There is a builtin proxy, but you can also host 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.

Proxy servers are used to connect to Minecraft servers which use TCP protocol. When you connect connect to a server with a proxy, websocket connection is created between you (browser client) and the proxy server located in Europe, then the proxy connects to the Minecraft server and sends the data to the client (you) without any packet deserialization to avoid any additional delays. That said all the Minecraft protocol packets are processed by the client, right in your browser.

graph LR
    A[Web App - Client] --> C[Proxy Server]
    C --> B[Minecraft Server]
    style A fill:#f9d,stroke:#333,stroke-width:2px
    style B fill:#fc0,stroke:#333,stroke-width:2px
    style C fill:#fff,stroke:#333,stroke-width:2px

So if the server is located in Europe and you are connecting from Europe, you will have ~40ms ping (~180ms with residential proxy version), however if you are in the US and connecting to the server located in US, you will have >200ms ping, which is the worst case scenario.

Again, the proxy server is not a part of the client, it is a separate service that you can host yourself.

Docker Files

  • Main Dockerfile - for production build & offline/private usage. Includes full web-app + proxy server for connecting to Minecraft servers.
  • Proxy Dockerfile - for proxy server only - that one you would be able to specify in the proxy field on the client (docker build . -f Dockerfile.proxy -t minecraft-web-proxy)

In case of using docker, you don't have to follow preparation steps from CONTRIBUTING.MD, like installing Node.js, pnpm, etc.

Rendering

Three.js Renderer

  • Uses WebGL2. Chunks are rendered using Geometry Buffers prepared by 4 mesher workers.
  • Entities & text rendering
  • Supports resource packs
  • Doesn't support occlusion culling

Advanced Settings

There are many many settings, that are not exposed in the UI yet. You can find or change them by opening the browser console and typing options. You can also change them by typing options.<setting_name> = <value>.

Console

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 & Contributing

It should be easy to build/start the project locally. See CONTRIBUTING.MD for more info. Also you can look at Dockerfile for reference.

There is world renderer playground (link).

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

  • bot - Mineflayer bot instance. See Mineflayer documentation for more.

  • viewer - Three.js viewer instance, basically does all the rendering.

  • 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/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.

The most useful thing in devtools is the watch expression. You can add any expression there and it will be re-evaluated in real time. For example, you can add viewer.camera.position to see the camera position and so on.

Watch expression

You can also drag and drop any .dat or .mca (region files) into the browser window to see it's contents in the console.

F3 Keybindings

  • F3 - Toggle debug overlay
  • F3 + A - Reload all chunks (these that are loaded from the server)
  • F3 + G - Toggle chunk sections (geometries) border visibility + entities outline (aka Three.js geometry helpers)

world chunks have a yellow border, hostile mobs have a red outline, passive mobs have a green outline, players have a blue outline.

Query Parameters

Press Y to set query parameters to url of your current game state.

There are some parameters you can set in the url to archive some specific behaviors:

Server specific:

  • ?ip=<server_address> - Display connect screen to the server on load with predefined server ip. :<port> is optional and can be added to the ip.
  • ?name=<name> - Set the server name for saving to the server list
  • ?version=<version> - Set the version for the server
  • ?proxy=<proxy_address> - Set the proxy server address to use for the server
  • ?username=<username> - Set the username for the server
  • ?lockConnect=true - Only works then ip parameter is set. Disables cancel/save buttons and all inputs in the connect screen already set as parameters. Useful for integrates iframes.
  • ?reconnect=true - Reconnect to the server on page reloads. Available in dev mode only and very useful on server testing.

Single player specific:

  • ?loadSave=<save_name> - Load the save on load with the specified folder name (not title)
  • ?singleplayer=1 - Create empty world on load. Nothing will be saved
  • ?version=<version> - Set the version for the singleplayer world (when used with ?singleplayer=1)
  • ?noSave=true - Disable auto save on unload / disconnect / export whenever a world is loaded. Only manual save with /save command will work.
  • ?map=<map_url> - Load the map from ZIP. You can use any url, but it must be CORS enabled.

General:

  • ?setting=<setting_name>:<setting_value> - Set and lock the setting on load. You can set multiple settings by separating them with & e.g. ?setting=autoParkour:true&setting=renderDistance:4

Notable Things that Power this Project

Things that are not planned yet

  • Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines

Alternatives