Compare commits
No commits in common. "next" and "gh-pages" have entirely different histories.
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
description: Restricts usage of the global Mineflayer `bot` variable to only src/ files; prohibits usage in renderer/. Specifies correct usage of player state and appViewer globals.
|
||||
globs: src/**/*.ts,renderer/**/*.ts
|
||||
alwaysApply: false
|
||||
---
|
||||
Ask AI
|
||||
|
||||
- The global variable `bot` refers to the Mineflayer bot instance.
|
||||
- You may use `bot` directly in any file under the `src/` directory (e.g., `src/mineflayer/playerState.ts`).
|
||||
- Do **not** use `bot` directly in any file under the `renderer/` directory or its subfolders (e.g., `renderer/viewer/three/worldrendererThree.ts`).
|
||||
- In renderer code, all bot/player state and events must be accessed via explicit interfaces, state managers, or passed-in objects, never by referencing `bot` directly.
|
||||
- In renderer code (such as in `WorldRendererThree`), use the `playerState` property (e.g., `worldRenderer.playerState.gameMode`) to access player state. The implementation for `playerState` lives in `src/mineflayer/playerState.ts`.
|
||||
- In `src/` code, you may use the global variable `appViewer` from `src/appViewer.ts` directly. Do **not** import `appViewer` or use `window.appViewer`; use the global `appViewer` variable as-is.
|
||||
- Some other global variables that can be used without window prefixes are listed in src/globals.d.ts
|
||||
|
||||
Rationale: This ensures a clean separation between the Mineflayer logic (server-side/game logic) and the renderer (client-side/view logic), making the renderer portable and testable, and maintains proper usage of global state.
|
||||
|
||||
For more general project contributing guides see CONTRIBUTING.md on like how to setup the project. Use pnpm tsc if needed to validate result with typechecking the whole project.
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# build stuff
|
||||
node_modules
|
||||
public
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
node_modules
|
||||
rsbuild.config.ts
|
||||
*.module.css.d.ts
|
||||
*.generated.ts
|
||||
generated
|
||||
dist
|
||||
public
|
||||
**/*/rsbuildSharedConfig.ts
|
||||
src/mcDataTypes.ts
|
||||
223
.eslintrc.json
|
|
@ -1,223 +0,0 @@
|
|||
{
|
||||
"extends": [
|
||||
"zardoy",
|
||||
"plugin:@stylistic/disable-legacy"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!*.js"
|
||||
],
|
||||
"plugins": [
|
||||
"@stylistic"
|
||||
],
|
||||
"rules": {
|
||||
// style
|
||||
"@stylistic/space-infix-ops": "error",
|
||||
"@stylistic/no-multi-spaces": "error",
|
||||
"@stylistic/no-trailing-spaces": "error",
|
||||
"@stylistic/space-before-function-paren": "error",
|
||||
"@stylistic/array-bracket-spacing": "error",
|
||||
// would be great to have but breaks TS code like (url?) => ...
|
||||
// "@stylistic/arrow-parens": [
|
||||
// "error",
|
||||
// "as-needed"
|
||||
// ],
|
||||
"@stylistic/arrow-spacing": "error",
|
||||
"@stylistic/block-spacing": "error",
|
||||
"@typescript-eslint/no-this-alias": "off",
|
||||
"@stylistic/brace-style": [
|
||||
"error",
|
||||
"1tbs",
|
||||
{
|
||||
"allowSingleLine": true
|
||||
}
|
||||
],
|
||||
// too annoying to be forced to multi-line, probably should be enforced to never
|
||||
// "@stylistic/comma-dangle": [
|
||||
// "error",
|
||||
// "always-multiline"
|
||||
// ],
|
||||
"@stylistic/computed-property-spacing": "error",
|
||||
"@stylistic/dot-location": [
|
||||
"error",
|
||||
"property"
|
||||
],
|
||||
"@stylistic/eol-last": "error",
|
||||
"@stylistic/function-call-spacing": "error",
|
||||
"@stylistic/function-paren-newline": [
|
||||
"error",
|
||||
"consistent"
|
||||
],
|
||||
"@stylistic/generator-star-spacing": "error",
|
||||
"@stylistic/implicit-arrow-linebreak": "error",
|
||||
"@stylistic/indent-binary-ops": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"@stylistic/function-call-argument-newline": [
|
||||
"error",
|
||||
"consistent"
|
||||
],
|
||||
"@stylistic/space-in-parens": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"@stylistic/object-curly-spacing": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"@stylistic/comma-spacing": "error",
|
||||
"@stylistic/semi": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"@stylistic/indent": [
|
||||
"error",
|
||||
2,
|
||||
{
|
||||
"SwitchCase": 1,
|
||||
"ignoredNodes": [
|
||||
"TemplateLiteral"
|
||||
]
|
||||
}
|
||||
],
|
||||
"@stylistic/quotes": [
|
||||
"error",
|
||||
"single",
|
||||
{
|
||||
"allowTemplateLiterals": true
|
||||
}
|
||||
],
|
||||
"@stylistic/key-spacing": "error",
|
||||
"@stylistic/keyword-spacing": "error",
|
||||
// "@stylistic/line-comment-position": "error", // not needed
|
||||
// "@stylistic/lines-around-comment": "error", // also not sure if needed
|
||||
// "@stylistic/max-len": "error", // also not sure if needed
|
||||
// "@stylistic/linebreak-style": "error", // let git decide
|
||||
"@stylistic/max-statements-per-line": [
|
||||
"error",
|
||||
{
|
||||
"max": 5
|
||||
}
|
||||
],
|
||||
// "@stylistic/member-delimiter-style": "error",
|
||||
// "@stylistic/multiline-ternary": "error", // not needed
|
||||
// "@stylistic/newline-per-chained-call": "error", // not sure if needed
|
||||
"@stylistic/new-parens": "error",
|
||||
"@typescript-eslint/class-literal-property-style": "off",
|
||||
"@stylistic/no-confusing-arrow": "error",
|
||||
"@stylistic/wrap-iife": "error",
|
||||
"@stylistic/space-before-blocks": "error",
|
||||
"@stylistic/type-generic-spacing": "error",
|
||||
"@stylistic/template-tag-spacing": "error",
|
||||
"@stylistic/template-curly-spacing": "error",
|
||||
"@stylistic/type-annotation-spacing": "error",
|
||||
"@stylistic/jsx-child-element-spacing": "error",
|
||||
// buggy
|
||||
// "@stylistic/jsx-closing-bracket-location": "error",
|
||||
// "@stylistic/jsx-closing-tag-location": "error",
|
||||
"@stylistic/jsx-curly-brace-presence": "error",
|
||||
"@stylistic/jsx-curly-newline": "error",
|
||||
"@stylistic/jsx-curly-spacing": "error",
|
||||
"@stylistic/jsx-equals-spacing": "error",
|
||||
"@stylistic/jsx-first-prop-new-line": "error",
|
||||
"@stylistic/jsx-function-call-newline": "error",
|
||||
"@stylistic/jsx-max-props-per-line": [
|
||||
"error",
|
||||
{
|
||||
"maximum": 7
|
||||
}
|
||||
],
|
||||
"@stylistic/jsx-pascal-case": "error",
|
||||
"@stylistic/jsx-props-no-multi-spaces": "error",
|
||||
"@stylistic/jsx-self-closing-comp": "error",
|
||||
// "@stylistic/jsx-sort-props": [
|
||||
// "error",
|
||||
// {
|
||||
// "callbacksLast": false,
|
||||
// "shorthandFirst": true,
|
||||
// "shorthandLast": false,
|
||||
// "multiline": "ignore",
|
||||
// "ignoreCase": true,
|
||||
// "noSortAlphabetically": true,
|
||||
// "reservedFirst": [
|
||||
// "key",
|
||||
// "className"
|
||||
// ],
|
||||
// "locale": "auto"
|
||||
// }
|
||||
// ],
|
||||
// perf
|
||||
"import/no-deprecated": "off",
|
||||
// ---
|
||||
"@typescript-eslint/prefer-nullish-coalescing": "off",
|
||||
"@typescript-eslint/naming-convention": "off",
|
||||
"prefer-template": "off",
|
||||
// intentional: improve readability in some cases
|
||||
"no-else-return": "off",
|
||||
"@typescript-eslint/padding-line-between-statements": "off",
|
||||
"@typescript-eslint/no-dynamic-delete": "off",
|
||||
"arrow-body-style": "off",
|
||||
"unicorn/prefer-ternary": "off",
|
||||
"unicorn/switch-case-braces": "off",
|
||||
"@typescript-eslint/consistent-type-definitions": "off",
|
||||
"unicorn/explicit-length-check": "off",
|
||||
"unicorn/prefer-dom-node-append": "off",
|
||||
"typescript-eslint/no-confusing-void-expression": "off",
|
||||
"unicorn/no-lonely-if": "off",
|
||||
"no-multi-assign": "off",
|
||||
"sonarjs/no-duplicate-string": "off",
|
||||
"new-cap": "off",
|
||||
"unicorn/consistent-destructuring": "off",
|
||||
"unicorn/no-await-expression-member": "off",
|
||||
"unicorn/prefer-add-event-listener": "off",
|
||||
"unicorn/prefer-top-level-await": "off",
|
||||
"default-case": "off",
|
||||
// I guess it would better to fix
|
||||
"node/prefer-global/buffer": "off",
|
||||
"unicorn/prefer-optional-catch-binding": "off", // still useful for debugging
|
||||
"no-alert": "off", // todo once replaced with ui, enable
|
||||
"@typescript-eslint/restrict-plus-operands": "off",
|
||||
// ---
|
||||
"@typescript-eslint/no-throw-literal": "off", // disabling because of "rule expansion"
|
||||
"no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"unicorn/prefer-query-selector": "off",
|
||||
"@typescript-eslint/dot-notation": "off", // trick prop type-checking
|
||||
"@typescript-eslint/consistent-type-imports": "off",
|
||||
"no-negated-condition": "off",
|
||||
"@typescript-eslint/no-require-imports": "off",
|
||||
"unicorn/prefer-number-properties": "off",
|
||||
"@typescript-eslint/no-confusing-void-expression": "off",
|
||||
"unicorn/no-empty-file": "off",
|
||||
"unicorn/prefer-event-target": "off",
|
||||
"@typescript-eslint/member-ordering": "off",
|
||||
// needs to be fixed actually
|
||||
"complexity": "off",
|
||||
"@typescript-eslint/no-floating-promises": "warn",
|
||||
"no-async-promise-executor": "off",
|
||||
"no-bitwise": "off",
|
||||
"unicorn/filename-case": "off",
|
||||
"max-depth": "off",
|
||||
"unicorn/no-typeof-undefined": "off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.js"
|
||||
],
|
||||
"rules": {
|
||||
"@stylistic/space-before-function-paren": [
|
||||
"error",
|
||||
{
|
||||
"anonymous": "always",
|
||||
"named": "never",
|
||||
"asyncArrow": "always"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"root": true
|
||||
}
|
||||
59
.github/workflows/benchmark.yml
vendored
|
|
@ -1,59 +0,0 @@
|
|||
name: Benchmark
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
push:
|
||||
branches:
|
||||
- perf-test
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
(github.event_name == 'push' && github.ref == 'refs/heads/perf-test') ||
|
||||
(
|
||||
github.event_name == 'issue_comment' &&
|
||||
github.event.issue.pull_request != '' &&
|
||||
(startsWith(github.event.comment.body, '/benchmark'))
|
||||
)
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- run: lscpu
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: "pnpm"
|
||||
- name: Move Cypress to dependencies
|
||||
run: |
|
||||
jq '.dependencies.cypress = .optionalDependencies.cypress | del(.optionalDependencies.cypress)' package.json > package.json.tmp
|
||||
mv package.json.tmp package.json
|
||||
- run: pnpm install --no-frozen-lockfile
|
||||
|
||||
- run: pnpm build
|
||||
- run: nohup pnpm prod-start &
|
||||
|
||||
- run: pnpm test:benchmark
|
||||
id: benchmark
|
||||
continue-on-error: true
|
||||
# read benchmark results from stdout
|
||||
- run: |
|
||||
if [ -f benchmark.txt ]; then
|
||||
# Format the benchmark results for GitHub comment
|
||||
BENCHMARK_RESULT=$(cat benchmark.txt | sed 's/^/- /')
|
||||
echo "BENCHMARK_RESULT<<EOF" >> $GITHUB_ENV
|
||||
echo "$BENCHMARK_RESULT" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
else
|
||||
echo "BENCHMARK_RESULT=Benchmark failed to run or produce results" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
with:
|
||||
allow-repeats: true
|
||||
message: |
|
||||
Benchmark result: ${{ env.BENCHMARK_RESULT }}
|
||||
33
.github/workflows/build-single-file.yml
vendored
|
|
@ -1,33 +0,0 @@
|
|||
name: build-single-file
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build single-file version - minecraft.html
|
||||
run: pnpm build-single-file && mv dist/single/index.html minecraft.html
|
||||
env:
|
||||
LOCAL_CONFIG_FILE: config.mcraft-only.json
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: minecraft.html
|
||||
path: minecraft.html
|
||||
45
.github/workflows/build-zip.yml
vendored
|
|
@ -1,45 +0,0 @@
|
|||
name: Make Self Host Zip
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build project
|
||||
run: pnpm build
|
||||
env:
|
||||
LOCAL_CONFIG_FILE: config.mcraft-only.json
|
||||
|
||||
- name: Bundle server.js
|
||||
run: |
|
||||
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define:process.env.NODE_ENV="'production'"
|
||||
|
||||
- name: Create distribution package
|
||||
run: |
|
||||
mkdir -p package
|
||||
cp -r dist package/
|
||||
cp bundled-server.js package/server.js
|
||||
cd package
|
||||
zip -r ../self-host.zip .
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: self-host
|
||||
path: self-host.zip
|
||||
177
.github/workflows/ci.yml
vendored
|
|
@ -1,177 +0,0 @@
|
|||
name: CI
|
||||
on:
|
||||
pull_request:
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@master
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v1.4.3
|
||||
with:
|
||||
java-version: 17
|
||||
java-package: jre
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
# cache: "pnpm"
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- run: pnpm install
|
||||
- run: pnpm build-single-file
|
||||
- name: Store minecraft.html size
|
||||
run: |
|
||||
SIZE_BYTES=$(du -s dist/single/minecraft.html 2>/dev/null | cut -f1)
|
||||
echo "SIZE_BYTES=$SIZE_BYTES" >> $GITHUB_ENV
|
||||
- run: pnpm check-build
|
||||
- name: Create zip package for size comparison
|
||||
run: |
|
||||
mkdir -p package
|
||||
cp -r dist package/
|
||||
cd package
|
||||
zip -r ../self-host.zip .
|
||||
- run: pnpm build-playground
|
||||
# - run: pnpm build-storybook
|
||||
- run: pnpm test-unit
|
||||
- run: pnpm lint
|
||||
|
||||
- name: Parse Bundle Stats
|
||||
run: |
|
||||
GZIP_BYTES=$(du -s self-host.zip 2>/dev/null | cut -f1)
|
||||
SIZE=$(echo "scale=2; $SIZE_BYTES/1024/1024" | bc)
|
||||
GZIP_SIZE=$(echo "scale=2; $GZIP_BYTES/1024/1024" | bc)
|
||||
echo "{\"total\": ${SIZE}, \"gzipped\": ${GZIP_SIZE}}" > /tmp/bundle-stats.json
|
||||
|
||||
# - name: Compare Bundle Stats
|
||||
# id: compare
|
||||
# uses: actions/github-script@v6
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GIST_TOKEN }}
|
||||
# with:
|
||||
# script: |
|
||||
# const gistId = '${{ secrets.BUNDLE_STATS_GIST_ID }}';
|
||||
|
||||
# async function getGistContent() {
|
||||
# const { data } = await github.rest.gists.get({
|
||||
# gist_id: gistId,
|
||||
# headers: {
|
||||
# authorization: `token ${process.env.GITHUB_TOKEN}`
|
||||
# }
|
||||
# });
|
||||
# return JSON.parse(data.files['bundle-stats.json'].content || '{}');
|
||||
# }
|
||||
|
||||
# const content = await getGistContent();
|
||||
# const baseStats = content['${{ github.event.pull_request.base.ref }}'];
|
||||
# const newStats = require('/tmp/bundle-stats.json');
|
||||
|
||||
# const comparison = `minecraft.html (normal build gzip)\n${baseStats.total}MB (${baseStats.gzipped}MB compressed) -> ${newStats.total}MB (${newStats.gzipped}MB compressed)`;
|
||||
# core.setOutput('stats', comparison);
|
||||
|
||||
# - run: pnpm tsx scripts/buildNpmReact.ts
|
||||
- run: nohup pnpm prod-start &
|
||||
- run: nohup pnpm test-mc-server &
|
||||
- uses: cypress-io/github-action@v5
|
||||
with:
|
||||
install: false
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: cypress-images
|
||||
path: cypress/screenshots/
|
||||
# - run: node scripts/outdatedGitPackages.mjs
|
||||
# if: ${{ github.event.pull_request.base.ref == 'release' }}
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# - name: Store Bundle Stats
|
||||
# if: github.event.pull_request.base.ref == 'next'
|
||||
# uses: actions/github-script@v6
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GIST_TOKEN }}
|
||||
# with:
|
||||
# script: |
|
||||
# const gistId = '${{ secrets.BUNDLE_STATS_GIST_ID }}';
|
||||
|
||||
# async function getGistContent() {
|
||||
# const { data } = await github.rest.gists.get({
|
||||
# gist_id: gistId,
|
||||
# headers: {
|
||||
# authorization: `token ${process.env.GITHUB_TOKEN}`
|
||||
# }
|
||||
# });
|
||||
# return JSON.parse(data.files['bundle-stats.json'].content || '{}');
|
||||
# }
|
||||
|
||||
# async function updateGistContent(content) {
|
||||
# await github.rest.gists.update({
|
||||
# gist_id: gistId,
|
||||
# headers: {
|
||||
# authorization: `token ${process.env.GITHUB_TOKEN}`
|
||||
# },
|
||||
# files: {
|
||||
# 'bundle-stats.json': {
|
||||
# content: JSON.stringify(content, null, 2)
|
||||
# }
|
||||
# }
|
||||
# });
|
||||
# }
|
||||
|
||||
# const stats = require('/tmp/bundle-stats.json');
|
||||
# const content = await getGistContent();
|
||||
# content['${{ github.event.pull_request.base.ref }}'] = stats;
|
||||
# await updateGistContent(content);
|
||||
|
||||
# - name: Update PR Description
|
||||
# uses: actions/github-script@v6
|
||||
# with:
|
||||
# script: |
|
||||
# const { data: pr } = await github.rest.pulls.get({
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# pull_number: context.issue.number
|
||||
# });
|
||||
|
||||
# let body = pr.body || '';
|
||||
# const statsMarker = '### Bundle Size';
|
||||
# const comparison = '${{ steps.compare.outputs.stats }}';
|
||||
|
||||
# if (body.includes(statsMarker)) {
|
||||
# body = body.replace(
|
||||
# new RegExp(`${statsMarker}[^\n]*\n[^\n]*`),
|
||||
# `${statsMarker}\n${comparison}`
|
||||
# );
|
||||
# } else {
|
||||
# body += `\n\n${statsMarker}\n${comparison}`;
|
||||
# }
|
||||
|
||||
# await github.rest.pulls.update({
|
||||
# owner: context.repo.owner,
|
||||
# repo: context.repo.repo,
|
||||
# pull_number: context.issue.number,
|
||||
# body
|
||||
# });
|
||||
# dedupe-check:
|
||||
# runs-on: ubuntu-latest
|
||||
# if: github.event.pull_request.head.ref == 'next'
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@v2
|
||||
|
||||
# - name: Install pnpm
|
||||
# run: npm install -g pnpm@9.0.4
|
||||
|
||||
# - name: Run pnpm dedupe
|
||||
# run: pnpm dedupe
|
||||
|
||||
# - name: Check for changes
|
||||
# run: |
|
||||
# if ! git diff --exit-code --quiet pnpm-lock.yaml; then
|
||||
# echo "pnpm dedupe introduced changes:"
|
||||
# git diff --color=always pnpm-lock.yaml
|
||||
# exit 1
|
||||
# else
|
||||
# echo "No changes detected after pnpm dedupe in pnpm-lock.yaml"
|
||||
# fi
|
||||
29
.github/workflows/fix-lint.yml
vendored
|
|
@ -1,29 +0,0 @@
|
|||
name: Fix Lint Command
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event.issue.pull_request != '' &&
|
||||
(
|
||||
contains(github.event.comment.body, '/fix')
|
||||
)
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: refs/pull/${{ github.event.issue.number }}/head
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- run: pnpm install
|
||||
- run: pnpm lint --fix
|
||||
- name: Push Changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
28
.github/workflows/merge-next.yml
vendored
|
|
@ -1,28 +0,0 @@
|
|||
name: Update Base Branch Command
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event.issue.pull_request != '' &&
|
||||
(
|
||||
contains(github.event.comment.body, '/update')
|
||||
)
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # Fetch all history so we can merge branches
|
||||
ref: refs/pull/${{ github.event.issue.number }}/head
|
||||
- name: Fetch All Branches
|
||||
run: git fetch --all
|
||||
# - name: Checkout PR
|
||||
# run: git checkout ${{ github.event.issue.pull_request.head.ref }}
|
||||
- name: Merge From Next
|
||||
run: git merge origin/next --strategy-option=theirs
|
||||
- name: Push Changes
|
||||
run: git push
|
||||
91
.github/workflows/next-deploy.yml
vendored
|
|
@ -1,91 +0,0 @@
|
|||
name: Vercel Deploy Next
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
ALIASES: ${{ vars.ALIASES }}
|
||||
MAIN_MENU_LINKS: ${{ vars.MAIN_MENU_LINKS }}
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- next
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- name: Install Global Dependencies
|
||||
run: pnpm add -g vercel
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
- name: Pull Vercel Environment Information
|
||||
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Write Release Info
|
||||
run: |
|
||||
echo "{\"latestTag\": \"$(git rev-parse --short $GITHUB_SHA)\", \"isCommit\": true}" > assets/release.json
|
||||
- name: Download Generated Sounds map
|
||||
run: node scripts/downloadSoundsMap.mjs
|
||||
- name: Build Project Artifacts
|
||||
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
|
||||
env:
|
||||
CONFIG_JSON_SOURCE: BUNDLED
|
||||
LOCAL_CONFIG_FILE: config.mcraft-only.json
|
||||
- name: Copy playground files
|
||||
run: |
|
||||
mkdir -p .vercel/output/static/playground
|
||||
pnpm build-playground
|
||||
cp -r renderer/dist/* .vercel/output/static/playground/
|
||||
- name: Deploy Project Artifacts to Vercel
|
||||
uses: mathiasvr/command-output@v2.0.0
|
||||
with:
|
||||
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
|
||||
id: deploy
|
||||
- name: Start servers for testing
|
||||
run: |
|
||||
nohup pnpm prod-start &
|
||||
nohup pnpm test-mc-server &
|
||||
- name: Run Cypress smoke tests
|
||||
uses: cypress-io/github-action@v5
|
||||
with:
|
||||
install: false
|
||||
spec: cypress/e2e/smoke.spec.ts
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: cypress-smoke-test-screenshots
|
||||
path: cypress/screenshots/
|
||||
- name: Set deployment aliases
|
||||
run: |
|
||||
for alias in $(echo ${{ secrets.TEST_PREVIEW_DOMAIN }} | tr "," "\n"); do
|
||||
vercel alias set ${{ steps.deploy.outputs.stdout }} $alias --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
|
||||
done
|
||||
|
||||
- name: Create Release Pull Request
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const { data: pulls } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
head: `${context.repo.owner}:next`,
|
||||
base: 'release',
|
||||
state: 'open'
|
||||
});
|
||||
|
||||
if (pulls.length === 0) {
|
||||
await github.rest.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: 'Release',
|
||||
head: 'next',
|
||||
base: 'release',
|
||||
body: 'PR was created automatically by the release workflow, hope you release it as soon as possible!',
|
||||
});
|
||||
}
|
||||
114
.github/workflows/preview.yml
vendored
|
|
@ -1,114 +0,0 @@
|
|||
name: Vercel PR 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]
|
||||
pull_request_target:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
(
|
||||
(
|
||||
github.event_name == 'issue_comment' &&
|
||||
contains(github.event.comment.body, '/deploy') &&
|
||||
github.event.issue.pull_request != null
|
||||
) ||
|
||||
(
|
||||
github.event_name == 'pull_request_target' &&
|
||||
contains(fromJson(vars.AUTO_DEPLOY_PRS), github.event.pull_request.number)
|
||||
)
|
||||
)
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout Base To Temp
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: temp-base-repo
|
||||
- name: Get deployment alias
|
||||
run: node temp-base-repo/scripts/githubActions.mjs getAlias
|
||||
id: alias
|
||||
env:
|
||||
ALIASES: ${{ env.ALIASES }}
|
||||
PULL_URL: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }}
|
||||
- name: Checkout PR (comment)
|
||||
uses: actions/checkout@v2
|
||||
if: github.event_name == 'issue_comment'
|
||||
with:
|
||||
ref: refs/pull/${{ github.event.issue.number }}/head
|
||||
- name: Checkout PR (pull_request)
|
||||
uses: actions/checkout@v2
|
||||
if: github.event_name == 'pull_request_target'
|
||||
with:
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/head
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: "pnpm"
|
||||
- name: Update deployAlwaysUpdate packages
|
||||
run: |
|
||||
if [ -f package.json ]; then
|
||||
PACKAGES=$(node -e "const pkg = require('./package.json'); if (pkg.deployAlwaysUpdate) console.log(pkg.deployAlwaysUpdate.join(' '))")
|
||||
if [ ! -z "$PACKAGES" ]; then
|
||||
echo "Updating packages: $PACKAGES"
|
||||
pnpm up -L $PACKAGES
|
||||
else
|
||||
echo "No deployAlwaysUpdate packages found in package.json"
|
||||
fi
|
||||
else
|
||||
echo "package.json not found"
|
||||
fi
|
||||
- name: Install Global Dependencies
|
||||
run: pnpm add -g vercel
|
||||
- name: Pull Vercel Environment Information
|
||||
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Write Release Info
|
||||
run: |
|
||||
echo "{\"latestTag\": \"$(git rev-parse --short ${{ github.event.pull_request.head.sha }})\", \"isCommit\": true}" > assets/release.json
|
||||
- name: Download Generated Sounds map
|
||||
run: node scripts/downloadSoundsMap.mjs
|
||||
- name: Build Project Artifacts
|
||||
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
|
||||
env:
|
||||
CONFIG_JSON_SOURCE: BUNDLED
|
||||
LOCAL_CONFIG_FILE: config.mcraft-only.json
|
||||
- name: Copy playground files
|
||||
run: |
|
||||
mkdir -p .vercel/output/static/playground
|
||||
pnpm build-playground
|
||||
cp -r renderer/dist/* .vercel/output/static/playground/
|
||||
- name: Write pr redirect index.html
|
||||
run: |
|
||||
mkdir -p .vercel/output/static/pr
|
||||
echo "<meta http-equiv='refresh' content='0;url=https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number || github.event.pull_request.number }}'>" > .vercel/output/static/pr/index.html
|
||||
- name: Write commit redirect index.html
|
||||
run: |
|
||||
mkdir -p .vercel/output/static/commit
|
||||
echo "<meta http-equiv='refresh' content='0;url=https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number || github.event.pull_request.number }}/commits/${{ github.event.pull_request.head.sha }}'>" > .vercel/output/static/commit/index.html
|
||||
- name: Deploy Project Artifacts to Vercel
|
||||
uses: mathiasvr/command-output@v2.0.0
|
||||
with:
|
||||
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
|
||||
id: deploy
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
# if: github.event_name == 'issue_comment'
|
||||
with:
|
||||
allow-repeats: true
|
||||
message: |
|
||||
Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }}
|
||||
[Playground](${{ steps.deploy.outputs.stdout }}/playground/)
|
||||
[Storybook](${{ steps.deploy.outputs.stdout }}/storybook/)
|
||||
# - run: git checkout next scripts/githubActions.mjs
|
||||
- name: Set deployment alias
|
||||
if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }}
|
||||
run: |
|
||||
for alias in $(echo ${{ steps.alias.outputs.alias }} | tr "," "\n"); do
|
||||
vercel alias set ${{ steps.deploy.outputs.stdout }} $alias --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
|
||||
done
|
||||
116
.github/workflows/release.yml
vendored
|
|
@ -1,116 +0,0 @@
|
|||
name: Release
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
MAIN_MENU_LINKS: ${{ vars.MAIN_MENU_LINKS }}
|
||||
on:
|
||||
push:
|
||||
branches: [release]
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@master
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
- name: Install Global Dependencies
|
||||
run: pnpm add -g vercel
|
||||
# - run: pnpm install
|
||||
# - run: pnpm build
|
||||
- run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- run: node scripts/replaceFavicon.mjs ${{ secrets.FAVICON_MAIN }}
|
||||
# will install + build to .vercel/output/static
|
||||
- name: Get Release Info
|
||||
run: pnpx zardoy-release empty --skip-github --output-file assets/release.json
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download Generated Sounds map
|
||||
run: node scripts/downloadSoundsMap.mjs
|
||||
- run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
|
||||
env:
|
||||
CONFIG_JSON_SOURCE: BUNDLED
|
||||
LOCAL_CONFIG_FILE: config.mcraft-only.json
|
||||
- name: Copy playground files
|
||||
run: |
|
||||
mkdir -p .vercel/output/static/playground
|
||||
pnpm build-playground
|
||||
cp -r renderer/dist/* .vercel/output/static/playground/
|
||||
|
||||
# publish to github
|
||||
- run: cp vercel.json .vercel/output/static/vercel.json
|
||||
- uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: .vercel/output/static
|
||||
force_orphan: true
|
||||
|
||||
# Create CNAME file for custom domain
|
||||
- name: Create CNAME file
|
||||
run: echo "github.mcraft.fun" > .vercel/output/static/CNAME
|
||||
|
||||
- name: Deploy to mwc-mcraft-pages repository
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
personal_token: ${{ secrets.MCW_MCRAFT_PAGE_DEPLOY_TOKEN }}
|
||||
external_repository: ${{ github.repository_owner }}/mwc-mcraft-pages
|
||||
publish_dir: .vercel/output/static
|
||||
publish_branch: main
|
||||
destination_dir: docs
|
||||
force_orphan: true
|
||||
|
||||
- name: Change index.html title
|
||||
run: |
|
||||
# change <title>Minecraft Web Client</title> to <title>Minecraft Web Client — Free Online Browser Version</title>
|
||||
sed -i 's/<title>Minecraft Web Client<\/title>/<title>Minecraft Web Client — Free Online Browser Version<\/title>/' .vercel/output/static/index.html
|
||||
|
||||
- name: Deploy Project to Vercel
|
||||
uses: mathiasvr/command-output@v2.0.0
|
||||
with:
|
||||
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
|
||||
id: deploy
|
||||
- name: Get releasing alias
|
||||
run: node scripts/githubActions.mjs getReleasingAlias
|
||||
id: alias
|
||||
- name: Set deployment alias
|
||||
run: |
|
||||
for alias in $(echo ${{ steps.alias.outputs.alias }} | tr "," "\n"); do
|
||||
vercel alias set ${{ steps.deploy.outputs.stdout }} $alias --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
|
||||
done
|
||||
|
||||
- name: Build single-file version - minecraft.html
|
||||
run: pnpm build-single-file && mv dist/single/index.html minecraft.html
|
||||
- name: Build self-host version
|
||||
run: pnpm build
|
||||
- name: Bundle server.js
|
||||
run: |
|
||||
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define:process.env.NODE_ENV="'production'"
|
||||
|
||||
- name: Create zip package
|
||||
run: |
|
||||
mkdir -p package
|
||||
cp -r dist package/
|
||||
cp bundled-server.js package/server.js
|
||||
cd package
|
||||
zip -r ../self-host.zip .
|
||||
|
||||
- run: |
|
||||
pnpx zardoy-release node --footer "This release URL: https://$(echo ${{ steps.alias.outputs.alias }} | cut -d',' -f1) (Vercel URL: ${{ steps.deploy.outputs.stdout }})"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# has possible output: tag
|
||||
id: release
|
||||
|
||||
# has output
|
||||
- name: Set publishing config
|
||||
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
# - run: pnpm tsx scripts/buildNpmReact.ts ${{ steps.release.outputs.tag }}
|
||||
# if: steps.release.outputs.tag
|
||||
# env:
|
||||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
24
.gitignore
vendored
|
|
@ -1,24 +0,0 @@
|
|||
node_modules/
|
||||
package-lock.json
|
||||
.vscode
|
||||
**/public
|
||||
*.log
|
||||
.env.local
|
||||
Thumbs.db
|
||||
build
|
||||
localSettings.mjs
|
||||
dist*
|
||||
.DS_Store
|
||||
.idea/
|
||||
/world
|
||||
data*.json
|
||||
out
|
||||
*.iml
|
||||
.vercel
|
||||
generated
|
||||
storybook-static
|
||||
server-jar
|
||||
config.local.json
|
||||
logs/
|
||||
|
||||
src/react/npmReactComponents.ts
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
node_modules/
|
||||
package-lock.json
|
||||
.vscode
|
||||
3
.npmrc
|
|
@ -1,3 +0,0 @@
|
|||
public-hoist-pattern=*
|
||||
ignore-workspace-root-check=true
|
||||
shell-emulator=true
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
import type { StorybookConfig } from "@storybook/react-vite";
|
||||
|
||||
const config: StorybookConfig = {
|
||||
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
||||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
|
||||
framework: {
|
||||
name: "@storybook/react-vite",
|
||||
options: {},
|
||||
},
|
||||
docs: {
|
||||
autodocs: "tag",
|
||||
},
|
||||
};
|
||||
export default config;
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import React from 'react'
|
||||
|
||||
import type { Preview } from "@storybook/react"
|
||||
|
||||
import './storybook.css'
|
||||
import '../src/styles.css'
|
||||
import '../src/scaleInterface'
|
||||
|
||||
const preview: Preview = {
|
||||
decorators: [
|
||||
(Story, c) => {
|
||||
const noScaling = c.parameters.noScaling
|
||||
return <div id={noScaling ? '' : 'ui-root'}>
|
||||
<Story />
|
||||
</div>
|
||||
},
|
||||
],
|
||||
parameters: {
|
||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default preview
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#storybook-root::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background-image: url("../assets/storybook-bg.jpg");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: minecraft;
|
||||
src: url(../assets/minecraftia.woff);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: mojangles;
|
||||
src: url(../assets/mojangles.ttf);
|
||||
}
|
||||
60
.vscode/launch.json
vendored
|
|
@ -1,60 +0,0 @@
|
|||
{
|
||||
"configurations": [
|
||||
// recommended as much faster
|
||||
{
|
||||
// to launch "C:\Program Files\Google\Chrome Beta\Application\chrome.exe" --remote-debugging-port=9222
|
||||
"type": "chrome",
|
||||
"address": "localhost",
|
||||
"name": "Attach Chrome",
|
||||
"request": "attach",
|
||||
// comment if using webpack
|
||||
"pathMapping": {
|
||||
"/": "${workspaceFolder}/dist"
|
||||
},
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js",
|
||||
// "!${workspaceFolder}/dist/**/*vendors*",
|
||||
"!${workspaceFolder}/dist/**/*mc-data*",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"skipFiles": [
|
||||
// "<node_internals>/**/*vendors*"
|
||||
"<node_internals>/**/*mc-data*"
|
||||
],
|
||||
"port": 9222,
|
||||
},
|
||||
{
|
||||
// not recommended as in most cases it will slower as it launches from extension host so it slows down extension host, not sure why
|
||||
"type": "chrome",
|
||||
"name": "Launch Chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:3000/",
|
||||
"pathMapping": {
|
||||
"/": "${workspaceFolder}/dist"
|
||||
},
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js",
|
||||
// "!${workspaceFolder}/dist/**/*vendors*",
|
||||
"!${workspaceFolder}/dist/**/*mc-data*",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"skipFiles": [
|
||||
// "<node_internals>/**/*vendors*"
|
||||
"<node_internals>/**/*mc-data*"
|
||||
],
|
||||
},
|
||||
{
|
||||
// to launch "C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server
|
||||
"type": "firefox",
|
||||
"name": "Attach Firefox",
|
||||
"request": "attach",
|
||||
// comment if using webpack
|
||||
"url": "http://localhost:3000/",
|
||||
"webRoot": "${workspaceFolder}/",
|
||||
"skipFiles": [
|
||||
// "<node_internals>/**/*vendors*"
|
||||
"<node_internals>/**/*mc-data*"
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
36
.vscode/tasks.json
vendored
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "viewer-server",
|
||||
"command": "live-server --port=9090",
|
||||
"type": "shell",
|
||||
"args": [],
|
||||
"problemMatcher": [],
|
||||
// set cwd
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/prismarine-viewer/public/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
},
|
||||
{
|
||||
"label": "viewer-esbuild",
|
||||
"type": "shell",
|
||||
"command": "node prismarine-viewer/esbuild.mjs -w",
|
||||
"problemMatcher": "$esbuild-watch",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
},
|
||||
{
|
||||
"label": "viewer server+esbuild",
|
||||
"dependsOn": [
|
||||
"viewer-server",
|
||||
"viewer-esbuild"
|
||||
],
|
||||
"dependsOrder": "parallel",
|
||||
}
|
||||
]
|
||||
}
|
||||
195
CONTRIBUTING.md
|
|
@ -1,195 +0,0 @@
|
|||
# Contributing Guide
|
||||
|
||||
After forking the repository, run the following commands to get started:
|
||||
|
||||
0. Ensure you have [Node.js](https://nodejs.org) installed. Enable corepack with `corepack enable` *(1).
|
||||
1. Install dependencies: `pnpm i`
|
||||
2. Start the project in development mode: `pnpm start` or build the project for production: `pnpm build`
|
||||
3. Read the [Tasks Categories](#tasks-categories) and [Workflow](#workflow) sections below
|
||||
4. Let us know if you are working on something and be sure to open a PR if you got any changes. Happy coding!
|
||||
|
||||
*(1): If you are getting `Cannot find matching keyid` update corepack to the latest version with `npm i -g corepack`.
|
||||
|
||||
*(2): If still something doesn't work ensure you have the right nodejs version with `node -v` (tested on 22.x)
|
||||
|
||||
<!-- *(3): For GitHub codespaces (cloud ide): Run `pnpm i @rsbuild/core@1.2.4 @rsbuild/plugin-node-polyfill@1.3.0 @rsbuild/plugin-react@1.1.0 @rsbuild/plugin-typed-css-modules@1.0.2` command to avoid crashes because of limited ram -->
|
||||
|
||||
## 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.
|
||||
|
||||
### Renderer: Playground & Mesher (`renderer`)
|
||||
|
||||
- Playground Scripts:
|
||||
- Start: `pnpm run-playground` (playground, mesher + server) or `pnpm watch-playground`
|
||||
- Build: `pnpm build-playground` or `node renderer/esbuild.mjs`
|
||||
|
||||
- Mesher Scripts:
|
||||
- Start: `pnpm watch-mesher`
|
||||
- Build: `pnpm build-mesher`
|
||||
|
||||
Paths:
|
||||
|
||||
- `renderer` - 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:
|
||||
- `renderer/viewer/lib/worldrenderer.ts` - adding new objects to three.js happens here (sections)
|
||||
- `renderer/viewer/lib/models.ts` - preparing data for rendering (blocks) - happens in worker: out file - `worker.js`, building - `renderer/buildWorker.mjs`
|
||||
- `renderer/playground/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:
|
||||
|
||||
- `mineflayer` - provider `bot` variable and as mineflayer states it is a wrapper for the `node-minecraft-protocol` module and is used to connect and interact with real Java Minecraft servers. However not all events & properties are exposed and sometimes you have to use `bot._client.on('packet_name', data => ...)` to handle packets that are not handled via mineflayer API. Also you can use almost any mineflayer plugin.
|
||||
|
||||
## Running Main App + Playground
|
||||
|
||||
To start the main web app and playground, run `pnpm run-all`. Note is doesn't start storybook and tests.
|
||||
|
||||
## Cypress Tests (E2E)
|
||||
|
||||
Cypress tests are located in `cypress` folder. To run them, run `pnpm test-mc-server` and then `pnpm test:cypress` when the `pnpm prod-start` is running (or change the port to 3000 to test with the dev server). Usually you don't need to run these until you get issues on the CI.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
There are not many unit tests for now (which we are trying to improve).
|
||||
Location of unit tests: `**/*.test.ts` files in `src` folder and `renderer` folder.
|
||||
Start them with `pnpm test-unit`.
|
||||
|
||||
## Making protocol-related changes
|
||||
|
||||
You can get a description of packets for the latest protocol version from <https://wiki.vg/Protocol> and for previous protocol versions from <https://wiki.vg/Protocol_version_numbers> (look for *Page* links that have *Protocol* in URL).
|
||||
|
||||
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.
|
||||
|
||||
## A few other notes
|
||||
|
||||
- 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.
|
||||
- If CI is failing on the next branch for some reason, feel free to use the latest commit for release branch. We will update the base branch asap. Please, always make sure to allow maintainers do changes when opening PRs.
|
||||
|
||||
## Tasks Categories
|
||||
|
||||
(most important for now are on top).
|
||||
|
||||
## 1. Client-side Logic (most important right now)
|
||||
|
||||
Everything related to the client side packets. Investigate issues when something goes wrong with some server. It's much easier to work on these types of tasks when you have experience in Java with Minecraft, a deep understanding of the original client, and know how to debug it (which is not hard actually). Right now the client is easily detectable by anti-cheat plugins, and the main goal is to fix it (mostly because of wrong physics implementation).
|
||||
|
||||
Priority tasks:
|
||||
|
||||
- Rewrite or fix the physics logic (Botcraft or Grim can be used as a reference as well)
|
||||
- Implement basic minecart / boat / horse riding
|
||||
- Fix auto jump module (false triggers, performance issues)
|
||||
- Investigate connection issues to some servers
|
||||
- Setup a platform for automatic cron testing against the latest version of the anti-cheat plugins
|
||||
- ...
|
||||
|
||||
Goals:
|
||||
|
||||
- Make more servers playable. Right now on hypixel-like servers (servers with minigames), only tnt run (and probably ) is fully playable.
|
||||
|
||||
Notes:
|
||||
|
||||
- You can see the incoming/outgoing packets in the console (F12 in Chrome) by enabling `options.debugLogNotFrequentPackets = true`. However, if you need a FULL log of all packets, you can start recording the packets by going into `Settings` > `Advanced` > `Enable Packets Replay` and then you can download the file and use it to replay the packets.
|
||||
- You can use mcraft-e2e studio to send the same packets over and over again (which is useful for testing) or use the packets replayer (which is useful for debugging).
|
||||
|
||||
## 2. Three.js Renderer
|
||||
|
||||
Example tasks:
|
||||
|
||||
- Improve / fix entity rendering
|
||||
- Better update entities on specific packets
|
||||
- Investigate performance issues under different conditions (instructions provided)
|
||||
- Work on the playground code
|
||||
|
||||
Goals:
|
||||
|
||||
- Fix a lot of entity rendering issues (including position updates)
|
||||
- Implement switching camera mode (first person, third person, etc)
|
||||
- Animated blocks
|
||||
- Armor rendering
|
||||
- ...
|
||||
|
||||
Note:
|
||||
|
||||
- It's useful to know how to use helpers & additional cameras (e.g. setScissor)
|
||||
|
||||
## 3. Server-side Logic
|
||||
|
||||
Flying squid fork (space-squid).
|
||||
Example tasks:
|
||||
|
||||
- Add missing commands (e.g. /scoreboard)
|
||||
- Basic physics (player fall damage, falling blocks & entities)
|
||||
- Basic entities AI (spawning, attacking)
|
||||
- Pvp
|
||||
- Emit more packets on some specific events (e.g. when a player uses an item)
|
||||
- Make more maps playable (e.g. fix when something is not implemented in both server and client and blocking map interaction)
|
||||
- ...
|
||||
|
||||
Long Term Goals:
|
||||
|
||||
- Make most adventure maps playable
|
||||
- Make a way to complete the game from the scratch (crafting, different dimensions, terrain generation, etc)
|
||||
- Make bedwars playable!
|
||||
Most of the tasks are straightforward to implement, just be sure to use a debugger ;). If you feel you are stuck, ask for help on Discord. Absolutely any tests / refactor suggestions are welcome!
|
||||
|
||||
## 4. Frontend
|
||||
|
||||
New React components, improve UI (including mobile support).
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Locate the problem on the public test server & make an easily reproducible environment (you can also use local packets replay server or your custom server setup). Dm me for details on public test server / replay server
|
||||
2. Debug the code, find an issue in the code, isolate the problem
|
||||
3. Develop, try to fix and test. Finally we should find a way to fix it. It's ideal to have an automatic test but it's not necessary for now
|
||||
3. Repeat step 1 to make sure the task is done and the problem is fixed (or the feature is implemented)
|
||||
|
||||
## Updating Dependencies
|
||||
|
||||
1. Use `pnpm update-git-deps` to check and update git dependencies (like mineflayer fork, prismarine packages etc). The script will:
|
||||
- Show which git dependencies have updates available
|
||||
- Ask if you want to update them
|
||||
- Skip dependencies listed in `pnpm.updateConfig.ignoreDependencies`
|
||||
|
||||
2. Update PrismarineJS dependencies to the latest version: `minecraft-data` (be sure to replace the version twice in the package.json), `mineflayer`, `minecraft-protocol`, `prismarine-block`, `prismarine-chunk`, `prismarine-item`, ...
|
||||
|
||||
3. If `minecraft-protocol` patch fails, do this:
|
||||
1. Remove the patch from `patchedDependencies` in `package.json`
|
||||
2. Run `pnpm patch minecraft-protocol`, open patch directory
|
||||
3. Apply the patch manually in this directory: `patch -p1 < minecraft-protocol@<version>.patch`
|
||||
4. Run the suggested command from `pnpm patch ...` (previous step) to update the patch
|
||||
|
||||
### Would be useful to have
|
||||
|
||||
- cleanup folder & modules structure, cleanup playground code
|
||||
43
Dockerfile
|
|
@ -1,43 +0,0 @@
|
|||
# ---- Build Stage ----
|
||||
FROM node:18-alpine AS build
|
||||
# Without git installing the npm packages fails
|
||||
RUN apk add git
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
# install pnpm with corepack
|
||||
RUN corepack enable
|
||||
# Build arguments
|
||||
ARG DOWNLOAD_SOUNDS=false
|
||||
ARG DISABLE_SERVICE_WORKER=false
|
||||
ARG CONFIG_JSON_SOURCE=REMOTE
|
||||
# TODO need flat --no-root-optional
|
||||
RUN node ./scripts/dockerPrepare.mjs
|
||||
RUN pnpm i
|
||||
# Download sounds if flag is enabled
|
||||
RUN if [ "$DOWNLOAD_SOUNDS" = "true" ] ; then node scripts/downloadSoundsMap.mjs ; fi
|
||||
|
||||
# TODO for development
|
||||
# EXPOSE 9090
|
||||
# VOLUME /app/src
|
||||
# VOLUME /app/renderer
|
||||
# ENTRYPOINT ["pnpm", "run", "run-all"]
|
||||
|
||||
# only for prod
|
||||
RUN DISABLE_SERVICE_WORKER=$DISABLE_SERVICE_WORKER \
|
||||
CONFIG_JSON_SOURCE=$CONFIG_JSON_SOURCE \
|
||||
pnpm run build
|
||||
|
||||
# ---- Run Stage ----
|
||||
FROM node:18-alpine
|
||||
RUN apk add git
|
||||
WORKDIR /app
|
||||
# Copy build artifacts from the build stage
|
||||
COPY --from=build /app/dist /app/dist
|
||||
COPY server.js /app/server.js
|
||||
# Install express
|
||||
RUN npm i -g pnpm@10.8.0
|
||||
RUN npm init -yp
|
||||
RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors
|
||||
EXPOSE 8080
|
||||
VOLUME /app/public
|
||||
ENTRYPOINT ["node", "server.js", "--prod"]
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# ---- Run Stage ----
|
||||
FROM node:18-alpine
|
||||
RUN apk add git
|
||||
WORKDIR /app
|
||||
COPY server.js /app/server.js
|
||||
# Install server dependencies
|
||||
RUN npm i -g pnpm@9.0.4
|
||||
RUN npm init -yp
|
||||
RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["node", "server.js"]
|
||||
21
LICENSE
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 PrismarineJS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
238
README.MD
|
|
@ -1,238 +0,0 @@
|
|||
# Minecraft Web Client
|
||||
|
||||

|
||||
|
||||
Minecraft **clone** rewritten in TypeScript using the best modern web technologies. Minecraft vanilla-compatible client and integrated server packaged into a single web app.
|
||||
|
||||
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 default (`develop`) branch is deployed to [s.mcraft.fun](https://s.mcraft.fun/) and [s.pcm.gg](https://s.pcm.gg/) - so it's usually newer, but might be less stable.
|
||||
|
||||
> For Turkey/Russia use [ru.mcraft.fun](https://ru.mcraft.fun/) (since Cloudflare is blocked)
|
||||
|
||||
Don't confuse with [Eaglercraft](https://git.eaglercraft.rip/eaglercraft/eaglercraft-1.8) which is a REAL vanilla Minecraft Java edition port to the web (but with its own limitations). Eaglercraft is a fully playable solution, meanwhile this project is aimed for *device-compatiiblity* and better performance so it feels portable, flexible and lightweight. It's also a very strong example on how to build true HTML games for the web at scale entirely with the JS ecosystem. Have fun!
|
||||
|
||||
For building the project yourself / contributing, see [Development, Debugging & Contributing](#development-debugging--contributing). For reference at what and how web technologies / frameworks are used, see [TECH.md](./TECH.md) (also for comparison with Eaglercraft).
|
||||
|
||||
> **Note**: You can deploy it on your own server in less than a minute using a one-liner script from [Minecraft Everywhere repo](https://github.com/zardoy/minecraft-everywhere)
|
||||
|
||||
### Big Features
|
||||
|
||||
- Official Mineflayer [plugin integration](https://github.com/zardoy/mcraft-fun-mineflayer-plugin)! View / Control your bot remotely.
|
||||
- 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)
|
||||
- Integrated JS server clone capable of opening Java world saves in any way (folders, zip, web chunks streaming, etc)
|
||||
- Singleplayer mode with simple world generations!
|
||||
- Works offline
|
||||
- First-class touch (mobile) & controller support
|
||||
- First-class keybindings configuration
|
||||
- Advanced Resource pack support: Custom GUI, all textures. Server resource packs are supported with proper CORS configuration.
|
||||
- Builtin JEI with recipes & descriptions for almost every item (JEI is creative inventory replacement)
|
||||
- Custom protocol channel extensions (eg for custom block models in the world)
|
||||
- Play with friends over internet! (P2P is powered by Peer.js discovery servers)
|
||||
- ~~Google Drive support for reading / saving worlds back to the cloud~~
|
||||
- Support for custom rendering 3D engines. Modular architecture.
|
||||
- even even more!
|
||||
|
||||
All components that are in [Storybook](https://minimap.mcraft.fun/storybook/) are published as npm module and can be used in other projects: [`minecraft-react`](https://npmjs.com/minecraft-react)
|
||||
|
||||
### Recommended Settings
|
||||
|
||||
- Controls -> **Touch Controls Type** -> **Joystick**
|
||||
- Controls -> **Auto Full Screen** -> **On** - To avoid ctrl+w issue
|
||||
- Interface -> **Enable Minimap** -> **Always** - To enable useful minimap (why not?)
|
||||
- Controls -> **Raw Input** -> **On** - This will make the controls more precise (UPD: already enabled by default)
|
||||
- Interface -> **Chat Select** -> **On** - To select chat messages (UPD: already enabled by default)
|
||||
|
||||
### Browser Notes
|
||||
|
||||
This project is tested with BrowserStack. Special thanks to [BrowserStack](https://www.browserstack.com/) for providing testing infrastructure!
|
||||
|
||||
Howerver, it's known that these browsers have issues:
|
||||
|
||||
**Opera Mini**: Disable *mouse gestures* in browsre settings to avoid opening new tab on right click hold
|
||||
|
||||
**Vivaldi**: Disable Controls -> *Raw Input* in game settings if experiencing issues
|
||||
|
||||
### Versions Support
|
||||
|
||||
Server versions 1.8 - 1.21.5 are supported.
|
||||
First class versions (most of the features are tested on these versions):
|
||||
|
||||
- 1.19.4
|
||||
- 1.21.4
|
||||
|
||||
Versions below 1.13 are not tested currently and may not work correctly.
|
||||
|
||||
### 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.
|
||||
|
||||

|
||||
|
||||
### Servers & Proxy
|
||||
|
||||
You can play almost on any Java server, vanilla servers are fully supported.
|
||||
See the [Mineflayer](https://github.com/PrismarineJS/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. Or you can deploy it to the cloud service:
|
||||
|
||||
[](https://app.koyeb.com/deploy?name=minecraft-web-client&type=git&repository=zardoy%2Fminecraft-web-client&branch=next&builder=dockerfile&env%5B%5D=&ports=8080%3Bhttp%3B%2F)
|
||||
|
||||
> **Note**: If you want to make **your own** Minecraft server accessible to web clients (without our proxies), you can use [mwc-proxy](https://github.com/zardoy/mwc-proxy) - a lightweight JS WebSocket proxy that runs on the same server as your Minecraft server, allowing players to connect directly via `wss://play.example.com`. `?client_mcraft` is added to the URL, so the proxy will know that it's this client.
|
||||
|
||||
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.
|
||||
|
||||
```mermaid
|
||||
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](./Dockerfile) - for production build & offline/private usage. Includes full web-app + proxy server for connecting to Minecraft servers.
|
||||
- [Proxy Dockerfile](./Dockerfile.proxy) - 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](./CONTRIBUTING.md) for more info. Also you can look at Dockerfile for reference.
|
||||
|
||||
There is world renderer playground ([link](https://mcon.vercel.app/playground/)).
|
||||
|
||||
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:
|
||||
|
||||
- If you type `debugToggle`, press enter in console - It will 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.
|
||||
- `world` - Three.js world instance, basically does all the rendering (part of renderer backend).
|
||||
- `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.
|
||||
- `localServer.levelData.LevelName = 'test'; localServer.writeLevelDat()` - Change name of the world
|
||||
|
||||
- `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 `world.getCameraPosition()` to see the camera position and so on.
|
||||
|
||||
<img src="./docs-assets/watch-expr.png" alt="Watch expression" width="480"/>
|
||||
|
||||
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 + N` - Restart local server (basically resets the world!) -->
|
||||
- `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:
|
||||
|
||||
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`
|
||||
- `?modal=<modal>` - Open specific modal on page load eg `keybindings`. Very useful on UI changes testing during dev. For path use `,` as separator. To get currently opened modal type this in the console: `activeModalStack.at(-1).reactType`
|
||||
- `?replayFileUrl=<url>` - Load and start a packet replay session from a URL with a integrated server. For debugging / previewing recorded sessions. The file must be CORS enabled.
|
||||
|
||||
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.
|
||||
- `?autoConnect=true` - Only works then `ip` and `version` parameters are set and `allowAutoConnect` is `true` in config.json! Directly connects to the specified server. Useful for integrates iframes.
|
||||
- `?serversList=<list_or_url>` - `<list_or_url>` can be a list of servers in the format `ip:version,ip` or a url to a json file with the same format (array) or a txt file with line-delimited list of server IPs.
|
||||
- `?addPing=<ping>` - Add a latency to both sides of the connection. Useful for testing ping issues. For example `?addPing=100` will add 200ms to your ping.
|
||||
|
||||
Single player specific:
|
||||
|
||||
- `?loadSave=<save_name>` - Load the save on load with the specified folder name (not title)
|
||||
- `?singleplayer=1` or `?sp=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.
|
||||
- `?serverSetting=<key>:<value>` - Set local server [options](https://github.com/zardoy/space-squid/tree/everything/src/modules.ts#L51). For example `?serverSetting=noInitialChunksSend:true` will disable initial chunks loading on the loading screen.
|
||||
- `?map=<map_url>` - Load the map from ZIP. You can use any url, but it must be **CORS enabled**.
|
||||
- `?mapDir=<index_file_url>` - Load the map from a file descriptor. It's recommended and the fastest way to load world but requires additional setup. The file must be in the following format:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "<url>",
|
||||
"index": {
|
||||
"level.dat": null,
|
||||
"region": {
|
||||
"r.-1.-1.mca": null,
|
||||
"r.-1.0.mca": null,
|
||||
"r.0.-1.mca": null,
|
||||
"r.0.0.mca": null,
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note that `mapDir` also accepts base64 encoded JSON like so:
|
||||
`?mapDir=data:application/json;base64,...` where `...` is the base64 encoded JSON of the index file.
|
||||
In this case you must use `?mapDirBaseUrl` to specify the base URL to fetch the files from index.
|
||||
|
||||
- `?mapDirBaseUrl` - See above.
|
||||
|
||||
Only during development:
|
||||
|
||||
- `?reconnect=true` - Reconnect to the server on page reloads. Very useful on server testing.
|
||||
|
||||
<!-- - `?mapDirGuess=<base_url>` - Load the map from the provided URL and paths will be guessed with a few additional fetch requests. -->
|
||||
|
||||
### Notable Things that Power this Project
|
||||
|
||||
- [Mineflayer](https://github.com/PrismarineJS/mineflayer) - Handles all client-side communications with the server (including the builtin one) - forked
|
||||
- [Forked Flying Squid (Space Squid)](https://github.com/zardoy/space-squid) - The builtin offline server that makes single player & P2P possible!
|
||||
- [Prismarine Provider Anvil](https://github.com/PrismarineJS/prismarine-provider-anvil) - Handles world loading (region format)
|
||||
- [Prismarine Physics](https://github.com/PrismarineJS/prismarine-physics) - Does all the physics calculations
|
||||
- [Minecraft Protocol](https://github.com/PrismarineJS/node-minecraft-protocol) - Makes connections to servers possible
|
||||
- [Peer.js](https://peerjs.com/) - P2P networking (when you open to wan)
|
||||
- [Three.js](https://threejs.org/) - Helping in 3D rendering
|
||||
|
||||
### Things that are not planned yet
|
||||
|
||||
- Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines
|
||||
|
||||
### Alternatives
|
||||
|
||||
- [https://github.com/ClassiCube/ClassiCube](ClassiCube - Better C# Rewrite) [DEMO](https://www.classicube.net/server/play/?warned=true)
|
||||
- [https://m.eaglercraft.com/](EaglerCraft) - Eaglercraft runnable on mobile (real Minecraft in the browser)
|
||||
- [js-minecraft](https://github.com/LabyStudio/js-minecraft) - An insanely well done clone from the graphical side that inspired many features here
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# Minecraft React
|
||||
|
||||
Minecraft UI components for React extracted from [mcraft.fun](https://mcraft.fun) project.
|
||||
|
||||
```bash
|
||||
pnpm i minecraft-react
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
```jsx
|
||||
import { Scoreboard } from 'minecraft-react'
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<Scoreboard
|
||||
open
|
||||
title="Scoreboard"
|
||||
items={[
|
||||
{ name: 'Player 1', value: 10 },
|
||||
{ name: 'Player 2', value: 20 },
|
||||
{ name: 'Player 3', value: 30 },
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
See [Storybook](https://mcraft.fun/storybook/) or [Storybook (Mirror link)](https://mcon.vercel.app/storybook/) for more examples and full components list. Also take a look at the full [standalone example](https://github.com/zardoy/minecraft-web-client/tree/experiments/UiStandaloneExample.tsx).
|
||||
|
||||
There are two types of components:
|
||||
|
||||
- Small UI components or HUD components
|
||||
- Full screen components (like sign editor, worlds selector)
|
||||
58
TECH.md
|
|
@ -1,58 +0,0 @@
|
|||
### Eaglercraft Comparison
|
||||
|
||||
This project uses proxies so you can connect to almost any vanilla server. Though proxies have some limitations such as increased latency and servers will complain about using VPN (though we have a workaround for that, but ping will be much higher).
|
||||
This client generally has better performance but some features reproduction might be inaccurate eg its less stable and more buggy in some cases.
|
||||
|
||||
| Feature | This project | Eaglercraft | Description |
|
||||
| --------------------------------- | ----------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| General | | | |
|
||||
| Mobile Support (touch) | ✅(+) | ✅ | |
|
||||
| Gamepad Support | ✅ | ❌ | |
|
||||
| A11Y | ✅ | ❌ | We have DOM for almost all UI so your extensions and other browser features will work natively like on any other web page (but maybe it's not needed) |
|
||||
| Game Features | | | |
|
||||
| Servers Support (quality) | ❌(+) | ✅ | Eaglercraft is vanilla Minecraft, while this project tries to emulate original game behavior at protocol level (Mineflayer is used) |
|
||||
| Servers Support (any version, ip) | ✅ | ❌ | We support almost all Minecraft versions, only important if you connect to a server where you need new content like blocks or if you play with friends. And you can connect to almost any server using proxy servers! |
|
||||
| Servers Support (online mode) | ✅ | ❌ | Join to online servers like Hypixel using your Microsoft account without additional proxies |
|
||||
| Singleplayer Survival Features | ❌ | ✅ | Just like Eaglercraft this project can generate and save worlds, but generator is simple and only a few survival features are supported (look here for [supported features list](https://github.com/zardoy/space-squid)) |
|
||||
| Singleplayer Maps | ✅ | ✅ | We support any version, but adventure maps won't work, but simple parkour and build maps might be interesting to explore... |
|
||||
| Singleplayer Maps World Streaming | ✅ | ❌ | Thanks to Browserfs, saves can be loaded to local singleplayer server using multiple ways: from local folder, server directory (not zip), dropbox or other cloud *backend* etc... |
|
||||
| P2P Multiplayer | ✅ | ✅ | A way to connect to other browser running the project. But it's almost useless here since many survival features are not implemented. Maybe only to build / explore maps together... |
|
||||
| Voice Chat | ❌(+) | ✅ | Eaglercraft has custom WebRTC voice chat implementation, though it could also be easily implemented there |
|
||||
| Online Servers | ✅ | ❌ | We have custom implementation (including integration on proxy side) for joining to servers |
|
||||
| Plugin Features | ✅ | ❌ | We have Mineflayer plugins support, like Auto Jump & Auto Parkour was added here that way |
|
||||
| Direct Connection | ✅ | ✅ | We have DOM for almost all UI so your extensions and other browser features will work natively like on any other web page |
|
||||
| Moding | ✅(own js mods) | ❌ | This project will support mods for singleplayer. In theory its possible to implement support for modded servers on protocol level (including all needed mods) |
|
||||
| Video Recording | ❌ | ✅ | Doesn't feel needed |
|
||||
| Metaverse Features | ✅(50%) | ❌ | We have videos / images support inside world, but not iframes (custom protocol channel) |
|
||||
| Sounds | ✅ | ✅ | |
|
||||
| Resource Packs | ✅(+extras) | ✅ | This project has very limited support for them (only textures images are loadable for now) |
|
||||
| Assets Compressing & Splitting | ✅ | ❌ | We have advanced Minecraft data processing and good code chunk splitting so the web app will open much faster and use less memory |
|
||||
| Graphics | | | |
|
||||
| Fancy Graphics | ❌ | ✅ | While Eaglercraft has top-level shaders we don't even support lighting |
|
||||
| Fast & Efficient Graphics | ❌(+) | ❌ | Feels like no one needs to have 64 rendering distance work smoothly |
|
||||
| VR | ✅(-) | ❌ | Feels like not needed feature. UI is missing in this project since DOM can't be rendered in VR so Eaglercraft could be better in that aspect |
|
||||
| AR | ❌ | ❌ | Would be the most useless feature |
|
||||
| Minimap & Waypoints | ✅(-) | ❌ | We have buggy minimap, which can be enabled in settings and full map is opened by pressing `M` key |
|
||||
|
||||
Features available to only this project:
|
||||
|
||||
- CSS & JS Customization
|
||||
- JS Real Time Debugging & Console Scripting (eg Devtools)
|
||||
|
||||
### Tech Stack
|
||||
|
||||
Bundler: Rsbuild!
|
||||
UI: powered by React and css modules. Storybook helps with UI development.
|
||||
|
||||
### Rare WEB Features
|
||||
|
||||
There are a number of web features that are not commonly used but you might be interested in them if you decide to build your own game in the web.
|
||||
|
||||
TODO
|
||||
|
||||
| API | Usage & Description |
|
||||
| ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `Crypto` API | Used to make chat features work when joining online servers with authentication. |
|
||||
| `requestPointerLock({ unadjustedMovement: true })` API | Required for games. Disables system mouse acceleration (important for Mac users). Aka mouse raw input |
|
||||
| `navigator.keyboard.lock()` | (only in Chromium browsers) When entering fullscreen it allows to use any key combination like ctrl+w in the game |
|
||||
| `navigator.keyboard.getLayoutMap()` | (only in Chromium browsers) To display the right keyboard symbol for the key keybinding on different keyboard layouts (e.g. QWERTY vs AZERTY) |
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
here you can place custom textures for bundled files (blocks/items) e.g. blocks/stone.png
|
||||
get file names from here (blocks/items) https://zardoy.github.io/mc-assets/
|
||||
|
Before Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 115 B |
|
Before Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 145 B |
|
Before Width: | Height: | Size: 155 B |
|
Before Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 190 B |
|
Before Width: | Height: | Size: 211 B |
|
Before Width: | Height: | Size: 218 B |
|
Before Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 513 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
BIN
assets/gui.png
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 859 KiB After Width: | Height: | Size: 859 KiB |
|
Before Width: | Height: | Size: 952 KiB After Width: | Height: | Size: 952 KiB |
|
Before Width: | Height: | Size: 704 KiB After Width: | Height: | Size: 704 KiB |
|
Before Width: | Height: | Size: 684 KiB After Width: | Height: | Size: 684 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
80
config.json
|
|
@ -1,80 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"defaultHost": "<from-proxy>",
|
||||
"defaultProxy": "https://proxy.mcraft.fun",
|
||||
"mapsProvider": "https://maps.mcraft.fun/",
|
||||
"skinTexturesProxy": "",
|
||||
"peerJsServer": "",
|
||||
"peerJsServerFallback": "https://p2p.mcraft.fun",
|
||||
"promoteServers": [
|
||||
{
|
||||
"ip": "wss://play.mcraft.fun"
|
||||
},
|
||||
{
|
||||
"ip": "wss://play.webmc.fun",
|
||||
"name": "WebMC"
|
||||
},
|
||||
{
|
||||
"ip": "wss://ws.fuchsmc.net"
|
||||
},
|
||||
{
|
||||
"ip": "wss://play2.mcraft.fun"
|
||||
},
|
||||
{
|
||||
"ip": "wss://play-creative.mcraft.fun",
|
||||
"description": "Might be available soon, stay tuned!"
|
||||
},
|
||||
{
|
||||
"ip": "kaboom.pw",
|
||||
"version": "1.20.3",
|
||||
"description": "Very nice a polite server. Must try for everyone!"
|
||||
}
|
||||
],
|
||||
"rightSideText": "A Minecraft client clone in the browser!",
|
||||
"splashText": "The sunset is coming!",
|
||||
"splashTextFallback": "Welcome!",
|
||||
"pauseLinks": [
|
||||
[
|
||||
{
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"type": "discord"
|
||||
}
|
||||
]
|
||||
],
|
||||
"defaultUsername": "mcrafter{0-9999}",
|
||||
"mobileButtons": [
|
||||
{
|
||||
"action": "general.drop",
|
||||
"actionHold": "general.dropStack",
|
||||
"label": "Q"
|
||||
},
|
||||
{
|
||||
"action": "general.selectItem",
|
||||
"actionHold": "",
|
||||
"label": "S"
|
||||
},
|
||||
{
|
||||
"action": "general.debugOverlay",
|
||||
"actionHold": "general.debugOverlayHelpMenu",
|
||||
"label": "F3"
|
||||
},
|
||||
{
|
||||
"action": "general.playersList",
|
||||
"actionHold": "",
|
||||
"icon": "pixelarticons:users",
|
||||
"label": "TAB"
|
||||
},
|
||||
{
|
||||
"action": "general.chat",
|
||||
"actionHold": "",
|
||||
"label": ""
|
||||
},
|
||||
{
|
||||
"action": "ui.pauseMenu",
|
||||
"actionHold": "",
|
||||
"label": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"alwaysReconnectButton": true,
|
||||
"reportBugButtonWithReconnect": true,
|
||||
"allowAutoConnect": true
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import { defineConfig } from 'cypress'
|
||||
|
||||
const isPerformanceTest = process.env.PERFORMANCE_TEST === 'true'
|
||||
|
||||
export default defineConfig({
|
||||
video: false,
|
||||
chromeWebSecurity: false,
|
||||
screenshotOnRunFailure: true, // Enable screenshots on test failures
|
||||
e2e: {
|
||||
// We've imported your old cypress plugins here.
|
||||
// You may want to clean this up later by importing these.
|
||||
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',
|
||||
specPattern: !isPerformanceTest ? 'cypress/e2e/smoke.spec.ts' : 'cypress/e2e/rendering_performance.spec.ts',
|
||||
excludeSpecPattern: ['**/__snapshots__/*', '**/__image_snapshots__/*'],
|
||||
},
|
||||
})
|
||||
2
cypress/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
screenshots
|
||||
fixtures
|
||||
|
Before Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
|
@ -1,32 +0,0 @@
|
|||
/// <reference types="cypress" />
|
||||
import { BenchmarkAdapterInfo, getAllInfoLines } from '../../src/benchmarkAdapter'
|
||||
import { cleanVisit } from './shared'
|
||||
|
||||
it('Benchmark rendering performance', () => {
|
||||
cleanVisit('/?openBenchmark=true&renderDistance=5')
|
||||
// wait for render end event
|
||||
return cy.document().then({ timeout: 180_000 }, doc => {
|
||||
return new Cypress.Promise(resolve => {
|
||||
cy.log('Waiting for world to load')
|
||||
doc.addEventListener('cypress-world-ready', resolve)
|
||||
}).then(() => {
|
||||
cy.log('World loaded')
|
||||
})
|
||||
}).then(() => {
|
||||
cy.window().then(win => {
|
||||
const adapter = win.benchmarkAdapter as BenchmarkAdapterInfo
|
||||
|
||||
const messages = getAllInfoLines(adapter)
|
||||
// wait for 10 seconds
|
||||
cy.wait(10_000)
|
||||
const messages2 = getAllInfoLines(adapter, true)
|
||||
for (const message of messages) {
|
||||
cy.log(message)
|
||||
}
|
||||
for (const message of messages2) {
|
||||
cy.log(message)
|
||||
}
|
||||
cy.writeFile('benchmark.txt', [...messages, ...messages2].join('\n'))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import { AppOptions } from '../../src/optionsStorage'
|
||||
|
||||
export const cleanVisit = (url?) => {
|
||||
cy.clearLocalStorage()
|
||||
visit(url)
|
||||
window.localStorage.options = {
|
||||
chatOpacity: 0
|
||||
}
|
||||
}
|
||||
export const visit = (url = '/') => {
|
||||
window.localStorage.cypress = 'true'
|
||||
cy.visit(url)
|
||||
}
|
||||
export const setOptions = (options: Partial<AppOptions>) => {
|
||||
cy.window().then(win => {
|
||||
Object.assign(win['options'], options)
|
||||
})
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/* eslint-disable max-nested-callbacks */
|
||||
/// <reference types="cypress" />
|
||||
import supportedVersions from '../../src/supportedVersions.mjs'
|
||||
import { setOptions, cleanVisit, visit } from './shared'
|
||||
|
||||
// todo use ssl
|
||||
|
||||
const compareRenderedFlatWorld = () => {
|
||||
// wait for render
|
||||
// cy.wait(6000)
|
||||
// cy.get('body').toMatchImageSnapshot({
|
||||
// name: 'superflat-world',
|
||||
// })
|
||||
}
|
||||
|
||||
const testWorldLoad = () => {
|
||||
return cy.document().then({ timeout: 35_000 }, doc => {
|
||||
return new Cypress.Promise(resolve => {
|
||||
doc.addEventListener('cypress-world-ready', resolve)
|
||||
})
|
||||
}).then(() => {
|
||||
compareRenderedFlatWorld()
|
||||
})
|
||||
}
|
||||
|
||||
it('Loads & renders singleplayer', () => {
|
||||
cleanVisit('/?singleplayer=1')
|
||||
setOptions({
|
||||
localServerOptions: {
|
||||
generation: {
|
||||
name: 'superflat',
|
||||
// eslint-disable-next-line unicorn/numeric-separators-style
|
||||
options: { seed: 250869072 }
|
||||
},
|
||||
},
|
||||
renderDistance: 2
|
||||
})
|
||||
testWorldLoad()
|
||||
})
|
||||
|
||||
it.skip('Joins to local flying-squid server', () => {
|
||||
visit('/?ip=localhost&version=1.16.1')
|
||||
window.localStorage.version = ''
|
||||
// todo replace with data-test
|
||||
// cy.get('[data-test-id="servers-screen-button"]').click()
|
||||
// cy.get('[data-test-id="server-ip"]').clear().focus().type('localhost')
|
||||
// cy.get('[data-test-id="version"]').clear().focus().type('1.16.1') // todo needs to fix autoversion
|
||||
cy.get('[data-test-id="connect-qs"]').click() // todo! cypress sometimes doesn't click
|
||||
testWorldLoad()
|
||||
})
|
||||
|
||||
it.skip('Joins to local latest Java vanilla server', () => {
|
||||
const version = supportedVersions.at(-1)!
|
||||
cy.task('startServer', [version, 25_590]).then(() => {
|
||||
visit('/?ip=localhost:25590&username=bot')
|
||||
cy.get('[data-test-id="connect-qs"]').click()
|
||||
testWorldLoad().then(() => {
|
||||
let x = 0
|
||||
let z = 0
|
||||
cy.window().then((win) => {
|
||||
x = win.bot.entity.position.x
|
||||
z = win.bot.entity.position.z
|
||||
})
|
||||
cy.document().trigger('keydown', { code: 'KeyW' })
|
||||
cy.wait(1500).then(() => {
|
||||
cy.document().trigger('keyup', { code: 'KeyW' })
|
||||
cy.window().then(async (win) => {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
const bot: typeof __type_bot = win.bot
|
||||
// todo use f3 stats instead
|
||||
if (bot.entity.position.x === x && bot.entity.position.z === z) {
|
||||
throw new Error('Player not moved')
|
||||
}
|
||||
|
||||
bot.chat('Hello') // todo assert
|
||||
bot.chat('/gamemode creative')
|
||||
// bot.on('message', () => {
|
||||
void bot.creative.setInventorySlot(bot.inventory.hotbarStart, new win.PrismarineItem(1, 1, 0))
|
||||
// })
|
||||
await bot.lookAt(bot.entity.position.offset(1, 0, 1))
|
||||
}).then(() => {
|
||||
cy.document().trigger('mousedown', { button: 2, isTrusted: true, force: true }) // right click
|
||||
cy.document().trigger('mouseup', { button: 2, isTrusted: true, force: true })
|
||||
cy.wait(1000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('Loads & renders zip world', () => {
|
||||
cleanVisit()
|
||||
cy.get('[data-test-id="select-file-folder"]').click({ shiftKey: true })
|
||||
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true })
|
||||
testWorldLoad()
|
||||
})
|
||||
|
||||
|
||||
it.skip('Loads & renders world from folder', () => {
|
||||
cleanVisit()
|
||||
// dragndrop folder
|
||||
cy.get('[data-test-id="select-file-folder"]').click()
|
||||
cy.get('input[type="file"]').selectFile('server-jar/world', {
|
||||
force: true,
|
||||
// action: 'drag-drop',
|
||||
})
|
||||
testWorldLoad()
|
||||
})
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
//@ts-check
|
||||
import mcServer from 'flying-squid'
|
||||
import defaultOptions from 'flying-squid/config/default-settings.json' with { type: 'json' }
|
||||
|
||||
/** @type {Options} */
|
||||
const serverOptions = {
|
||||
...defaultOptions,
|
||||
'online-mode': false,
|
||||
'logging': false,
|
||||
'gameMode': 0,
|
||||
'difficulty': 0,
|
||||
'worldFolder': undefined,
|
||||
// todo set sid, disable entities auto-spawn
|
||||
'generation': {
|
||||
'name': 'superflat',
|
||||
options: {}
|
||||
// 'options': {
|
||||
// 'worldHeight': 80
|
||||
// }
|
||||
},
|
||||
'modpe': false,
|
||||
'view-distance': 4,
|
||||
'everybody-op': true,
|
||||
'version': '1.16.1'
|
||||
}
|
||||
const server = mcServer.createMCServer(serverOptions)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
//@ts-check
|
||||
const { cypressEsbuildPreprocessor } = require('cypress-esbuild-preprocessor')
|
||||
const { initPlugin } = require('cypress-plugin-snapshots/plugin')
|
||||
const polyfill = require('esbuild-plugin-polyfill-node')
|
||||
const { startMinecraftServer } = require('./startServer')
|
||||
|
||||
module.exports = (on, config) => {
|
||||
initPlugin(on, config)
|
||||
on('file:preprocessor', cypressEsbuildPreprocessor({
|
||||
esbuildOptions: {
|
||||
sourcemap: true,
|
||||
plugins: [
|
||||
polyfill.polyfillNode({
|
||||
polyfills: {
|
||||
crypto: true,
|
||||
},
|
||||
})
|
||||
],
|
||||
},
|
||||
}))
|
||||
on('task', {
|
||||
log(message) {
|
||||
console.log(message)
|
||||
return null
|
||||
},
|
||||
})
|
||||
on('task', {
|
||||
async startServer([version, port]) {
|
||||
return startMinecraftServer(version, port)
|
||||
}
|
||||
})
|
||||
return config
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[
|
||||
{
|
||||
"uuid": "67128b5b-2e6b-3ad1-baa0-1b937b03e5c5",
|
||||
"name": "bot",
|
||||
"level": 4,
|
||||
"bypassesPlayerLimit": false
|
||||
}
|
||||
]
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#Minecraft server properties
|
||||
allow-flight=false
|
||||
allow-nether=true
|
||||
broadcast-console-to-ops=true
|
||||
broadcast-rcon-to-ops=true
|
||||
difficulty=peaceful
|
||||
enable-command-block=false
|
||||
enable-jmx-monitoring=false
|
||||
enable-query=false
|
||||
enable-rcon=false
|
||||
enable-status=true
|
||||
enforce-secure-profile=true
|
||||
enforce-whitelist=false
|
||||
entity-broadcast-range-percentage=100
|
||||
force-gamemode=false
|
||||
function-permission-level=2
|
||||
gamemode=survival
|
||||
generate-structures=true
|
||||
generator-settings={}
|
||||
hardcore=false
|
||||
hide-online-players=false
|
||||
initial-disabled-packs=
|
||||
initial-enabled-packs=vanilla
|
||||
level-name=world
|
||||
level-seed=
|
||||
level-type=flat
|
||||
log-ips=true
|
||||
max-build-height=256
|
||||
max-chained-neighbor-updates=1000000
|
||||
max-players=20
|
||||
max-tick-time=60000
|
||||
max-world-size=29999984
|
||||
motd=A Minecraft Server
|
||||
network-compression-threshold=256
|
||||
online-mode=false
|
||||
op-permission-level=4
|
||||
player-idle-timeout=0
|
||||
prevent-proxy-connections=false
|
||||
pvp=true
|
||||
query.port=25565
|
||||
rate-limit=0
|
||||
rcon.password=
|
||||
rcon.port=25575
|
||||
require-resource-pack=false
|
||||
resource-pack=
|
||||
resource-pack-id=
|
||||
resource-pack-prompt=
|
||||
resource-pack-sha1=
|
||||
server-ip=
|
||||
server-port=25565
|
||||
simulation-distance=10
|
||||
snooper-enabled=true
|
||||
spawn-animals=true
|
||||
spawn-monsters=true
|
||||
spawn-npcs=true
|
||||
spawn-protection=16
|
||||
sync-chunk-writes=true
|
||||
text-filtering-config=
|
||||
use-native-transport=true
|
||||
view-distance=10
|
||||
white-list=false
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
import { ChildProcess, spawn } from 'child_process'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { promisify } from 'util'
|
||||
import { downloadServer } from 'minecraft-wrap'
|
||||
import * as waitOn from 'wait-on'
|
||||
|
||||
let prevProcess: ChildProcess | null = null
|
||||
export const startMinecraftServer = async (version: string, port: number) => {
|
||||
if (prevProcess) return null
|
||||
const jar = `./server-jar/${version}.jar`
|
||||
|
||||
const start = () => {
|
||||
// if (prevProcess) {
|
||||
// prevProcess.kill()
|
||||
// }
|
||||
|
||||
prevProcess = spawn('java', ['-jar', path.basename(jar), 'nogui', '--port', `${port}`], {
|
||||
stdio: 'inherit',
|
||||
cwd: path.dirname(jar),
|
||||
})
|
||||
}
|
||||
|
||||
let coldStart = false
|
||||
if (fs.existsSync(jar)) {
|
||||
start()
|
||||
} else {
|
||||
coldStart = true
|
||||
promisify(downloadServer)(version, jar).then(() => {
|
||||
// add eula.txt
|
||||
fs.writeFileSync(path.join(path.dirname(jar), 'eula.txt'), 'eula=true')
|
||||
// copy cypress/plugins/server.properties
|
||||
fs.copyFileSync(path.join(__dirname, 'server.properties'), path.join(path.dirname(jar), 'server.properties'))
|
||||
// copy ops.json
|
||||
fs.copyFileSync(path.join(__dirname, 'ops.json'), path.join(path.dirname(jar), 'ops.json'))
|
||||
start()
|
||||
})
|
||||
}
|
||||
|
||||
return new Promise<null>((res) => {
|
||||
waitOn({ resources: [`tcp:localhost:${port}`] }, () => {
|
||||
setTimeout(() => res(null), coldStart ? 6500 : 2000) // todo retry instead of timeout
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
import 'cypress-plugin-snapshots/commands'
|
||||
Cypress.Commands.overwrite('log', (_subject, message) => cy.task('log', message))
|
||||
|
Before Width: | Height: | Size: 217 KiB |
|
|
@ -1,169 +0,0 @@
|
|||
# Handled Packets
|
||||
|
||||
## Server -> Client
|
||||
|
||||
❌ statistics
|
||||
❌ advancements
|
||||
❌ face_player
|
||||
❌ nbt_query_response
|
||||
❌ chat_suggestions
|
||||
❌ trade_list
|
||||
❌ vehicle_move
|
||||
❌ open_book
|
||||
❌ craft_recipe_response
|
||||
❌ end_combat_event
|
||||
❌ enter_combat_event
|
||||
❌ unlock_recipes
|
||||
❌ camera
|
||||
❌ update_view_position
|
||||
❌ update_view_distance
|
||||
❌ entity_sound_effect
|
||||
❌ stop_sound
|
||||
❌ feature_flags
|
||||
❌ select_advancement_tab
|
||||
❌ declare_recipes
|
||||
❌ tags
|
||||
❌ acknowledge_player_digging
|
||||
❌ initialize_world_border
|
||||
❌ world_border_center
|
||||
❌ world_border_lerp_size
|
||||
❌ world_border_size
|
||||
❌ world_border_warning_delay
|
||||
❌ world_border_warning_reach
|
||||
❌ simulation_distance
|
||||
❌ chunk_biomes
|
||||
❌ hurt_animation
|
||||
✅ damage_event
|
||||
✅ spawn_entity
|
||||
✅ spawn_entity_experience_orb
|
||||
✅ named_entity_spawn
|
||||
✅ animation
|
||||
✅ block_break_animation
|
||||
✅ tile_entity_data
|
||||
✅ block_action
|
||||
✅ block_change
|
||||
✅ boss_bar
|
||||
✅ difficulty
|
||||
✅ tab_complete
|
||||
✅ declare_commands
|
||||
✅ multi_block_change
|
||||
✅ close_window
|
||||
✅ open_window
|
||||
✅ window_items
|
||||
✅ craft_progress_bar
|
||||
✅ set_slot
|
||||
✅ set_cooldown
|
||||
✅ custom_payload
|
||||
✅ hide_message
|
||||
✅ kick_disconnect
|
||||
✅ profileless_chat
|
||||
✅ entity_status
|
||||
✅ explosion
|
||||
✅ unload_chunk
|
||||
✅ game_state_change
|
||||
✅ open_horse_window
|
||||
✅ keep_alive
|
||||
✅ map_chunk
|
||||
✅ world_event
|
||||
✅ world_particles
|
||||
✅ update_light
|
||||
✅ login
|
||||
✅ map
|
||||
✅ rel_entity_move
|
||||
✅ entity_move_look
|
||||
✅ entity_look
|
||||
✅ open_sign_entity
|
||||
✅ abilities
|
||||
✅ player_chat
|
||||
✅ death_combat_event
|
||||
✅ player_remove
|
||||
✅ player_info
|
||||
✅ position
|
||||
✅ entity_destroy
|
||||
✅ remove_entity_effect
|
||||
✅ resource_pack_send
|
||||
✅ respawn
|
||||
✅ entity_head_rotation
|
||||
✅ held_item_slot
|
||||
✅ scoreboard_display_objective
|
||||
✅ entity_metadata
|
||||
✅ attach_entity
|
||||
✅ entity_velocity
|
||||
✅ entity_equipment
|
||||
✅ experience
|
||||
✅ update_health
|
||||
✅ scoreboard_objective
|
||||
✅ set_passengers
|
||||
✅ teams
|
||||
✅ scoreboard_score
|
||||
✅ spawn_position
|
||||
✅ update_time
|
||||
✅ sound_effect
|
||||
✅ system_chat
|
||||
✅ playerlist_header
|
||||
✅ collect
|
||||
✅ entity_teleport
|
||||
✅ entity_update_attributes
|
||||
✅ entity_effect
|
||||
✅ server_data
|
||||
✅ clear_titles
|
||||
✅ action_bar
|
||||
✅ ping
|
||||
✅ set_title_subtitle
|
||||
✅ set_title_text
|
||||
✅ set_title_time
|
||||
✅ packet
|
||||
|
||||
## Client -> Server
|
||||
|
||||
❌ query_block_nbt
|
||||
❌ set_difficulty
|
||||
❌ query_entity_nbt
|
||||
❌ pick_item
|
||||
❌ set_beacon_effect
|
||||
❌ update_command_block_minecart
|
||||
❌ update_structure_block
|
||||
❌ generate_structure
|
||||
❌ lock_difficulty
|
||||
❌ craft_recipe_request
|
||||
❌ displayed_recipe
|
||||
❌ recipe_book
|
||||
❌ update_jigsaw_block
|
||||
❌ spectate
|
||||
❌ advancement_tab
|
||||
✅ teleport_confirm
|
||||
✅ chat_command
|
||||
✅ chat_message
|
||||
✅ message_acknowledgement
|
||||
✅ edit_book
|
||||
✅ name_item
|
||||
✅ select_trade
|
||||
✅ update_command_block
|
||||
✅ tab_complete
|
||||
✅ client_command
|
||||
✅ settings
|
||||
✅ enchant_item
|
||||
✅ window_click
|
||||
✅ close_window
|
||||
✅ custom_payload
|
||||
✅ use_entity
|
||||
✅ keep_alive
|
||||
✅ position
|
||||
✅ position_look
|
||||
✅ look
|
||||
✅ flying
|
||||
✅ vehicle_move
|
||||
✅ steer_boat
|
||||
✅ abilities
|
||||
✅ block_dig
|
||||
✅ entity_action
|
||||
✅ steer_vehicle
|
||||
✅ resource_pack_receive
|
||||
✅ held_item_slot
|
||||
✅ set_creative_slot
|
||||
✅ update_sign
|
||||
✅ arm_animation
|
||||
✅ block_place
|
||||
✅ use_item
|
||||
✅ pong
|
||||
✅ chat_session_update
|
||||
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 24 KiB |
|
|
@ -1,71 +0,0 @@
|
|||
import React, { useState } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import {
|
||||
Button,
|
||||
Slider,
|
||||
ArmorBar,
|
||||
BreathBar,
|
||||
Chat,
|
||||
HealthBar,
|
||||
PlayerListOverlay,
|
||||
Scoreboard,
|
||||
MessageFormattedString,
|
||||
XPBar,
|
||||
FoodBar
|
||||
} from '../dist-npm'
|
||||
|
||||
const ExampleDemo = () => {
|
||||
const [sliderValue, setSliderValue] = useState(0)
|
||||
|
||||
return (
|
||||
<div style={{ scale: '2', transformOrigin: 'top left', width: '50%', height: '50dvh', fontFamily: 'mojangles, sans-serif', background: 'gray' }}>
|
||||
<Button>Button</Button>
|
||||
<Slider label="Slider" value={sliderValue} updateValue={value => setSliderValue(value)} />
|
||||
<ArmorBar armorValue={10} />
|
||||
<Chat
|
||||
messages={[
|
||||
{ id: 0, parts: [{ text: 'A formmated message in the chat', color: 'blue' }] },
|
||||
{ id: 1, parts: [{ text: 'An other message in the chat', color: 'red' }] },
|
||||
]}
|
||||
usingTouch={false}
|
||||
opened
|
||||
sendMessage={message => {
|
||||
console.log('typed', message)
|
||||
// close
|
||||
}}
|
||||
/>
|
||||
<BreathBar oxygen={10} />
|
||||
<HealthBar isHardcore={false} healthValue={10} damaged={false} />
|
||||
<FoodBar food={10} />
|
||||
<PlayerListOverlay
|
||||
style={{
|
||||
position: 'static',
|
||||
}}
|
||||
clientId="" // needed for current player highlight
|
||||
serverIP="Server IP"
|
||||
tablistHeader="Tab §aHeader"
|
||||
tablistFooter="Tab §bFooter"
|
||||
playersLists={[
|
||||
[
|
||||
{ username: 'Player 1', ping: 10, uuid: undefined },
|
||||
{ username: 'Player 2', ping: 20, uuid: undefined },
|
||||
{ username: 'Player 3', ping: 30, uuid: undefined },
|
||||
],
|
||||
]}
|
||||
/>
|
||||
"§bRed" displays as <MessageFormattedString message="§bRed" />
|
||||
<Scoreboard
|
||||
open
|
||||
title="Scoreboard"
|
||||
items={[
|
||||
{ name: 'Player 1', value: 10 },
|
||||
{ name: 'Player 2', value: 20 },
|
||||
{ name: 'Player 3', value: 30 },
|
||||
]}
|
||||
/>
|
||||
<XPBar gamemode="survival" level={10} progress={0.5} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
createRoot(document.body as Element).render(<ExampleDemo />)
|
||||
|
|
@ -1 +0,0 @@
|
|||
<script src="decode.ts" type="module"></script>
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// Include the pako library
|
||||
import pako from 'pako';
|
||||
import compressedJsRaw from './compressed.js?raw'
|
||||
|
||||
function decompressFromBase64(input) {
|
||||
// Decode the Base64 string
|
||||
const binaryString = atob(input);
|
||||
const len = binaryString.length;
|
||||
const bytes = new Uint8Array(len);
|
||||
|
||||
// Convert the binary string to a byte array
|
||||
for (let i = 0; i < len; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// Decompress the byte array
|
||||
const decompressedData = pako.inflate(bytes, { to: 'string' });
|
||||
|
||||
return decompressedData;
|
||||
}
|
||||
|
||||
// Use the function
|
||||
console.time('decompress');
|
||||
const decompressedData = decompressFromBase64(compressedJsRaw);
|
||||
console.timeEnd('decompress')
|
||||
console.log(decompressedData)
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<style>
|
||||
div {
|
||||
position: fixed;
|
||||
bottom: env(safe-area-inset-bottom);
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #f00;
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<span>bottom: env(safe-area-inset-bottom)</span>
|
||||
</div>
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="captured"></div>
|
||||
<script>
|
||||
const pointers = []
|
||||
const up = () => {
|
||||
captured.textContent = pointers.join(', ')
|
||||
}
|
||||
window.addEventListener('pointerdown', (e) => {
|
||||
pointers.push(e.pointerId)
|
||||
document.body.setPointerCapture(e.pointerId)
|
||||
up()
|
||||
e.preventDefault()
|
||||
})
|
||||
const remove = (id) => {
|
||||
pointers.splice(pointers.indexOf(id), 1)
|
||||
up()
|
||||
}
|
||||
window.addEventListener('pointerup', (e) => {
|
||||
pointers.push('up')
|
||||
remove(e.pointerId)
|
||||
})
|
||||
window.addEventListener('pointercancel', (e) => {
|
||||
pointers.push('cancel')
|
||||
remove(e.pointerId)
|
||||
})
|
||||
window.addEventListener('lostpointercapture', (e) => {
|
||||
pointers.push('lost')
|
||||
remove(e.pointerId)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<script src="state.ts" type="module"></script>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
import { SmoothSwitcher } from '../renderer/viewer/lib/smoothSwitcher'
|
||||
|
||||
const div = document.createElement('div')
|
||||
div.style.width = '100px'
|
||||
div.style.height = '100px'
|
||||
div.style.backgroundColor = 'red'
|
||||
document.body.appendChild(div)
|
||||
|
||||
const pos = {x: 0, y: 0}
|
||||
|
||||
const positionSwitcher = new SmoothSwitcher(() => pos, (key, value) => {
|
||||
pos[key] = value
|
||||
})
|
||||
globalThis.positionSwitcher = positionSwitcher
|
||||
|
||||
document.body.addEventListener('keydown', e => {
|
||||
if (e.code === 'ArrowLeft' || e.code === 'ArrowRight') {
|
||||
const to = {
|
||||
x: e.code === 'ArrowLeft' ? -100 : 100
|
||||
}
|
||||
console.log(pos, to)
|
||||
positionSwitcher.transitionTo(to, e.code === 'ArrowLeft' ? 'Left' : 'Right', () => {
|
||||
console.log('Switched to ', e.code === 'ArrowLeft' ? 'Left' : 'Right')
|
||||
})
|
||||
}
|
||||
if (e.code === 'Space') {
|
||||
pos.x = 200
|
||||
}
|
||||
})
|
||||
|
||||
const render = () => {
|
||||
positionSwitcher.update()
|
||||
div.style.transform = `translate(${pos.x}px, ${pos.y}px)`
|
||||
requestAnimationFrame(render)
|
||||
}
|
||||
|
||||
render()
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Minecraft Item Viewer</title>
|
||||
<style>
|
||||
body { margin: 0; overflow: hidden; }
|
||||
canvas { display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="./three-item.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
import * as THREE from 'three'
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
||||
import itemsAtlas from 'mc-assets/dist/itemsAtlasLegacy.png'
|
||||
import { createItemMeshFromCanvas, createItemMesh } from '../renderer/viewer/three/itemMesh'
|
||||
|
||||
// Create scene, camera and renderer
|
||||
const scene = new THREE.Scene()
|
||||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
|
||||
const renderer = new THREE.WebGLRenderer({ antialias: true })
|
||||
renderer.setSize(window.innerWidth, window.innerHeight)
|
||||
document.body.appendChild(renderer.domElement)
|
||||
|
||||
// Setup camera and controls
|
||||
camera.position.set(0, 0, 3)
|
||||
const controls = new OrbitControls(camera, renderer.domElement)
|
||||
controls.enableDamping = true
|
||||
|
||||
// Background and lights
|
||||
scene.background = new THREE.Color(0x333333)
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 0.7)
|
||||
scene.add(ambientLight)
|
||||
|
||||
// Animation loop
|
||||
function animate () {
|
||||
requestAnimationFrame(animate)
|
||||
controls.update()
|
||||
renderer.render(scene, camera)
|
||||
}
|
||||
|
||||
async function setupItemMesh () {
|
||||
try {
|
||||
const loader = new THREE.TextureLoader()
|
||||
const atlasTexture = await loader.loadAsync(itemsAtlas)
|
||||
|
||||
// Pixel-art configuration
|
||||
atlasTexture.magFilter = THREE.NearestFilter
|
||||
atlasTexture.minFilter = THREE.NearestFilter
|
||||
atlasTexture.generateMipmaps = false
|
||||
atlasTexture.wrapS = atlasTexture.wrapT = THREE.ClampToEdgeWrapping
|
||||
|
||||
// Extract the tile at x=2, y=0 (16x16)
|
||||
const tileSize = 16
|
||||
const tileX = 2
|
||||
const tileY = 0
|
||||
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = tileSize
|
||||
canvas.height = tileSize
|
||||
const ctx = canvas.getContext('2d')!
|
||||
|
||||
ctx.imageSmoothingEnabled = false
|
||||
ctx.drawImage(
|
||||
atlasTexture.image,
|
||||
tileX * tileSize,
|
||||
tileY * tileSize,
|
||||
tileSize,
|
||||
tileSize,
|
||||
0,
|
||||
0,
|
||||
tileSize,
|
||||
tileSize
|
||||
)
|
||||
|
||||
// Test both approaches - working manual extraction:
|
||||
const meshOld = createItemMeshFromCanvas(canvas, { depth: 0.1 })
|
||||
meshOld.position.x = -1
|
||||
meshOld.rotation.x = -Math.PI / 12
|
||||
meshOld.rotation.y = Math.PI / 12
|
||||
scene.add(meshOld)
|
||||
|
||||
// And new unified function:
|
||||
const atlasWidth = atlasTexture.image.width
|
||||
const atlasHeight = atlasTexture.image.height
|
||||
const u = (tileX * tileSize) / atlasWidth
|
||||
const v = (tileY * tileSize) / atlasHeight
|
||||
const sizeX = tileSize / atlasWidth
|
||||
const sizeY = tileSize / atlasHeight
|
||||
|
||||
console.log('Debug texture coords:', {u, v, sizeX, sizeY, atlasWidth, atlasHeight})
|
||||
|
||||
const resultNew = createItemMesh(atlasTexture, {
|
||||
u, v, sizeX, sizeY
|
||||
}, {
|
||||
faceCamera: false,
|
||||
use3D: true,
|
||||
depth: 0.1
|
||||
})
|
||||
|
||||
resultNew.mesh.position.x = 1
|
||||
resultNew.mesh.rotation.x = -Math.PI / 12
|
||||
resultNew.mesh.rotation.y = Math.PI / 12
|
||||
scene.add(resultNew.mesh)
|
||||
|
||||
animate()
|
||||
} catch (err) {
|
||||
console.error('Failed to create item mesh:', err)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle window resize
|
||||
window.addEventListener('resize', () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight
|
||||
camera.updateProjectionMatrix()
|
||||
renderer.setSize(window.innerWidth, window.innerHeight)
|
||||
})
|
||||
|
||||
// Start
|
||||
setupItemMesh()
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<script type="module" src="three-labels.ts"></script>
|
||||
<style>
|
||||
body { margin: 0; }
|
||||
canvas { display: block; }
|
||||
</style>
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
import * as THREE from 'three'
|
||||
import { FirstPersonControls } from 'three/addons/controls/FirstPersonControls.js'
|
||||
import { createWaypointSprite, WAYPOINT_CONFIG } from '../renderer/viewer/three/waypointSprite'
|
||||
|
||||
// Create scene, camera and renderer
|
||||
const scene = new THREE.Scene()
|
||||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
|
||||
const renderer = new THREE.WebGLRenderer({ antialias: true })
|
||||
renderer.setSize(window.innerWidth, window.innerHeight)
|
||||
document.body.appendChild(renderer.domElement)
|
||||
|
||||
// Add FirstPersonControls
|
||||
const controls = new FirstPersonControls(camera, renderer.domElement)
|
||||
controls.lookSpeed = 0.1
|
||||
controls.movementSpeed = 10
|
||||
controls.lookVertical = true
|
||||
controls.constrainVertical = true
|
||||
controls.verticalMin = 0.1
|
||||
controls.verticalMax = Math.PI - 0.1
|
||||
|
||||
// Position camera
|
||||
camera.position.y = 1.6 // Typical eye height
|
||||
camera.lookAt(0, 1.6, -1)
|
||||
|
||||
// Create a helper grid and axes
|
||||
const grid = new THREE.GridHelper(20, 20)
|
||||
scene.add(grid)
|
||||
const axes = new THREE.AxesHelper(5)
|
||||
scene.add(axes)
|
||||
|
||||
// Create waypoint sprite via utility
|
||||
const waypoint = createWaypointSprite({
|
||||
position: new THREE.Vector3(0, 0, -5),
|
||||
color: 0xff0000,
|
||||
label: 'Target',
|
||||
})
|
||||
scene.add(waypoint.group)
|
||||
|
||||
// Use built-in offscreen arrow from utils
|
||||
waypoint.enableOffscreenArrow(true)
|
||||
waypoint.setArrowParent(scene)
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
requestAnimationFrame(animate)
|
||||
|
||||
const delta = Math.min(clock.getDelta(), 0.1)
|
||||
controls.update(delta)
|
||||
|
||||
// Unified camera update (size, distance text, arrow, visibility)
|
||||
const sizeVec = renderer.getSize(new THREE.Vector2())
|
||||
waypoint.updateForCamera(camera.position, camera, sizeVec.width, sizeVec.height)
|
||||
|
||||
renderer.render(scene, camera)
|
||||
}
|
||||
|
||||
// Handle window resize
|
||||
window.addEventListener('resize', () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight
|
||||
camera.updateProjectionMatrix()
|
||||
renderer.setSize(window.innerWidth, window.innerHeight)
|
||||
})
|
||||
|
||||
// Add clock for controls
|
||||
const clock = new THREE.Clock()
|
||||
|
||||
animate()
|
||||
|
|
@ -1 +0,0 @@
|
|||
<script type="module" src="three.ts"></script>
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
import * as THREE from 'three'
|
||||
|
||||
// Create scene, camera and renderer
|
||||
const scene = new THREE.Scene()
|
||||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
|
||||
const renderer = new THREE.WebGLRenderer()
|
||||
renderer.setSize(window.innerWidth, window.innerHeight)
|
||||
document.body.appendChild(renderer.domElement)
|
||||
|
||||
// Position camera
|
||||
camera.position.z = 5
|
||||
|
||||
// Create a canvas with some content
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = 256
|
||||
canvas.height = 256
|
||||
const ctx = canvas.getContext('2d')
|
||||
|
||||
scene.background = new THREE.Color(0x444444)
|
||||
|
||||
// Draw something on the canvas
|
||||
ctx.fillStyle = '#444444'
|
||||
// ctx.fillRect(0, 0, 256, 256)
|
||||
ctx.fillStyle = 'red'
|
||||
ctx.font = '48px Arial'
|
||||
ctx.textAlign = 'center'
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText('Hello!', 128, 128)
|
||||
|
||||
// Create bitmap and texture
|
||||
async function createTexturedBox() {
|
||||
const canvas2 = new OffscreenCanvas(256, 256)
|
||||
const ctx2 = canvas2.getContext('2d')!
|
||||
ctx2.drawImage(canvas, 0, 0)
|
||||
const texture = new THREE.Texture(canvas2)
|
||||
texture.magFilter = THREE.NearestFilter
|
||||
texture.minFilter = THREE.NearestFilter
|
||||
texture.needsUpdate = true
|
||||
texture.flipY = false
|
||||
|
||||
// Create box with texture
|
||||
const geometry = new THREE.BoxGeometry(2, 2, 2)
|
||||
const material = new THREE.MeshBasicMaterial({
|
||||
map: texture,
|
||||
side: THREE.DoubleSide,
|
||||
premultipliedAlpha: false,
|
||||
})
|
||||
const cube = new THREE.Mesh(geometry, material)
|
||||
scene.add(cube)
|
||||
}
|
||||
|
||||
// Create the textured box
|
||||
createTexturedBox()
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
requestAnimationFrame(animate)
|
||||
renderer.render(scene, camera)
|
||||
}
|
||||
animate()
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
root: 'experiments',
|
||||
})
|
||||
BIN
favicon.png
Normal file
|
After Width: | Height: | Size: 526 KiB |
|
|
@ -158,10 +158,10 @@
|
|||
<meta property="og:title" content="Minecraft Web Client" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
</head>
|
||||
<meta charset="UTF-8"><link href="./static/css/22.b067bcc2.css" rel="stylesheet"><link href="./static/css/index.52e799dc.css" rel="stylesheet"><link rel="manifest" crossorigin="anonymous" href="manifest.json"><link rel="favicon" href="favicon.png"><link rel="icon" type="image/png" href="favicon.png"><meta property="og:image" content="favicon.png"></head>
|
||||
<body>
|
||||
<div id="react-root"></div>
|
||||
<div id="ui-root"></div>
|
||||
<!-- inject script -->
|
||||
</body>
|
||||
<script defer src="./static/js/lib-polyfill.0b967fd8.js"></script><script defer src="./static/js/lib-react.2ae75c39.js"></script><script defer src="./static/js/22.7edb4911.js"></script><script defer src="./static/js/index.63cb9e63.js"></script></body>
|
||||
</html>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |