Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: zardoy/space-squid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.12
Choose a base ref
...
head repository: zardoy/space-squid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: everything
Choose a head ref

Commits on Mar 21, 2024

  1. fix: fix warps support

    zardoy committed Mar 21, 2024
    Copy the full SHA
    ce9dd8d View commit details
  2. fix: fix shortcut

    zardoy committed Mar 21, 2024
    Copy the full SHA
    5edc27b View commit details
  3. feat: add /home & /sethome

    zardoy committed Mar 21, 2024
    Copy the full SHA
    43f9944 View commit details

Commits on Apr 14, 2024

  1. fix: disable chests for now

    zardoy committed Apr 14, 2024
    Copy the full SHA
    f3ad970 View commit details

Commits on Apr 20, 2024

  1. Copy the full SHA
    211721e View commit details
  2. handle pnpm update

    zardoy committed Apr 20, 2024
    Copy the full SHA
    7002769 View commit details

Commits on Apr 29, 2024

  1. Copy the full SHA
    d518be2 View commit details
  2. Copy the full SHA
    3580d3f View commit details
  3. Copy the full SHA
    9ba5220 View commit details

Commits on May 6, 2024

  1. Copy the full SHA
    3cc8744 View commit details

Commits on May 12, 2024

  1. fix: A lot of regression fixes, starting from basic cli usage ending …

    …with compatibility with > 1.13 worlds and tsx watch compatibility
    
    docs: add instructions for best dx
    zardoy committed May 12, 2024
    Copy the full SHA
    bbf4597 View commit details
  2. fix: fix esm module crash, don't create false directory when no world…

    … folder is selected, improve some types
    zardoy committed May 12, 2024
    Copy the full SHA
    391a546 View commit details

Commits on May 16, 2024

  1. feat: basic support for bun hot reload in dev! (bun --hot src/app.js)

    fix: improve server cleanup on quit
    zardoy committed May 16, 2024
    Copy the full SHA
    7997d80 View commit details

Commits on May 20, 2024

  1. feat: parse, write day time from level.dat

    fix: cancel generating chunks on server stop
    zardoy committed May 20, 2024
    Copy the full SHA
    168fe27 View commit details

Commits on May 29, 2024

  1. Copy the full SHA
    fa61c13 View commit details
  2. Copy the full SHA
    81abb9d View commit details

Commits on Jun 12, 2024

  1. fix: fix block renames for some versions

    fix bitmap in the client locally
    zardoy committed Jun 12, 2024
    Copy the full SHA
    84071ac View commit details
  2. Copy the full SHA
    36ccbfa View commit details

Commits on Jun 13, 2024

  1. Copy the full SHA
    0048c12 View commit details
  2. Copy the full SHA
    348cd00 View commit details
  3. Copy the full SHA
    8220f71 View commit details

Commits on Jun 18, 2024

  1. feat: add serv.setWarp

    zardoy committed Jun 18, 2024
    Copy the full SHA
    6bf948b View commit details
  2. add missing deps

    zardoy committed Jun 18, 2024
    Copy the full SHA
    c61e32f View commit details

Commits on Jun 27, 2024

  1. Copy the full SHA
    fc57287 View commit details
  2. Copy the full SHA
    6df78cb View commit details

Commits on Jun 30, 2024

  1. Copy the full SHA
    d1bf244 View commit details
  2. Copy the full SHA
    b4b89bc View commit details

Commits on Jul 24, 2024

  1. feat: improve compatibility with any bundler by not using esbuild spe…

    …cific plugin, gen list of plugins at bulid-time, not runtime
    zardoy committed Jul 24, 2024
    Copy the full SHA
    5284c45 View commit details

Commits on Aug 6, 2024

  1. up readme for ver

    zardoy committed Aug 6, 2024
    Copy the full SHA
    83d9be3 View commit details
  2. feat: save full info about warp like color (#9)

    Co-authored-by: gguio <nikvish150@gmail.com>
    gguio and gguio authored Aug 6, 2024
    Copy the full SHA
    e9956e5 View commit details

Commits on Aug 31, 2024

  1. fix: login player only after configuration is complete which should f…

    …ix it for new vanilla clients & pweb client safari
    zardoy committed Aug 31, 2024
    Copy the full SHA
    c16b25c View commit details
  2. lock minecraft data

    zardoy committed Aug 31, 2024
    Copy the full SHA
    1731532 View commit details

Commits on Sep 3, 2024

  1. fix: stop loading chunks in previous position when teleported to a ne…

    …w pos and always start loading chunks in new pos
    zardoy committed Sep 3, 2024
    Copy the full SHA
    5786dff View commit details

Commits on Sep 4, 2024

  1. Copy the full SHA
    3cf3c7b View commit details

Commits on Sep 6, 2024

  1. feat: noInitialChunksSend

    zardoy committed Sep 6, 2024
    Copy the full SHA
    9dccf8f View commit details
  2. Copy the full SHA
    8f827a1 View commit details
  3. fix(regression,critical): chunks were stopped loading after moving to…

    … another chunk
    
    fix: fix command blocks parsing for most versions
    fix: chat was not working for 1.19+
    fix: better range adjustment for plate command block activation
    fix: was not possible to change the warp
    zardoy committed Sep 6, 2024
    Copy the full SHA
    8fe38b9 View commit details

Commits on Oct 17, 2024

  1. feat: crafting table (#11)

    zardoy authored Oct 17, 2024
    Copy the full SHA
    e87ddf4 View commit details
  2. fix build

    zardoy committed Oct 17, 2024
    Copy the full SHA
    fcb23e0 View commit details
  3. feat: add fall damage

    fix: fix gameMode undefined
    zardoy committed Oct 17, 2024
    Copy the full SHA
    9a7aa38 View commit details

Commits on Oct 20, 2024

  1. Copy the full SHA
    a6c934f View commit details

Commits on Oct 30, 2024

  1. Copy the full SHA
    a932afb View commit details

Commits on Nov 5, 2024

  1. Copy the full SHA
    1f02a6d View commit details
  2. Copy the full SHA
    1d160d5 View commit details

Commits on Nov 20, 2024

  1. feat: add gamerules support: basic data parsing, now possible to cont…

    …rol/change them via /gamerule
    
    only these gamerules effect implemented: doDaylightCycle
    fix: better messaging from output commands (now green)
    zardoy committed Nov 20, 2024
    Copy the full SHA
    b9ffbd8 View commit details

Commits on Nov 21, 2024

  1. fix: fix gamerules handling!

    fix: improve output commands formatting, especially errored ones
    zardoy committed Nov 21, 2024
    Copy the full SHA
    69e2a72 View commit details

Commits on Dec 17, 2024

  1. Copy the full SHA
    75dc7d1 View commit details
  2. fix options type

    zardoy committed Dec 17, 2024
    Copy the full SHA
    d4b6bd1 View commit details

Commits on Dec 20, 2024

  1. Copy the full SHA
    83da96b View commit details
Showing with 10,610 additions and 725 deletions.
  1. +0 −42 .github/disabled-workflows/docker.yml
  2. +2 −1 .gitignore
  3. +5 −6 Dockerfile
  4. +47 −0 README.md
  5. +0 −1 index.js
  6. +20 −9 package.json
  7. +12 −1 scripts/genTypes.mjs
  8. +44 −6 src/app.js
  9. +11 −0 src/blockRenames.test.ts
  10. +2 −6 src/blockRenames.ts
  11. +54 −6 src/index.ts
  12. +0 −36 src/itemBlockRenames.json
  13. +89 −0 src/levelDat.ts
  14. +17 −7 src/lib/command.ts
  15. +543 −0 src/lib/generatedClientPackets.ts
  16. +1,503 −0 src/lib/generatedServerPackets.ts
  17. +1 −1 src/lib/modules/animations.ts
  18. +7 −0 src/lib/modules/books.ts
  19. +50 −35 src/lib/modules/chat.ts
  20. +9 −5 src/lib/modules/chest.ts
  21. +33 −0 src/lib/modules/commandBlocks.ts
  22. +43 −7 src/lib/modules/commands.ts
  23. +126 −0 src/lib/modules/crafting.ts
  24. +6 −3 src/lib/modules/daycycle.ts
  25. +7,280 −0 src/lib/modules/dimensionCodec.ts
  26. +18 −25 src/lib/modules/external.ts
  27. +74 −0 src/lib/modules/fallDamange.ts
  28. +60 −0 src/lib/modules/gamerules.ts
  29. +2 −28 src/lib/modules/index.ts
  30. +21 −9 src/lib/modules/inventory.ts
  31. +18 −8 src/lib/modules/log.ts
  32. +131 −263 src/lib/modules/login.ts
  33. +6 −3 src/lib/modules/logout.ts
  34. +7 −10 src/lib/modules/moderation.ts
  35. +19 −13 src/lib/modules/placeBlock.ts
  36. +5 −7 src/lib/modules/players.ts
  37. +46 −0 src/lib/modules/pluginsFolder.ts
  38. +4 −4 src/lib/modules/pvp.ts
  39. +4 −2 src/lib/modules/redstone.ts
  40. +4 −7 src/lib/modules/settings.ts
  41. +8 −7 src/lib/modules/spawn.ts
  42. +7 −3 src/lib/modules/tabComplete.ts
  43. +6 −4 src/lib/modules/updatePositions.ts
  44. +61 −10 src/lib/modules/warps.ts
  45. +149 −80 src/lib/modules/world.ts
  46. +22 −5 src/lib/playerDat.js
  47. +0 −59 src/lib/requireindex.js
  48. +2 −2 src/lib/worldGenerations/empty.js
  49. +2 −1 src/lib/worldGenerations/nether.js
  50. +2 −1 src/lib/worldGenerations/superflat.js
  51. +21 −1 src/modules.ts
  52. +7 −1 src/utils/index.ts
  53. 0 world/.gitkeep
42 changes: 0 additions & 42 deletions .github/disabled-workflows/docker.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -9,4 +9,5 @@ distTest
world/*
!world/.gitkeep
package-lock.json
/README.md
worlds*
native/
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM node:16-slim
FROM node:18-slim

WORKDIR /app
COPY package.json ./
RUN npm config set bin-links false
RUN npm install
COPY . .
# COPY package.json scripts src ./
# todo shouldn't copy non-existent our outdated dist
COPY package.json dist

ENTRYPOINT [ "node", "app.js", "-c", "/config" ]
ENTRYPOINT node dist/app.js -c /config
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Space Squid

> TypeScript fork of [Flying Squid](https://github.com/PrismarineJS/flying-squid) with a focus on better DX experince for plugins!
Minecraft lightweight server written in TypeScript (JS).

- Supports latest versions (up to ~1.20)
- Easily customizable in every aspect

## Installation

### Node.js

If you have Node.js installed, you can install `pnpm` or `npm`:

```bash
npm i -g @zardoy/flying-squid
```

```bash
flying-squid
```

It's recommended to also install `pm2` for process auto-restart on crashes and system reboots.

## Roadmap

| Feature | Status |
| ---------------- | --------------------------------------------------------------------- |
| WebSocket | Not started |
| Plugin API | Done. Needs polishing |
| World Generation | Few simple generators available. Needs more |
| World Saving | ✅ Doesn't support latest versions |
| World Loading | ✅ Full support for all versions, but writing can broke existing saves |
| Redstone | Not started |
| Command Blocks | ✅ Needs all commands implementation (50%) |
| Pvp | Not started |
| Mobs | ✅ Needs spawning, ai, a few physics fixes |

### Alternatives

### development

0. Clone, setup Node.js (at least v18.6.0)
1. Install dependencies: `npm install` or `pnpm install`
2. Run `npm run dev`, `npm run start` for without watch or `npm run watch` for watch mode (for prismarine-web-client)
2.1. If using [Bun](https://bun.sh) (experimental) instead: `bun --watch src/app.js` or `bun --hot src/app.js` (preview)
1 change: 0 additions & 1 deletion index.js

This file was deleted.

29 changes: 20 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -14,6 +14,9 @@
"scripts": {
"start": "tsc && node dist/app.js",
"build": "tsc && node scripts/genTypes.mjs",
"dev": "tsx watch src/app.js",
"watch": "concurrently \"tsc -w\" \"nodemon --watch dist/index.js scripts/genTypes.mjs\"",
"make-exe": "pkg dist/app.js --targets node18-win-x64",
"build-npm": "tsc -p tsconfig.npm.json && node scripts/genTypes.mjs",
"prepare": "pnpm build",
"lint": "eslint src/**",
@@ -24,7 +27,7 @@
"test-essential": "echo todo",
"test-all": "echo todo",
"test": "echo TODO",
"pretest": "npm run lint"
"pretest": "echo TODO-soon"
},
"keywords": [
"browser",
@@ -36,19 +39,17 @@
"node": ">=8"
},
"dependencies": {
"@tootallnate/once": "2.0.0",
"change-case": "^4.1.2",
"colors": "1.4.0",
"diamond-square": "^1.2.0",
"chalk": "^5.3.0",
"diamond-square": "github:zardoy/diamond-square",
"emit-then": "^2.0.0",
"event-promise": "^0.0.1",
"exit-hook": "^2.2.1",
"flatmap": "^0.0.3",
"long": "^5.1.0",
"minecraft-data": "^3.42.1",
"minecraft-data": "3.67.0",
"minecraft-protocol": "^1.44.0",
"mkdirp": "^2.1.3",
"moment": "^2.10.6",
"needle": "^2.5.0",
"node-gzip": "^1.1.2",
"node-rsa": "^1.1.1",
"prismarine-chunk": "^1.35.0",
@@ -58,23 +59,33 @@
"prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
"prismarine-windows": "^2.8.0",
"prismarine-world": "^3.6.2",
"rambda": "^9.2.0",
"random-seed": "^0.3.0",
"range": "^0.0.3",
"readline": "^1.3.0",
"sanitize-filename": "^1.6.3",
"typed-emitter": "1.4.0",
"uuid-1345": "^1.0.1",
"vec3": "^0.1.8",
"yaml": "^2.4.1",
"yargs": "^17.0.1"
},
"devDependencies": {
"concurrently": "^8.2.2",
"expect": "^29.1.2",
"flying-squid": "file:.",
"longjohn": "^0.2.12",
"minecraft-wrap": "^1.2.3",
"mineflayer": "^4.0.0",
"mocha": "^10.0.0",
"typescript": "^5.3.3",
"nodemon": "^3.1.4",
"pkg": "^5.8.1",
"tsx": "^4.10.1",
"typescript": "^5.6.3",
"vitest": "^0.34.6"
},
"pnpm": {
"overrides": {
"protodef": "npm:@zardoy/protodef"
}
}
}
13 changes: 12 additions & 1 deletion scripts/genTypes.mjs
Original file line number Diff line number Diff line change
@@ -4,9 +4,20 @@ import fs from 'fs'
const targetFile = './dist/types.d.ts';
const plugins = fs.readdirSync('./dist/lib/modules').filter(f => f !== 'index')
let types = ''
types = plugins.filter(module => module.endsWith('.d.ts')).map(module => `import "./lib/plugins/${module}"`).join('\n') + '\n' + types
types = plugins.filter(module => module.endsWith('.d.ts')).map(module => `import "./lib/modules/${module}"`).join('\n') + '\n' + types
fs.writeFileSync(targetFile, types, 'utf8')

let indexTs = fs.readFileSync('./dist/index.d.ts', 'utf8')
indexTs = `import './types';` + indexTs
fs.writeFileSync('./dist/index.d.ts', indexTs, 'utf8')

const modules = fs.readdirSync('./dist/lib/modules').filter(f => f !== 'index' && f.endsWith('.js')).map(f => f.replace('.js', ''))
const modulesReqLines = modules.map(m => `'${m}': require('./${m}')`).join(',\n')
const modulesFileJs = `
module.exports = {
builtinPlugins: {
${modulesReqLines}
}
}
`
fs.writeFileSync('./dist/lib/modules/index.js', modulesFileJs, 'utf8')
50 changes: 44 additions & 6 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node

const argv = require('yargs/yargs')(process.argv.slice(2))
const yargs = require('yargs/yargs')(process.argv.slice(2))

const argv = yargs
.usage('Usage: $0 <command> [options]')
.help('h')
.option('config', {
@@ -23,13 +25,25 @@ const argv = require('yargs/yargs')(process.argv.slice(2))
type: 'boolean',
default: 'false'
})
.option('port', {
description: 'Port to run the server on',
type: 'number',
default: '25565'
})
.option('ver', {
description: 'The version of the server to run (for clients and world)',
type: 'string',
})
.option('world', {
description: 'Path to Java world save folder',
type: 'string',
})
.argv

const mcServer = require('./index')

//@ts-ignore
const defaultSettings = require('../config/default-settings.json')
const mcServer = require('./index')

/** @type {Options} */
let settings

try {
@@ -42,12 +56,36 @@ settings = Object.assign(settings, defaultSettings, settings)
if (argv.offline) settings['online-mode'] = false
if (argv.log) settings.logging = true
if (argv.op) settings['everybody-op'] = true
if (argv.port) settings.port = +argv.port
if (argv.ver) settings.version = argv.ver
if (argv.world) settings.worldFolder = argv.world === 'false' ? false : argv.world

if (!require('./lib/version').supportedVersions.includes(settings.version)) {
throw new Error(`Version ${settings.version} is not supported.`)
// throw new Error(`Version ${settings.version} is not supported.`)
console.warn(`Version ${settings.version} is not supported.`)
}

if (globalThis.server) {
globalThis.__hot_reload = true
settings.oldServerData = globalThis.server
}

module.exports = globalThis.server = mcServer.createMCServer(settings)
const server = mcServer.createMCServer(settings)

globalThis.server = {
_server: server._server,
cleanupFunctions: server.cleanupFunctions,
players: server.players,
oldData: {}
}
module.exports = server

const saveData = ['time']
server.on('tick', () => {
for (const data of saveData) {
globalThis.server.oldData[data] = server[data]
}
})

process.on('unhandledRejection', err => {
console.log(err.stack)
11 changes: 11 additions & 0 deletions src/blockRenames.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from 'vitest'
import { getRenamedData } from './blockRenames'

test('works', () => {
expect(getRenamedData('blocks', 'short_grass', '1.20.3', '1.8.8')).toEqual('tallgrass')
expect(getRenamedData('blocks', ['standing_sign', 'grass'], '1.8.8', '1.16')).toEqual(['oak_sign', 'grass_block'])
expect(getRenamedData('blocks', ['stone'], '1.8.8', '1.8.8')).toEqual(['stone'])
expect(getRenamedData('blocks', ['stone'], '1.20.3', '1.20.3')).toEqual(['stone'])
expect(getRenamedData('blocks', ['stone'], '1.8.8', '1.20.4')).toEqual(['stone'])
expect(getRenamedData('blocks', ['planks'], '1.8.8', '1.20.4')).toEqual(['oak_planks'])
})
8 changes: 2 additions & 6 deletions src/blockRenames.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import itemBlockRenames from './itemBlockRenames.json'
import { versionToNumber } from './utils'

// postflatenning
// todo regen 1.13 the flatenning data

const versionToNumber = (ver: string) => {
const [x, y = '0', z = '0'] = ver.split('.')
return +`${x.padStart(2, '0')}${(parseInt(y).toString().padStart(2, '0'))}${parseInt(z).toString().padStart(2, '0')}`
}

// const allRenamesMapFromLatest = Object.fromEntries(
// ['blocks', 'items'].map(x =>
// [
@@ -29,7 +25,7 @@ export const adoptBlockOrItemNamesFromLatest = (type: 'blocks' | 'items', blockO
const mapVersions = Object.keys(itemBlockRenames).sort((a, b) => dir * (versionToNumber(a) - versionToNumber(b)))
const upperBoundVer = dir > 0 ? verTo : verFrom
const lowerBoundVer = dir > 0 ? verFrom : verTo
for (const mapVersion of mapVersions) {
for (const mapVersion of mapVersions.filter(x => versionToNumber(x) <= upperBoundVer && versionToNumber(x) >= lowerBoundVer)) {
if (dir > 0 && versionToNumber(mapVersion) >= upperBoundVer) break
if (dir < 0 && versionToNumber(mapVersion) <= lowerBoundVer) break
const nextMapData = itemBlockRenames[mapVersion][type]
Loading