Initial commit

This commit is contained in:
unknown committed 2026-03-08 03:34:30 -04:00
commit 44f4e564b1
33 files changed
+8165

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

+1
View File
@@ -0,0 +1 @@
node_modules/
+187
View File
@@ -0,0 +1,187 @@
# Legacy Cross Play
**This project allows Legacy Console Edition clients to join a vanilla 1.8 Java Edition server!**
![](https://raw.githubusercontent.com/DeveloperExotic/LegacyCrossPlay/refs/heads/main/.assets/screenshot1.png)
![](https://raw.githubusercontent.com/DeveloperExotic/LegacyCrossPlay/refs/heads/main/.assets/screenshot2.png)
# How to Install
**Code modifications to the client source code is required for multiplayer to function properly**
- Install [NodeJS](https://nodejs.org/en/download), you may need to restart your computer after
- Start a localhost Java Edition server running on port 25564, and in offline mode (you can edit these in `server.properties`)
- Run the file `install_dependencies.bat`, - you only need to run this file one time.
- Run `start.bat`, the Java Edition server will appear in the join tab on Legacy Console Edition! You can configure the server IP / PORT in `constants.js`.
# Known issues, will be fixed
- You're unable to dismount while riding
- Chunk lighting is always lit
- Death animation plays when a Java player leaves
- You're unable to craft in survival mode
- You're unable to accept villager trades
---
# TODO
## Chunks
- [x] Java → LCE chunks
- [x] Blocks
- [x] Metadata
- [x] Lighting
- [x] Biomes
## Inventory Syncing
- [x] Held item
- [x] Item dropping
- [x] Creative items
- [x] Creative clear
- [x] Moved items
## Sync Gamemode / XP / Health / Hunger
- [x] Damage knockback / sound
## Respawn
- [x] Death animation
- [x] Respawn handling
## Environment
### Time
- [x] Sync Time
- [x] DoDaylightCycle fix
### Weather
- [x] Sync Weather
## Sound
- [x] Sound effects
---
# Entities
## Base Entities
- [x] Java edition players
- [x] Items
- [x] Mobs
### Mob Features
- [x] Ageable entities
- [x] Entity metadata (e.g. size, type)
- [x] Nametags
- [x] Mob inventory
- [x] Animations (e.g. bats)
## Entity Attachments
- [x] Attach to entities (e.g. riding pig, minecart, boat)
### Damage Translation
#### LCE Damage → Java Entity
- [x] Entity
- [x] Player
#### Java Damage → LCE Entity
- [x] Mobs
- [x] Players
- [x] Hurt sound
- [x] Entity velocity knockback
### Critical Hits
- [x] Normal critical
- [x] Magical critical
### Other Entity Systems
- [x] Fix minecart metadata (e.g. tnt minecart)
- [x] Arrows
- [x] Fix arrow bug when colliding with player / low bow pull
- [x] Falling block entities (e.g. sand, gravel, anvil)
- [x] Fireball
---
# Server
## Chat
- [x] Receive server chat
- [x] Send server chat
- [x] Fix chat commands (e.g. /say, /tellraw)
- [x] Java edition english chat translations
## Disconnections
- [x] Our LCE client disconnects
- [ ] Our java player disconnects
---
# Player Animations
## LCE → Java
- [x] Crouch
- [x] Sprint
- [x] Attack (swing)
- [x] Riding
- [x] Sword blocking
## Java → LCE
- [x] Crouch
- [x] Sprint
- [x] Attack
- [x] Entity
- [x] Player
- [x] Eating
- [x] Sleeping
---
# Block Updates
## Java → LCE
- [x] Creative
- [x] Survival
- [x] Explosions
## LCE → Java
- [x] Creative
- [x] Survival
---
# World
- [x] Particles
- [x] Nether and End dimensions
---
# UI
- [ ] Crafting _(Hard to implement, may require server plugin)_
- [ ] Brewing stand
- [ ] Furnace
- [x] Villager trading
- [ ] Accept trade _(Hard to implement, may require server plugin)_
- [x] Anvils
- [x] Chests
+17
View File
@@ -0,0 +1,17 @@
const GAME_PORT = 25565;
const WIN64_LAN_DISCOVERY_PORT = 25566;
const MINECRAFT_NET_VERSION = 560;
const JAVA_SERVER_HOST = "localhost";
const JAVA_SERVER_PORT = 25564;
const PROXY_NAME = JAVA_SERVER_HOST + ":" + JAVA_SERVER_PORT;
module.exports = {
GAME_PORT,
WIN64_LAN_DISCOVERY_PORT,
MINECRAFT_NET_VERSION,
USE_LEGACY_USERNAME: false, // you can use your legacy edition username, or a custom username below.
CUSTOM_USERNAME: "LCE_Player",
JAVA_SERVER_HOST,
JAVA_SERVER_PORT,
PROXY_NAME,
};
+15
View File
@@ -0,0 +1,15 @@
process.removeAllListeners("warning");
process.on("warning", (warning) => {
if (warning.name === "DeprecationWarning") return;
console.warn(warning.name, warning.message);
});
const LCEProxy = require("./src/LCEProxy");
const proxy = new LCEProxy();
proxy.start();
process.on("SIGINT", () => {
proxy.stop();
process.exit(0);
});
+3
View File
@@ -0,0 +1,3 @@
@echo off
npm install minecraft-protocol
pause
+822
View File
@@ -0,0 +1,822 @@
{
"name": "lce-proxy",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "lce-proxy",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"minecraft-protocol": "^1.64.0"
}
},
"node_modules/@azure/msal-common": {
"version": "14.16.1",
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.1.tgz",
"integrity": "sha512-nyxsA6NA4SVKh5YyRpbSXiMr7oQbwark7JU9LMeg6tJYTSPyAGkdx61wPT4gyxZfxlSxMMEyAsWaubBlNyIa1w==",
"license": "MIT",
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/@azure/msal-node": {
"version": "2.16.3",
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.3.tgz",
"integrity": "sha512-CO+SE4weOsfJf+C5LM8argzvotrXw252/ZU6SM2Tz63fEblhH1uuVaaO4ISYFuN4Q6BhTo7I3qIdi8ydUQCqhw==",
"license": "MIT",
"dependencies": {
"@azure/msal-common": "14.16.1",
"jsonwebtoken": "^9.0.0",
"uuid": "^8.3.0"
},
"engines": {
"node": ">=16"
}
},
"node_modules/@types/node": {
"version": "25.3.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.3.tgz",
"integrity": "sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.18.0"
}
},
"node_modules/@types/node-rsa": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@types/node-rsa/-/node-rsa-1.1.4.tgz",
"integrity": "sha512-dB0ECel6JpMnq5ULvpUTunx3yNm8e/dIkv8Zu9p2c8me70xIRUUG3q+qXRwcSf9rN3oqamv4116iHy90dJGRpA==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/readable-stream": {
"version": "4.0.23",
"resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.23.tgz",
"integrity": "sha512-wwXrtQvbMHxCbBgjHaMGEmImFTQxxpfMOR/ZoQnXxB1woqkUbdLGFDgauo00Py9IudiaqSeiBiulSV9i6XIPig==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@xboxreplay/errors": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz",
"integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==",
"license": "MIT"
},
"node_modules/@xboxreplay/xboxlive-auth": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz",
"integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==",
"license": "MIT",
"dependencies": {
"@xboxreplay/errors": "^0.1.0",
"axios": "^0.21.1"
}
},
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"license": "MIT",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/aes-js": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz",
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==",
"license": "MIT"
},
"node_modules/ajv": {
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
"integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/asn1": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
"integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==",
"license": "MIT"
},
"node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.14.0"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/buffer-equal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz",
"integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==",
"license": "MIT",
"engines": {
"node": ">=0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
"license": "BSD-3-Clause"
},
"node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"license": "MIT"
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/discontinuous-range": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz",
"integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==",
"license": "MIT"
},
"node_modules/ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"license": "Apache-2.0",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/endian-toggle": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz",
"integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==",
"license": "MIT"
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/events": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
"integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
"license": "MIT",
"engines": {
"node": ">=0.8.x"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"license": "MIT"
},
"node_modules/follow-redirects": {
"version": "1.15.11",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "BSD-3-Clause"
},
"node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"license": "MIT"
},
"node_modules/jsonwebtoken": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz",
"integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==",
"license": "MIT",
"dependencies": {
"jws": "^4.0.1",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^7.5.4"
},
"engines": {
"node": ">=12",
"npm": ">=6"
}
},
"node_modules/jwa": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz",
"integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==",
"license": "MIT",
"dependencies": {
"buffer-equal-constant-time": "^1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jws": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz",
"integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==",
"license": "MIT",
"dependencies": {
"jwa": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==",
"license": "MIT"
},
"node_modules/lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==",
"license": "MIT"
},
"node_modules/lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==",
"license": "MIT"
},
"node_modules/lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==",
"license": "MIT"
},
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==",
"license": "MIT"
},
"node_modules/lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==",
"license": "MIT"
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"license": "MIT"
},
"node_modules/lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
"license": "MIT"
},
"node_modules/lodash.reduce": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
"integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==",
"license": "MIT"
},
"node_modules/macaddress": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.4.tgz",
"integrity": "sha512-i8xVWoUjj2woYU8kbpQby86Kq7uF7xl2brtKREXUBWpfgqx1fKXEeYzDiVMVxA/IufC1d3xxwJRHtFCX+9IspA==",
"license": "MIT"
},
"node_modules/minecraft-data": {
"version": "3.105.0",
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.105.0.tgz",
"integrity": "sha512-4bu0PYcd7qFDmLHYA0wzFYS9jqO4EpbbD4ntzdNg/wsLgqpQ/Mku8UbQcQFdap0X2zN+7Eiio0GYq2SOEoOCfg==",
"license": "MIT"
},
"node_modules/minecraft-folder-path": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz",
"integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==",
"license": "MIT"
},
"node_modules/minecraft-protocol": {
"version": "1.64.0",
"resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.64.0.tgz",
"integrity": "sha512-SM6M9016NuBp30YGOBsP+Xfs8WdsDOxaGFQ/YE/BtxpAI0rfO8l6T5jFAJ4vEvFwHvLEjpGcfnvKh8LUUWoqEA==",
"license": "BSD-3-Clause",
"dependencies": {
"@types/node-rsa": "^1.1.4",
"@types/readable-stream": "^4.0.0",
"aes-js": "^3.1.2",
"buffer-equal": "^1.0.0",
"debug": "^4.3.2",
"endian-toggle": "^0.0.0",
"lodash.merge": "^4.3.0",
"minecraft-data": "^3.78.0",
"minecraft-folder-path": "^1.2.0",
"node-fetch": "^2.6.1",
"node-rsa": "^0.4.2",
"prismarine-auth": "^2.2.0",
"prismarine-chat": "^1.10.0",
"prismarine-nbt": "^2.5.0",
"prismarine-realms": "^1.2.0",
"protodef": "^1.17.0",
"readable-stream": "^4.1.0",
"uuid-1345": "^1.0.1",
"yggdrasil": "^1.4.0"
},
"engines": {
"node": ">=22"
}
},
"node_modules/mojangson": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz",
"integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==",
"license": "MIT",
"dependencies": {
"nearley": "^2.19.5"
}
},
"node_modules/moo": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/moo/-/moo-0.5.3.tgz",
"integrity": "sha512-m2fmM2dDm7GZQsY7KK2cme8agi+AAljILjQnof7p1ZMDe6dQ4bdnSMx0cPppudoeNv5hEFQirN6u+O4fDE0IWA==",
"license": "BSD-3-Clause"
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/nearley": {
"version": "2.20.1",
"resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz",
"integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==",
"license": "MIT",
"dependencies": {
"commander": "^2.19.0",
"moo": "^0.5.0",
"railroad-diagrams": "^1.0.0",
"randexp": "0.4.6"
},
"bin": {
"nearley-railroad": "bin/nearley-railroad.js",
"nearley-test": "bin/nearley-test.js",
"nearley-unparse": "bin/nearley-unparse.js",
"nearleyc": "bin/nearleyc.js"
},
"funding": {
"type": "individual",
"url": "https://nearley.js.org/#give-to-nearley"
}
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-rsa": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz",
"integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==",
"license": "MIT",
"dependencies": {
"asn1": "0.2.3"
}
},
"node_modules/prismarine-auth": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.7.0.tgz",
"integrity": "sha512-L8wTF6sdtnN6hViPNy+Nx39a8iQBwR5iO92AWCiym5cSXp/92pmnuwnTdcmNDWyqq6zY4hbibVGYhgLA1Ox8sQ==",
"license": "MIT",
"dependencies": {
"@azure/msal-node": "^2.0.2",
"@xboxreplay/xboxlive-auth": "^3.3.3",
"debug": "^4.3.3",
"smart-buffer": "^4.1.0",
"uuid-1345": "^1.0.2"
}
},
"node_modules/prismarine-biome": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/prismarine-biome/-/prismarine-biome-1.3.0.tgz",
"integrity": "sha512-GY6nZxq93mTErT7jD7jt8YS1aPrOakbJHh39seYsJFXvueIOdHAmW16kYQVrTVMW5MlWLQVxV/EquRwOgr4MnQ==",
"license": "MIT",
"peerDependencies": {
"minecraft-data": "^3.0.0",
"prismarine-registry": "^1.1.0"
}
},
"node_modules/prismarine-block": {
"version": "1.22.0",
"resolved": "https://registry.npmjs.org/prismarine-block/-/prismarine-block-1.22.0.tgz",
"integrity": "sha512-SKVTm+CHR5mY/d+delryqzB2hMH8HIPse8b0O51Ez2R5zPFtKVCLGk5NG71kCDKbMzhhev2iF0O4UC/fWDXhRw==",
"license": "MIT",
"dependencies": {
"minecraft-data": "^3.38.0",
"prismarine-biome": "^1.1.0",
"prismarine-chat": "^1.5.0",
"prismarine-item": "^1.10.1",
"prismarine-nbt": "^2.0.0",
"prismarine-registry": "^1.1.0"
}
},
"node_modules/prismarine-chat": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.12.0.tgz",
"integrity": "sha512-+1QBUn4WGXbAGwoGwJy31/FvH6JtTBHh//yU0xwOiVnBO71+6Ij0hYMd9PzTTAwR9bySfl/YLltGPBftUAOYOA==",
"license": "MIT",
"dependencies": {
"mojangson": "^2.0.1",
"prismarine-nbt": "^2.0.0",
"prismarine-registry": "^1.4.0"
}
},
"node_modules/prismarine-item": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/prismarine-item/-/prismarine-item-1.17.0.tgz",
"integrity": "sha512-wN1OjP+f+Uvtjo3KzeCkVSy96CqZ8yG7cvuvlGwcYupQ6ct7LtNkubHp0AHuLMJ0vbbfAC0oZ2bWOgI1DYp8WA==",
"license": "MIT",
"dependencies": {
"prismarine-nbt": "^2.0.0",
"prismarine-registry": "^1.4.0"
}
},
"node_modules/prismarine-nbt": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.8.0.tgz",
"integrity": "sha512-5D6FUZq0PNtf3v/41ImDlwThVesOv5adyqCRMZLzmkUGEmRJNNh5C6AsnvrClBftXs+IF0yqPnZoj8kcNPiMGg==",
"license": "MIT",
"dependencies": {
"protodef": "^1.18.0"
}
},
"node_modules/prismarine-realms": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.4.1.tgz",
"integrity": "sha512-WmElIrwN4H/f0460HPnNYRJkRMVNjAmnZUOkZC+tn2Hg2IOsxRlHH5yJ/E2go1hEeFj+NlcYrGDOOhldSXnxSA==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.3",
"node-fetch": "^2.6.1"
}
},
"node_modules/prismarine-registry": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.11.0.tgz",
"integrity": "sha512-uTvWE+bILxYv4i5MrrlxPQ0KYWINv1DJ3P2570GLC8uCdByDiDLBFfVyk4BrqOZBlDBft9CnaJMeOsC1Ly1iXw==",
"license": "MIT",
"dependencies": {
"minecraft-data": "^3.70.0",
"prismarine-block": "^1.17.1",
"prismarine-nbt": "^2.0.0"
}
},
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
"license": "MIT",
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/protodef": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/protodef/-/protodef-1.19.0.tgz",
"integrity": "sha512-94f3GR7pk4Qi5YVLaLvWBfTGUIzzO8hyo7vFVICQuu5f5nwKtgGDaeC1uXIu49s5to/49QQhEYeL0aigu1jEGA==",
"license": "MIT",
"dependencies": {
"lodash.reduce": "^4.6.0",
"protodef-validator": "^1.3.0",
"readable-stream": "^4.4.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/protodef-validator": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.4.0.tgz",
"integrity": "sha512-2y2coBolqCEuk5Kc3QwO7ThR+/7TZiOit4FrpAgl+vFMvq8w76nDhh09z08e2NQOdrgPLsN2yzXsvRvtADgUZQ==",
"license": "MIT",
"dependencies": {
"ajv": "^6.5.4"
},
"bin": {
"protodef-validator": "cli.js"
}
},
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/railroad-diagrams": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz",
"integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==",
"license": "CC0-1.0"
},
"node_modules/randexp": {
"version": "0.4.6",
"resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz",
"integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==",
"license": "MIT",
"dependencies": {
"discontinuous-range": "1.0.0",
"ret": "~0.1.10"
},
"engines": {
"node": ">=0.12"
}
},
"node_modules/readable-stream": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz",
"integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==",
"license": "MIT",
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
"process": "^0.11.10",
"string_decoder": "^1.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/ret": {
"version": "0.1.15",
"resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
"license": "MIT",
"engines": {
"node": ">=0.12"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/semver": {
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
"license": "MIT",
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.2.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/undici-types": {
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
"integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
"license": "MIT"
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"license": "BSD-2-Clause",
"dependencies": {
"punycode": "^2.1.0"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/uuid-1345": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz",
"integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==",
"license": "MIT",
"dependencies": {
"macaddress": "^0.5.1"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/yggdrasil": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz",
"integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==",
"license": "MIT",
"dependencies": {
"node-fetch": "^2.6.1",
"uuid": "^8.2.0"
}
}
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"name": "lce-proxy",
"version": "1.0.0",
"description": "Minecraft Legacy Console Edition LAN Proxy",
"main": "proxy.js",
"scripts": {
"start": "node proxy.js"
},
"keywords": [
"minecraft",
"lce",
"proxy",
"lan"
],
"author": "",
"license": "MIT",
"dependencies": {
"minecraft-protocol": "^1.64.0"
}
}
File diff suppressed because it is too large. Load diff
+29
View File
@@ -0,0 +1,29 @@
const {
MINECRAFT_NET_VERSION,
GAME_PORT,
PROXY_NAME,
} = require("../constants");
class LANBroadcast {
constructor() {
this.buffer = Buffer.allocUnsafe(86);
this.buffer.writeUInt32LE(0x4d434c4e, 0);
this.buffer.writeUInt16LE(MINECRAFT_NET_VERSION, 4);
this.buffer.writeUInt16LE(GAME_PORT, 6);
const hostName = PROXY_NAME;
for (let i = 0; i < 32; i++) {
const char = i < hostName.length ? hostName.charCodeAt(i) : 0;
this.buffer.writeUInt16LE(char, 8 + i * 2);
}
this.buffer.writeUInt8(1, 72); //player count including host
this.buffer.writeUInt8(8, 73); //max players
this.buffer.writeUInt32LE(0, 74); //host settings
this.buffer.writeUInt32LE(0, 78); //texture pack ID
this.buffer.writeUInt8(0, 82); //sub texture pack ID
this.buffer.writeUInt8(1, 83); //is joinable
}
}
module.exports = LANBroadcast;
+2454
View File
File diff suppressed because it is too large. Load diff
+75
View File
@@ -0,0 +1,75 @@
class PacketReader {
constructor(buffer) {
this.buffer = buffer;
this.offset = 0;
}
readByte() {
const value = this.buffer.readInt8(this.offset);
this.offset += 1;
return value;
}
readUnsignedByte() {
const value = this.buffer.readUInt8(this.offset);
this.offset += 1;
return value;
}
readShort() {
const value = this.buffer.readInt16BE(this.offset);
this.offset += 2;
return value;
}
readInt() {
const value = this.buffer.readInt32BE(this.offset);
this.offset += 4;
return value;
}
readLong() {
const value = this.buffer.readBigInt64BE(this.offset);
this.offset += 8;
return value;
}
readFloat() {
const value = this.buffer.readFloatBE(this.offset);
this.offset += 4;
return value;
}
readBoolean() {
return this.readByte() !== 0;
}
readString() {
const length = this.readShort();
let str = "";
for (let i = 0; i < length; i++) {
const charCode = this.buffer.readUInt16BE(this.offset);
this.offset += 2;
str += String.fromCharCode(charCode);
}
return str;
}
readDouble() {
const value = this.buffer.readDoubleBE(this.offset);
this.offset += 8;
return value;
}
readFloat() {
const value = this.buffer.readFloatBE(this.offset);
this.offset += 4;
return value;
}
skip(bytes) {
this.offset += bytes;
}
}
module.exports = PacketReader;
+89
View File
@@ -0,0 +1,89 @@
class PacketWriter {
constructor() {
this.buffers = [];
}
writeByte(value) {
const buf = Buffer.allocUnsafe(1);
buf.writeUInt8(value, 0);
this.buffers.push(buf);
}
writeSignedByte(value) {
const buf = Buffer.allocUnsafe(1);
buf.writeInt8(value, 0);
this.buffers.push(buf);
}
writeSignedByte(value) {
const buf = Buffer.allocUnsafe(1);
buf.writeInt8(value, 0);
this.buffers.push(buf);
}
writeShort(value) {
const buf = Buffer.allocUnsafe(2);
buf.writeInt16BE(value, 0);
this.buffers.push(buf);
}
writeInt(value) {
const buf = Buffer.allocUnsafe(4);
buf.writeInt32BE(value, 0);
this.buffers.push(buf);
}
writeLong(value) {
const buf = Buffer.allocUnsafe(8);
buf.writeBigInt64BE(BigInt(value), 0);
this.buffers.push(buf);
}
writeDouble(value) {
const buf = Buffer.allocUnsafe(8);
buf.writeDoubleBE(value, 0);
this.buffers.push(buf);
}
writeFloat(value) {
const buf = Buffer.allocUnsafe(4);
buf.writeFloatBE(value, 0);
this.buffers.push(buf);
}
writeBoolean(value) {
this.writeByte(value ? 1 : 0);
}
writeUTF(str) {
const utf8Buffer = Buffer.from(str, "utf8");
this.writeShort(utf8Buffer.length);
this.buffers.push(utf8Buffer);
}
writeString(str) {
this.writeShort(str.length);
for (let i = 0; i < str.length; i++) {
const buf = Buffer.allocUnsafe(2);
buf.writeUInt16BE(str.charCodeAt(i), 0);
this.buffers.push(buf);
}
}
writeUtf(str) {
this.writeShort(str.length);
for (let i = 0; i < str.length; i++) {
this.writeShort(str.charCodeAt(i));
}
}
writeBytes(buffer) {
this.buffers.push(buffer);
}
toBuffer() {
return Buffer.concat(this.buffers);
}
}
module.exports = PacketWriter;
+176
View File
@@ -0,0 +1,176 @@
function createBlockMapping() {
return {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
10: 10,
11: 11,
12: 12,
13: 13,
14: 14,
15: 15,
16: 16,
17: 17,
18: 18,
19: 19,
20: 20,
21: 21,
22: 22,
23: 23,
24: 24,
25: 25,
26: 26,
27: 27,
28: 28,
29: 29,
30: 30,
31: 31,
32: 32,
33: 33,
34: 34,
35: 35,
36: 36,
37: 37,
38: 38,
39: 39,
40: 40,
41: 41,
42: 42,
43: 43,
44: 44,
45: 45,
46: 46,
47: 47,
48: 48,
49: 49,
50: 50,
51: 51,
52: 52,
53: 53,
54: 54,
55: 55,
56: 56,
57: 57,
58: 58,
59: 59,
60: 60,
61: 61,
62: 62,
63: 63,
64: 64,
65: 65,
66: 66,
67: 67,
68: 68,
69: 69,
70: 70,
71: 71,
72: 72,
73: 73,
74: 74,
75: 75,
76: 76,
77: 77,
78: 78,
79: 79,
80: 80,
81: 81,
82: 82,
83: 83,
84: 84,
85: 85,
86: 86,
87: 87,
88: 88,
89: 89,
90: 90,
91: 91,
92: 92,
93: 93,
94: 94,
95: 95,
96: 96,
97: 97,
98: 98,
99: 99,
100: 100,
101: 101,
102: 102,
103: 103,
104: 104,
105: 105,
106: 106,
107: 107,
108: 108,
109: 109,
110: 110,
111: 111,
112: 112,
113: 113,
114: 114,
115: 115,
116: 116,
117: 117,
118: 118,
119: 119,
120: 120,
121: 121,
122: 122,
123: 123,
124: 124,
125: 125,
126: 126,
127: 127,
128: 128,
129: 129,
130: 130,
131: 131,
132: 132,
133: 133,
134: 134,
135: 135,
136: 136,
137: 137,
138: 138,
139: 139,
140: 140,
141: 141,
142: 142,
143: 143,
144: 144,
145: 145,
146: 146,
147: 147,
148: 148,
149: 149,
150: 150,
151: 151,
152: 152,
153: 153,
154: 154,
155: 155,
156: 156,
157: 157,
158: 158,
159: 159,
160: 160,
161: 18,
162: 17,
163: 17,
170: 170,
171: 171,
172: 172,
173: 173,
174: 174,
175: 31,
};
}
module.exports = { createBlockMapping };
+67
View File
@@ -0,0 +1,67 @@
function createEntityTypeMapping() {
return {
//monsters
Creeper: 50,
Skeleton: 51,
Spider: 52,
Giant: 53,
Zombie: 54,
Slime: 55,
Ghast: 56,
PigZombie: 57,
Enderman: 58,
CaveSpider: 59,
Silverfish: 60,
Blaze: 61,
LavaSlime: 62,
EnderDragon: 63,
WitherBoss: 64,
Bat: 65,
Witch: 66,
//animals
Pig: 90,
Sheep: 91,
Cow: 92,
Chicken: 93,
Squid: 94,
Wolf: 95,
MushroomCow: 96,
SnowMan: 97,
Ozelot: 98,
VillagerGolem: 99,
EntityHorse: 100,
//npcs
Villager: 120,
//projectile & entities
Item: 1,
XPOrb: 2,
Painting: 9,
Arrow: 10,
Snowball: 11,
Fireball: 12,
SmallFireball: 13,
ThrownEnderpearl: 14,
EyeOfEnderSignal: 15,
ThrownPotion: 16,
ThrownExpBottle: 17,
ItemFrame: 18,
WitherSkull: 19,
PrimedTnt: 20,
FallingSand: 21,
FireworksRocketEntity: 22,
//transport
Boat: 41,
MinecartRideable: 42,
MinecartChest: 43,
MinecartFurnace: 44,
MinecartTNT: 45,
MinecartHopper: 46,
MinecartSpawner: 47,
};
}
module.exports = { createEntityTypeMapping };
+27
View File
@@ -0,0 +1,27 @@
const { mapJavaBlockToLCE: mapBlockId } = require("./mappers");
function mapJavaEntityIdToLce(client, javaEntityId) {
if (!client.javaToLceEntityId.has(javaEntityId)) {
const lceEntityId = client.nextLceEntityId++;
if (lceEntityId > 32767) {
return 100;
}
client.javaToLceEntityId.set(javaEntityId, lceEntityId);
}
return client.javaToLceEntityId.get(javaEntityId);
}
function mapJavaBlockToLCE(javaBlockId) {
return mapBlockId(javaBlockId);
}
function mapJavaParticleToLCE(particleId) {
const particleMap = {};
return particleMap[particleId] || "";
}
module.exports = {
mapJavaEntityIdToLce,
mapJavaBlockToLCE,
mapJavaParticleToLCE,
};
+21
View File
@@ -0,0 +1,21 @@
const { createEntityTypeMapping } = require("./entityMapping");
const { createItemMapping } = require("./itemMapping");
const { createBlockMapping } = require("./blockMapping");
const {
mapJavaBlockToLCE,
mapJavaParticleToLCE,
mapJavaItemToLCE,
mapLCEItemToJava,
mapLCEBlockToJava,
} = require("./mappers");
module.exports = {
createEntityTypeMapping,
createItemMapping,
createBlockMapping,
mapJavaBlockToLCE,
mapJavaParticleToLCE,
mapJavaItemToLCE,
mapLCEItemToJava,
mapLCEBlockToJava,
};
+174
View File
@@ -0,0 +1,174 @@
function createItemMapping() {
return {
256: 256, //iron_shovel
257: 257, //iron_pickaxe
258: 258, //iron_axe
259: 259, //flint_and_steel
260: 260, //apple
261: 261, //bow
262: 262, //arrow
263: 263, //coal
264: 264, //diamond
265: 265, //iron_ingot
266: 266, //gold_ingot
267: 267, //iron_sword
268: 268, //wooden_sword
269: 269, //wooden_shovel
270: 270, //wooden_pickaxe
271: 271, //wooden_axe
272: 272, //stone_sword
273: 273, //stone_shovel
274: 274, //stone_pickaxe
275: 275, //stone_axe
276: 276, //diamond_sword
277: 277, //diamond_shovel
278: 278, //diamond_pickaxe
279: 279, //diamond_axe
280: 280, //stick
281: 281, //bowl
282: 282, //mushroom_stew
283: 283, //golden_sword
284: 284, //golden_shovel
285: 285, //golden_pickaxe
286: 286, //golden_axe
287: 287, //string
288: 288, //feather
289: 289, //gunpowder
290: 290, //wooden_hoe
291: 291, //stone_hoe
292: 292, //iron_hoe
293: 293, //diamond_hoe
294: 294, //golden_hoe
295: 295, //wheat_seeds
296: 296, //wheat
297: 297, //bread
298: 298, //leather_helmet
299: 299, //leather_chestplate
300: 300, //leather_leggings
301: 301, //leather_boots
302: 302, //chainmail_helmet
303: 303, //chainmail_chestplate
304: 304, //chainmail_leggings
305: 305, //chainmail_boots
306: 306, //iron_helmet
307: 307, //iron_chestplate
308: 308, //iron_leggings
309: 309, //iron_boots
310: 310, //diamond_helmet
311: 311, //diamond_chestplate
312: 312, //diamond_leggings
313: 313, //diamond_boots
314: 314, //golden_helmet
315: 315, //golden_chestplate
316: 316, //golden_leggings
317: 317, //golden_boots
318: 318, //flint
319: 319, //porkchop
320: 320, //cooked_porkchop
321: 321, //painting
322: 322, //golden_apple
323: 323, //sign
324: 324, //wooden_door
325: 325, //bucket
326: 326, //water_bucket
327: 327, //lava_bucket
328: 328, //minecart
329: 329, //saddle
330: 330, //iron_door
331: 331, //redstone
332: 332, //snowball
333: 333, //boat
334: 334, //leather
335: 335, //milk_bucket
336: 336, //brick
337: 337, //clay_ball
338: 338, //reeds (sugar_cane)
339: 339, //paper
340: 340, //book
341: 341, //slime_ball
342: 342, //chest_minecart
343: 343, //furnace_minecart
344: 344, //egg
345: 345, //compass
346: 346, //fishing_rod
347: 347, //clock
348: 348, //glowstone_dust
349: 349, //fish (raw)
350: 350, //cooked_fish
351: 351, //dye
352: 352, //bone
353: 353, //sugar
354: 354, //cake
355: 355, //bed
356: 356, //repeater
357: 357, //cookie
358: 358, //filled_map
359: 359, //shears
360: 360, //melon
361: 361, //pumpkin_seeds
362: 362, //melon_seeds
363: 363, //beef
364: 364, //cooked_beef
365: 365, //chicken
366: 366, //cooked_chicken
367: 367, //rotten_flesh
368: 368, //ender_pearl
369: 369, //blaze_rod
370: 370, //ghast_tear
371: 371, //gold_nugget
372: 372, //nether_wart
373: 373, //potion
374: 374, //glass_bottle
375: 375, //spider_eye
376: 376, //fermented_spider_eye
377: 377, //blaze_powder
378: 378, //magma_cream
379: 379, //brewing_stand
380: 380, //cauldron
381: 381, //ender_eye
382: 382, //speckled_melon
383: 383, //spawn_egg
384: 384, //experience_bottle
385: 385, //fire_charge
388: 388, //emerald
389: 389, //item_frame
390: 390, //flower_pot
391: 391, //carrot
392: 392, //potato
393: 393, //baked_potato
394: 394, //poisonous_potato
395: 395, //map (empty_map)
396: 396, //golden_carrot
397: 397, //skull
398: 398, //carrot_on_a_stick
399: 399, //nether_star
400: 400, //pumpkin_pie
401: 401, //fireworks (firework_rocket)
402: 402, //firework_charge (firework_star)
403: 403, //enchanted_book
404: 404, //comparator
405: 405, //netherbrick (nether_brick item)
406: 406, //quartz
407: 407, //tnt_minecart
408: 408, //hopper_minecart
417: 417, //iron_horse_armor
418: 418, //golden_horse_armor
419: 419, //diamond_horse_armor
420: 420, //lead
421: 421, //name_tag
2256: 2256, //record_13
2257: 2257, //record_cat
2258: 2258, //record_blocks
2259: 2259, //record_chirp
2260: 2260, //record_far
2261: 2261, //record_mall
2262: 2262, //record_mellohi
2263: 2263, //record_stal
2264: 2264, //record_strad
2265: 2265, //record_ward
2266: 2266, //record_11
2267: 2267, //record_wait (4J exclusive!!)
};
}
module.exports = { createItemMapping };
+121
View File
@@ -0,0 +1,121 @@
function mapJavaBlockToLCE(javaBlockId, javaBlockMapping) {
if (javaBlockMapping[javaBlockId] !== undefined) {
return javaBlockMapping[javaBlockId];
}
return 0;
}
function mapJavaParticleToLCE(particleId) {
const particleMap = {
0: "explode",
1: "largeexplode",
2: "hugeexplosion",
3: "fireworksSpark",
4: "bubble",
5: "splash",
6: "wake",
7: "suspended",
8: "depthsuspend",
9: "crit",
10: "magicCrit",
11: "smoke",
12: "largesmoke",
13: "spell",
14: "instantSpell",
15: "mobSpell",
16: "mobSpellAmbient",
17: "witchMagic",
18: "dripWater",
19: "dripLava",
20: "angryVillager",
21: "happyVillager",
22: "townaura",
23: "note",
24: "portal",
25: "enchantmenttable",
26: "flame",
27: "lava",
28: "footstep",
29: "cloud",
30: "reddust",
31: "snowballpoof",
32: "snowshovel",
33: "slime",
34: "heart",
35: "barrier",
36: "iconcrack",
37: "blockcrack",
38: "blockdust",
39: "droplet",
40: "take",
41: "mobappearance",
42: "dragonbreath",
43: "endrod",
44: "damageindicator",
45: "sweepattack",
};
return particleMap[particleId] || null;
}
function mapJavaItemToLCE(javaItemId) {
if (javaItemId >= 0 && javaItemId <= 255) {
return this.mapJavaBlockToLCE(javaItemId);
}
if (this.javaItemMapping[javaItemId] !== undefined) {
return this.javaItemMapping[javaItemId];
}
if (
(javaItemId >= 256 && javaItemId <= 421) ||
(javaItemId >= 2256 && javaItemId <= 2267)
) {
return javaItemId;
}
return 1;
}
function mapLCEItemToJava(lceItemId) {
if (lceItemId >= 0 && lceItemId <= 255) {
return this.mapLCEBlockToJava(lceItemId);
}
if (
(lceItemId >= 256 && lceItemId <= 421) ||
(lceItemId >= 2256 && lceItemId <= 2267)
) {
for (const [javaId, lceId] of Object.entries(this.javaItemMapping)) {
if (lceId === lceItemId) {
return parseInt(javaId);
}
}
return lceItemId;
}
return null;
}
function mapLCEBlockToJava(lceBlockId) {
for (const [javaId, lceId] of Object.entries(this.javaBlockMapping)) {
if (lceId === lceBlockId) {
return parseInt(javaId);
}
}
if (lceBlockId >= 0 && lceBlockId <= 174) {
return lceBlockId;
}
return null;
}
module.exports = {
mapJavaBlockToLCE,
mapJavaParticleToLCE,
mapJavaItemToLCE,
mapLCEItemToJava,
mapLCEBlockToJava,
};
+229
View File
@@ -0,0 +1,229 @@
function mapJavaSoundToLCE(soundName) {
const soundMap = {
"mob.chicken.say": 0,
"mob.chicken": 0,
"entity.chicken.ambient": 0,
"entity.chicken.step": 0,
"mob.chicken.hurt": 1,
"entity.chicken.hurt": 1,
"mob.chicken.plop": 2,
"mob.cow.say": 3,
"mob.cow": 3,
"mob.cow.hurt": 4,
"mob.pig.say": 5,
"mob.pig": 5,
"mob.pig.death": 6,
"mob.sheep.say": 7,
"mob.sheep": 7,
"mob.sheep.death": 7,
"mob.wolf.growl": 8,
"mob.wolf.whine": 9,
"mob.wolf.panting": 10,
"mob.wolf.bark": 11,
"mob.wolf.hurt": 12,
"mob.wolf.death": 13,
"mob.wolf.shake": 14,
"mob.blaze.breathe": 15,
"mob.blaze.hit": 16,
"mob.blaze.death": 17,
"mob.ghast.moan": 18,
"mob.ghast.scream": 19,
"mob.ghast.death": 20,
"mob.ghast.fireball": 21,
"mob.ghast.charge": 22,
"mob.endermen.idle": 23,
"mob.endermen.hit": 24,
"mob.endermen.death": 25,
"mob.endermen.portal": 26,
"mob.zombiepig.zpig": 27,
"mob.zombiepig.zpighurt": 28,
"mob.zombiepig.zpigdeath": 29,
"mob.zombiepig.zpigangry": 30,
"mob.silverfish.say": 31,
"mob.silverfish.hit": 32,
"mob.silverfish.kill": 33,
"mob.silverfish.step": 34,
"mob.skeleton.say": 35,
"mob.skeleton": 35,
"mob.skeleton.hurt": 36,
"mob.spider.say": 37,
"mob.spider.death": 38,
"mob.slime.small": 39,
"mob.slime.attack": 40,
"mob.creeper.say": 41,
"mob.creeper.death": 42,
"mob.zombie.say": 43,
"mob.zombie.hurt": 44,
"mob.zombie.death": 45,
"mob.zombie.wood": 46,
"mob.zombie.woodbreak": 47,
"mob.zombie.metal": 48,
"mob.magmacube.big": 49,
"mob.magmacube.small": 50,
"mob.cat.purr": 51,
"mob.cat.purreow": 52,
"mob.cat.meow": 52,
"mob.cat.hiss": 53,
"random.bow": 55,
"random.bowhit": 56,
"random.explode": 57,
"random.fizz": 58,
"random.pop": 59,
"entity.item.pickup": 59,
"item.pickup": 59,
"random.fuse": 60,
"random.drink": 61,
"random.eat": 62,
"random.burp": 63,
"random.splash": 64,
"random.click": 65,
"dig.glass": 66,
"random.orb": 67,
"random.break": 68,
"random.chestopen": 69,
"random.chestclosed": 70,
"random.door_open": 71,
"random.door_close": 72,
"ambient.weather.rain": 73,
"ambient.weather.thunder": 74,
"ambient.cave.cave": 75,
"portal.portal": 77,
"portal.trigger": 78,
"portal.travel": 79,
"fire.ignite": 80,
"fire.fire": 81,
"damage.hit": 82,
"game.player.hurt": 83,
"game.player.hurt.fall.small": 83,
"game.player.hurt.fall.big": 84,
"game.hostile.hurt.fall.small": 83,
"game.hostile.hurt.fall.big": 84,
"game.neutral.hurt.fall.small": 83,
"game.neutral.hurt.fall.big": 84,
"damage.fallsmall": 83,
"damage.fallbig": 84,
"note.harp": 85,
"note.bd": 86,
"note.snare": 87,
"note.hat": 88,
"note.bassattack": 89,
"note.bass": 89,
"note.pling": 85,
"tile.piston.in": 90,
"tile.piston.out": 91,
"liquid.water": 92,
"liquid.lavapop": 93,
"liquid.lava": 94,
"step.stone": 95,
"step.wood": 96,
"step.gravel": 97,
"step.grass": 98,
"step.metal": 99,
"step.cloth": 100,
"step.sand": 101,
"mob.enderdragon.end": 102,
"mob.enderdragon.growl": 103,
"mob.enderdragon.hit": 104,
"mob.enderdragon.wings": 105,
"mob.irongolem.throw": 106,
"mob.irongolem.hit": 107,
"mob.irongolem.death": 108,
"mob.irongolem.walk": 109,
"damage.thorns": 109,
"random.anvil_break": 110,
"random.anvil_land": 111,
"random.anvil_use": 112,
"mob.villager.haggle": 113,
"mob.villager.idle": 114,
"mob.villager.hit": 115,
"mob.villager.death": 116,
"mob.villager.yes": 117,
"mob.villager.no": 118,
"mob.zombie.infect": 120,
"mob.zombie.unfect": 121,
"mob.zombie.remedy": 122,
"step.snow": 123,
"step.ladder": 124,
"dig.cloth": 124,
"dig.grass": 125,
"dig.gravel": 126,
"dig.sand": 127,
"dig.snow": 128,
"dig.stone": 129,
"dig.wood": 130,
"fireworks.launch": 132,
"fireworks.blast": 133,
"fireworks.blast_far": 134,
"fireworks.largeBlast": 135,
"fireworks.largeBlast_far": 136,
"fireworks.twinkle": 137,
"fireworks.twinkle_far": 138,
"mob.bat.idle": 139,
"mob.bat.hurt": 140,
"mob.bat.death": 141,
"mob.bat.takeoff": 142,
"mob.wither.spawn": 142,
"mob.wither.idle": 143,
"mob.wither.hurt": 144,
"mob.wither.death": 145,
"mob.wither.shoot": 146,
"mob.cow.step": 148,
"step.cow": 148,
"mob.chicken.step": 149,
"step.chicken": 149,
"mob.pig.step": 150,
"step.pig": 150,
"mob.endermen.stare": 151,
"mob.endermen.scream": 152,
"mob.sheep.shear": 153,
"mob.sheep.step": 154,
"mob.skeleton.death": 155,
"mob.skeletondeath": 155,
"mob.skeleton.step": 156,
"mob.spider.step": 157,
"mob.wolf.step": 158,
"mob.zombie.step": 159,
"liquid.swim": 160,
"game.player.swim": 159,
"game.player.swim.splash": 64,
"game.hostile.swim.splash": 64,
"game.neutral.swim.splash": 64,
"game.neutral.swim": 159,
"game.hostile.swim": 159,
"mob.horse.land": 161,
"mob.horse.armor": 162,
"mob.horse.leather": 163,
"mob.horse.zombie.death": 164,
"mob.horse.skeleton.death": 165,
"mob.horse.donkey.death": 166,
"mob.horse.death": 167,
"mob.horse.zombie.hit": 168,
"mob.horse.skeleton.hit": 169,
"mob.horse.donkey.hit": 170,
"mob.horse.hit": 171,
"mob.horse.zombie.idle": 172,
"mob.horse.skeleton.idle": 173,
"mob.horse.donkey.idle": 174,
"mob.horse.idle": 175,
"mob.horse.donkey.angry": 176,
"mob.horse.angry": 177,
"mob.horse.gallop": 178,
"mob.horse.breathe": 179,
"mob.horse.wood": 180,
"mob.horse.soft": 181,
"mob.horse.jump": 182,
"mob.witch.idle": 183,
"mob.witch.hurt": 184,
"mob.witch.death": 185,
"mob.slime.big": 186,
"mob.slime": 187,
eat: 187,
"random.levelup": 188,
"fire.active": 189,
};
const result = soundMap[soundName];
return result !== undefined ? result : -1;
}
module.exports = { mapJavaSoundToLCE };
+48
View File
@@ -0,0 +1,48 @@
const PacketWriter = require("../../PacketWriter");
function sendContainerOpenPacket(proxy, client, packet) {
const windowTypeMapping = {
"minecraft:container": 0, //container
"minecraft:chest": 0, //container
"minecraft:crafting_table": 1, //workbench
"minecraft:furnace": 2, //furnace
"minecraft:dispenser": 3, //trap
"minecraft:enchanting_table": 4, //enchantment
"minecraft:brewing_stand": 5, //brewing_stand
"minecraft:villager": 6, //trader npc
"minecraft:beacon": 7, //beacon
"minecraft:anvil": 8, //repair table
"minecraft:hopper": 9, //hopper
"minecraft:dropper": 10, //dropper
"minecraft:horse": 11, //horse
};
const windowType = packet.inventoryType || packet.windowType;
const lceType = windowTypeMapping[windowType] || 0;
const containerId = packet.windowId;
const title = packet.windowTitle
? JSON.parse(packet.windowTitle).text || ""
: "";
const size = packet.slotCount || 27;
const customName = title.length > 0;
const writer = new PacketWriter();
writer.writeByte(containerId & 0xff);
writer.writeByte(lceType & 0xff);
writer.writeByte(size & 0xff);
writer.writeBoolean(customName);
if (lceType === 11) { //horse
writer.writeInt(packet.entityId || 0);
}
if (customName) {
writer.writeUtf(title);
}
proxy.sendPacket(client, 0x64, writer.toBuffer());
}
module.exports = {
sendContainerOpenPacket,
};
+544
View File
@@ -0,0 +1,544 @@
const PacketWriter = require("../../PacketWriter");
function sendAddMobPacket(proxy, client, entityInfo) {
const entityKey = `${entityInfo.javaEntityId}`;
if (client._sentEntities && client._sentEntities.has(entityKey)) {
return;
}
if (!client._sentEntities) {
client._sentEntities = new Set();
}
client._sentEntities.add(entityKey);
const writer = new PacketWriter();
writer.writeShort(entityInfo.entityId);
writer.writeByte(entityInfo.type & 0xff);
writer.writeInt(Math.floor(entityInfo.x * 32));
writer.writeInt(Math.floor(entityInfo.y * 32));
writer.writeInt(Math.floor(entityInfo.z * 32));
const yRotByte = Math.floor(((entityInfo.yaw % 360) / 360) * 256) & 0xff;
const xRotByte = Math.floor(((entityInfo.pitch % 360) / 360) * 256) & 0xff;
const yHeadRotByte =
Math.floor(((entityInfo.headYaw % 360) / 360) * 256) & 0xff;
writer.writeByte(yRotByte);
writer.writeByte(xRotByte);
writer.writeByte(yHeadRotByte);
let velX = entityInfo.velocityX || 0;
let velY = entityInfo.velocityY || 0;
let velZ = entityInfo.velocityZ || 0;
velX = Math.max(-3.9, Math.min(3.9, velX));
velY = Math.max(-3.9, Math.min(3.9, velY));
velZ = Math.max(-3.9, Math.min(3.9, velZ));
const velocityX = Math.floor(velX * 8000);
const velocityY = Math.floor(velY * 8000);
const velocityZ = Math.floor(velZ * 8000);
writer.writeShort(velocityX);
writer.writeShort(velocityY);
writer.writeShort(velocityZ);
writer.writeByte((0 << 5) | 0);
writer.writeByte(0);
writer.writeByte((1 << 5) | 1);
writer.writeShort(300);
const agableMobTypes = [92, 91, 90, 93, 120];
if (agableMobTypes.includes(entityInfo.type)) {
const ageMetadata = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 12)
: null;
if (ageMetadata && ageMetadata.value !== undefined) {
writer.writeByte((2 << 5) | 12);
writer.writeInt(ageMetadata.value);
}
}
if (entityInfo.type === 120) {
const professionMetadata = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 16 && m.type === 2)
: null;
if (professionMetadata && professionMetadata.value !== undefined) {
writer.writeByte((2 << 5) | 16);
writer.writeInt(professionMetadata.value);
}
}
const customNameMeta = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 2 && m.type === 4)
: null;
if (customNameMeta && customNameMeta.value) {
writer.writeByte((4 << 5) | 10);
writer.writeUtf(customNameMeta.value);
}
const customNameVisibleMeta = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 3 && m.type === 0)
: null;
if (customNameVisibleMeta && customNameVisibleMeta.value !== undefined) {
writer.writeByte((0 << 5) | 11);
writer.writeByte(customNameVisibleMeta.value & 0xff);
}
if (entityInfo.type === 55 || entityInfo.type === 62) {
const sizeMetadata = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 16 && m.type === 0)
: null;
if (sizeMetadata && sizeMetadata.value !== undefined) {
writer.writeByte((0 << 5) | 16);
writer.writeByte(sizeMetadata.value & 0xff);
}
}
if (entityInfo.type === 51) {
const typeMetadata = entityInfo.metadata
? entityInfo.metadata.find((m) => m.key === 13 && m.type === 0)
: null;
if (typeMetadata && typeMetadata.value !== undefined) {
writer.writeByte((0 << 5) | 13);
writer.writeByte(typeMetadata.value & 0xff);
}
}
writer.writeByte(0x7f);
const payload = writer.toBuffer();
proxy.sendPacket(client, 0x18, payload);
}
function sendAddEntityPacket(proxy, client, entityInfo) {
const writer = new PacketWriter();
writer.writeShort(entityInfo.entityId);
writer.writeByte(entityInfo.type);
writer.writeInt(Math.floor(entityInfo.x * 32));
writer.writeInt(Math.floor(entityInfo.y * 32));
writer.writeInt(Math.floor(entityInfo.z * 32));
const yRotByte = Math.floor(((entityInfo.yaw % 360) / 360) * 256) & 0xff;
const xRotByte = Math.floor(((entityInfo.pitch % 360) / 360) * 256) & 0xff;
writer.writeByte(yRotByte);
writer.writeByte(xRotByte);
const data = entityInfo.data !== undefined ? entityInfo.data : -1;
writer.writeInt(data);
if (data > -1) {
const velocityX = entityInfo.velocityX || 0;
const velocityY = entityInfo.velocityY || 0;
const velocityZ = entityInfo.velocityZ || 0;
writer.writeShort(Math.max(-32768, Math.min(32767, velocityX)));
writer.writeShort(Math.max(-32768, Math.min(32767, velocityY)));
writer.writeShort(Math.max(-32768, Math.min(32767, velocityZ)));
}
proxy.sendPacket(client, 0x17, writer.toBuffer());
}
function sendMoveEntityPacketForEntity(
proxy,
client,
entity,
dX,
dY,
dZ,
includeRotation = false,
) {
if (Math.abs(dX) <= 127 && Math.abs(dY) <= 127 && Math.abs(dZ) <= 127) {
const writer = new PacketWriter();
writer.writeShort(entity.entityId);
writer.writeByte(dX & 0xff);
writer.writeByte(dY & 0xff);
writer.writeByte(dZ & 0xff);
if (includeRotation) {
const prevYaw =
entity.prevYaw !== undefined ? entity.prevYaw : entity.yaw;
const prevPitch =
entity.prevPitch !== undefined ? entity.prevPitch : entity.pitch;
let deltaYaw = entity.yaw - prevYaw;
let deltaPitch = entity.pitch - prevPitch;
while (deltaYaw > 180) deltaYaw -= 360;
while (deltaYaw < -180) deltaYaw += 360;
while (deltaPitch > 180) deltaPitch -= 360;
while (deltaPitch < -180) deltaPitch += 360;
const dYawByte = Math.floor((deltaYaw / 360) * 256) & 0xff;
const dPitchByte = Math.floor((deltaPitch / 360) * 256) & 0xff;
writer.writeByte(dYawByte);
writer.writeByte(dPitchByte);
entity.prevYaw = entity.yaw;
entity.prevPitch = entity.pitch;
proxy.sendPacket(client, 0x21, writer.toBuffer());
} else {
proxy.sendPacket(client, 0x1f, writer.toBuffer());
}
} else {
sendTeleportEntityPacketForEntity(proxy, client, entity);
}
}
function sendTeleportEntityPacketForEntity(proxy, client, entity) {
const writer = new PacketWriter();
writer.writeShort(entity.entityId);
writer.writeInt(Math.floor(entity.x * 32));
writer.writeInt(Math.floor(entity.y * 32));
writer.writeInt(Math.floor(entity.z * 32));
const yRotByte = Math.floor(((entity.yaw % 360) / 360) * 256) & 0xff;
const xRotByte = Math.floor(((entity.pitch % 360) / 360) * 256) & 0xff;
writer.writeByte(yRotByte);
writer.writeByte(xRotByte);
proxy.sendPacket(client, 34, writer.toBuffer());
}
function sendRotateEntityPacketForEntity(proxy, client, entity) {
const writer = new PacketWriter();
writer.writeShort(entity.entityId);
const prevYaw = entity.prevYaw !== undefined ? entity.prevYaw : entity.yaw;
const prevPitch =
entity.prevPitch !== undefined ? entity.prevPitch : entity.pitch;
let deltaYaw = entity.yaw - prevYaw;
let deltaPitch = entity.pitch - prevPitch;
while (deltaYaw > 180) deltaYaw -= 360;
while (deltaYaw < -180) deltaYaw += 360;
while (deltaPitch > 180) deltaPitch -= 360;
while (deltaPitch < -180) deltaPitch += 360;
const dYawByte = Math.floor((deltaYaw / 360) * 256) & 0xff;
const dPitchByte = Math.floor((deltaPitch / 360) * 256) & 0xff;
writer.writeByte(dYawByte);
writer.writeByte(dPitchByte);
entity.prevYaw = entity.yaw;
entity.prevPitch = entity.pitch;
proxy.sendPacket(client, 0x20, writer.toBuffer());
}
function sendRotateHeadPacketForEntity(proxy, client, entity) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
const yHeadRotByte = Math.floor(((entity.headYaw % 360) / 360) * 256) & 0xff;
writer.writeByte(yHeadRotByte);
proxy.sendPacket(client, 35, writer.toBuffer());
}
function sendEntityMetadataPacket(proxy, client, entity, metadata) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
for (const item of metadata) {
if (item.key === 12 && item.type === 0) {
const ageableMobTypes = [
"Pig",
"Cow",
"Sheep",
"Chicken",
"Wolf",
"Ocelot",
"MushroomCow",
];
const isAgeableMob = ageableMobTypes.includes(entity.javaType);
if (isAgeableMob && item.value === -1) {
const header = (2 << 5) | 12;
writer.writeByte(header);
writer.writeInt(-24000);
continue;
} else if (isAgeableMob && item.value === 0) {
const header = (2 << 5) | 12;
writer.writeByte(header);
writer.writeInt(0);
continue;
}
}
const header = (item.type << 5) | item.key;
writer.writeByte(header);
switch (item.type) {
case 0:
writer.writeByte(item.value & 0xff);
break;
case 1:
writer.writeShort(item.value);
break;
case 2:
writer.writeInt(item.value);
break;
case 3:
writer.writeFloat(item.value);
break;
case 4:
writer.writeUtf(item.value);
break;
case 5:
continue;
default:
continue;
}
}
writer.writeByte(0x7f);
proxy.sendPacket(client, 0x28, writer.toBuffer());
}
function sendSetEntityMotionPacket(proxy, client, entity) {
if (!entity || entity.entityId === undefined || entity.entityId < 0) {
return;
}
let xa = entity.velocityX || 0;
let ya = entity.velocityY || 0;
let za = entity.velocityZ || 0;
const maxVel = 31200;
xa = Math.max(-maxVel, Math.min(maxVel, xa));
ya = Math.max(-maxVel, Math.min(maxVel, ya));
za = Math.max(-maxVel, Math.min(maxVel, za));
const writer = new PacketWriter();
try {
const useBytes =
xa >= -2048 &&
xa < 2048 &&
ya >= -2048 &&
ya < 2048 &&
za >= -2048 &&
za < 2048;
if (useBytes) {
writer.writeShort((entity.entityId & 0x07ff) | 0x800);
const xByte = Math.floor(xa / 16);
const yByte = Math.floor(ya / 16);
const zByte = Math.floor(za / 16);
writer.writeSignedByte(xByte);
writer.writeSignedByte(yByte);
writer.writeSignedByte(zByte);
} else {
writer.writeShort(entity.entityId & 0x07ff);
writer.writeShort(xa);
writer.writeShort(ya);
writer.writeShort(za);
}
const payload = writer.toBuffer();
proxy.sendPacket(client, 0x1c, payload);
} catch (err) {
/* do nothing */
}
}
function sendEntityEventPacket(proxy, client, entity, eventId) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
writer.writeByte(eventId & 0xff);
proxy.sendPacket(client, 0x26, writer.toBuffer());
}
function sendSetEquippedItemPacket(proxy, client, entity, slot, item) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
writer.writeShort(slot);
if (!item || item.blockId === undefined || item.blockId === -1) {
writer.writeShort(-1);
proxy.sendPacket(client, 0x05, writer.toBuffer());
return;
}
const javaItemId = item.blockId;
const count = item.itemCount || 1;
let damage = item.itemDamage || 0;
const lceItemId = proxy.mapJavaItemToLCE(javaItemId);
if (lceItemId === 1 && javaItemId !== 1) {
damage = 0;
}
if (lceItemId === -1 || lceItemId === 0) {
writer.writeShort(-1);
proxy.sendPacket(client, 0x05, writer.toBuffer());
return;
}
if (
(lceItemId >= 1 && lceItemId <= 174) ||
(lceItemId >= 256 && lceItemId <= 421) ||
(lceItemId >= 2256 && lceItemId <= 2267)
) {
writer.writeShort(lceItemId);
writer.writeByte(count);
writer.writeShort(damage);
} else {
writer.writeShort(-1);
proxy.sendPacket(client, 0x05, writer.toBuffer());
return;
}
writer.writeShort(-1);
proxy.sendPacket(client, 0x05, writer.toBuffer());
}
function sendLevelParticlesPacket(
proxy,
client,
name,
x,
y,
z,
xDist,
yDist,
zDist,
maxSpeed,
count,
) {
const writer = new PacketWriter();
writer.writeString(name);
writer.writeFloat(x);
writer.writeFloat(y);
writer.writeFloat(z);
writer.writeFloat(xDist);
writer.writeFloat(yDist);
writer.writeFloat(zDist);
writer.writeFloat(maxSpeed);
writer.writeInt(count);
const buffer = writer.toBuffer();
proxy.sendPacket(client, 63, buffer);
}
function sendTileUpdatePacket(proxy, client, x, y, z, blockId, metadata) {
const writer = new PacketWriter();
writer.writeInt(x);
writer.writeByte(y & 0xff);
writer.writeInt(z);
writer.writeShort(blockId & 0xffff);
const levelIdx =
client.javaDimension === -1 ? 1 : client.javaDimension === 1 ? 2 : 0;
const dataLevel = ((levelIdx & 0xf) << 4) | (metadata & 0xf);
writer.writeByte(dataLevel);
const buffer = writer.toBuffer();
proxy.sendPacket(client, 53, buffer);
}
function sendSetItemDataPacket(proxy, client, entity, itemData) {
const lceItemId = proxy.mapJavaItemToLCE(itemData.blockId);
if (lceItemId === -1 || lceItemId === 0) {
return;
}
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
writer.writeByte((5 << 5) | 10);
writer.writeShort(lceItemId);
writer.writeByte(itemData.itemCount);
writer.writeShort(itemData.itemDamage);
writer.writeShort(-1);
writer.writeByte(0x7f);
const payload = writer.toBuffer();
proxy.sendPacket(client, 0x28, payload);
}
function sendSetEntityDataPacket(proxy, client, entity) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
const sharedFlagsHeader = (0 << 5) | 0;
writer.writeByte(sharedFlagsHeader);
writer.writeByte(0);
writer.writeByte(0x7f);
proxy.sendPacket(client, 0x27, writer.toBuffer());
}
function sendUpdateAttributesPacket(proxy, client, entity) {
const writer = new PacketWriter();
writer.writeInt(entity.entityId);
const attributes = [];
attributes.push({ id: 0, base: 20.0, modifiers: [] });
if (entity.type !== 94) {
attributes.push({ id: 3, base: 0.25, modifiers: [] });
}
if (entity.type >= 50 && entity.type <= 66) {
attributes.push({ id: 1, base: 32.0, modifiers: [] });
attributes.push({ id: 4, base: 2.0, modifiers: [] });
}
writer.writeInt(attributes.length);
for (const attr of attributes) {
writer.writeShort(attr.id);
writer.writeDouble(attr.base);
writer.writeShort(attr.modifiers.length);
}
const payload = writer.toBuffer();
proxy.sendPacket(client, 0x2c, payload);
}
function sendSetEntityLinkPacket(proxy, client, sourceId, destId, linkType) {
const writer = new PacketWriter();
writer.writeInt(sourceId);
writer.writeInt(destId);
writer.writeByte(linkType);
const buffer = writer.toBuffer();
proxy.sendPacket(client, 0x27, buffer);
}
module.exports = {
sendAddMobPacket,
sendAddEntityPacket,
sendMoveEntityPacketForEntity,
sendTeleportEntityPacketForEntity,
sendRotateEntityPacketForEntity,
sendRotateHeadPacketForEntity,
sendEntityMetadataPacket,
sendSetEntityMotionPacket,
sendEntityEventPacket,
sendSetEquippedItemPacket,
sendSetItemDataPacket,
sendSetEntityDataPacket,
sendUpdateAttributesPacket,
sendSetEntityLinkPacket,
};
+11
View File
@@ -0,0 +1,11 @@
const playerPackets = require("./playerPackets");
const entityPackets = require("./entityPackets");
const worldPackets = require("./worldPackets");
const containerPackets = require("./containerPackets");
module.exports = {
...playerPackets,
...entityPackets,
...worldPackets,
...containerPackets,
};
+115
View File
@@ -0,0 +1,115 @@
const PacketWriter = require("../../PacketWriter");
function sendMovePlayerPacket(proxy, client, x, y, z, yaw, pitch) {
const lceY = y + 1.65;
const moveWriter = new PacketWriter();
moveWriter.writeDouble(x);
moveWriter.writeDouble(lceY);
moveWriter.writeDouble(lceY + 1.62); //eye offset
moveWriter.writeDouble(z);
moveWriter.writeFloat(yaw);
moveWriter.writeFloat(pitch);
moveWriter.writeByte(0x01);
proxy.sendPacket(client, 0x0d, moveWriter.toBuffer());
}
function sendAddPlayerPacket(proxy, client, playerInfo) {
let playerName = playerInfo.name || "undefined";
if (playerName.length > 16) {
playerName = playerName.substring(0, 16);
}
if (playerName.length === 0) {
playerName = "undefined";
}
const writer = new PacketWriter();
writer.writeInt(playerInfo.entityId);
writer.writeString(playerName);
writer.writeInt(Math.floor(playerInfo.x * 32));
writer.writeInt(Math.floor(playerInfo.y * 32));
writer.writeInt(Math.floor(playerInfo.z * 32));
const yRotByte = Math.floor(((playerInfo.yaw % 360) / 360) * 256) & 0xff;
const xRotByte = Math.floor(((playerInfo.pitch % 360) / 360) * 256) & 0xff;
writer.writeByte(yRotByte);
writer.writeByte(xRotByte);
writer.writeByte(yRotByte);
writer.writeShort(0); //carriedItem
writer.writeLong(0); //xuid
writer.writeLong(0); //OnlineXuid
writer.writeByte(0); //playerIndex
writer.writeInt(0); //skinId
writer.writeInt(0); //capeId
writer.writeInt(0); //uiGamePrivileges
writer.writeByte(0x7f);
proxy.sendPacket(client, 0x14, writer.toBuffer());
}
function sendMoveEntityPacket(proxy, client, playerInfo) {
sendTeleportEntityPacket(proxy, client, playerInfo);
}
function sendTeleportEntityPacket(proxy, client, playerInfo) {
const writer = new PacketWriter();
writer.writeInt(playerInfo.entityId);
writer.writeInt(Math.floor(playerInfo.x * 32));
writer.writeInt(Math.floor(playerInfo.y * 32));
writer.writeInt(Math.floor(playerInfo.z * 32));
const yRotByte = Math.floor(((playerInfo.yaw % 360) / 360) * 256) & 0xff;
const xRotByte = Math.floor(((playerInfo.pitch % 360) / 360) * 256) & 0xff;
writer.writeByte(yRotByte);
writer.writeByte(xRotByte);
writer.writeByte(0x01); //onGround
proxy.sendPacket(client, 34, writer.toBuffer());
sendRotateHeadPacket(proxy, client, playerInfo);
}
function sendRotateHeadPacket(proxy, client, playerInfo) {
const writer = new PacketWriter();
writer.writeInt(playerInfo.entityId);
const yHeadRotByte = Math.floor(((playerInfo.yaw % 360) / 360) * 256) & 0xff;
writer.writeByte(yHeadRotByte);
proxy.sendPacket(client, 35, writer.toBuffer());
}
function sendChatPacket(
proxy,
client,
message,
messageType = 0,
customData = -1,
) {
const writer = new PacketWriter();
writer.writeInt(messageType);
writer.writeInt(1);
writer.writeString(message);
writer.writeInt(0);
if (customData !== -1) {
writer.writeInt(customData);
}
proxy.sendPacket(client, 3, writer.toBuffer());
}
module.exports = {
sendMovePlayerPacket,
sendAddPlayerPacket,
sendMoveEntityPacket,
sendTeleportEntityPacket,
sendRotateHeadPacket,
sendChatPacket,
};
+72
View File
@@ -0,0 +1,72 @@
const PacketWriter = require("../../PacketWriter");
function sendLevelSoundPacket(proxy, client, soundId, x, y, z, volume, pitch) {
const safeX = x !== undefined && x !== null && !isNaN(x) ? x : 0;
const safeY = y !== undefined && y !== null && !isNaN(y) ? y : 0;
const safeZ = z !== undefined && z !== null && !isNaN(z) ? z : 0;
const safeVolume =
volume !== undefined && volume !== null && !isNaN(volume) ? volume : 1.0;
const safePitch =
pitch !== undefined && pitch !== null && !isNaN(pitch) ? pitch : 1.0;
const writer = new PacketWriter();
writer.writeInt(soundId);
writer.writeInt(Math.floor(safeX * 8.0));
writer.writeInt(Math.floor(safeY * 8.0));
writer.writeInt(Math.floor(safeZ * 8.0));
writer.writeFloat(safeVolume);
writer.writeFloat(safePitch);
proxy.sendPacket(client, 0x3e, writer.toBuffer());
}
function sendLevelParticlesPacket(
proxy,
client,
name,
x,
y,
z,
xDist,
yDist,
zDist,
maxSpeed,
count,
) {
const writer = new PacketWriter();
writer.writeString(name);
writer.writeFloat(x);
writer.writeFloat(y);
writer.writeFloat(z);
writer.writeFloat(xDist);
writer.writeFloat(yDist);
writer.writeFloat(zDist);
writer.writeFloat(maxSpeed);
writer.writeInt(count);
const buffer = writer.toBuffer();
proxy.sendPacket(client, 63, buffer);
}
function sendTileUpdatePacket(proxy, client, x, y, z, blockId, metadata) {
const writer = new PacketWriter();
writer.writeInt(x);
writer.writeByte(y & 0xff);
writer.writeInt(z);
writer.writeShort(blockId & 0xffff);
const levelIdx =
client.javaDimension === -1 ? 1 : client.javaDimension === 1 ? 2 : 0;
const dataLevel = ((levelIdx & 0xf) << 4) | (metadata & 0xf);
writer.writeByte(dataLevel);
const buffer = writer.toBuffer();
proxy.sendPacket(client, 53, buffer);
}
module.exports = {
sendLevelSoundPacket,
sendLevelParticlesPacket,
sendTileUpdatePacket,
};
+16
View File
@@ -0,0 +1,16 @@
function encodeVarInt(value) {
const bytes = [];
do {
let temp = value & 0x7f;
value >>>= 7;
if (value !== 0) {
temp |= 0x80;
}
bytes.push(temp);
} while (value !== 0);
return Buffer.from(bytes);
}
module.exports = {
encodeVarInt,
};
+523
View File
@@ -0,0 +1,523 @@
function getTranslation(key, args = []) {
const translations = {
"chat.type.text": (args) => `<${args[0]}> ${args[1]}`,
"chat.type.announcement": (args) => `[${args[0]}] ${args[1]}`,
"chat.type.admin": (args) => `[${args[0]}] ${args[1]}`,
"chat.type.emote": (args) => `* ${args[0]} ${args[1]}`,
"multiplayer.player.joined": (args) => `${args[0]} joined the game`,
"multiplayer.player.left": (args) => `${args[0]} left the game`,
"death.attack.mob": (args) => `${args[0]} was slain by ${args[1]}`,
"death.attack.player": (args) => `${args[0]} was slain by ${args[1]}`,
"death.attack.player.item": (args) =>
`${args[0]} was slain by ${args[1]} using ${args[2]}`,
"death.attack.arrow": (args) => `${args[0]} was shot by ${args[1]}`,
"death.attack.arrow.item": (args) =>
`${args[0]} was shot by ${args[1]} using ${args[2]}`,
"death.attack.fireball": (args) =>
`${args[0]} was fireballed by ${args[1]}`,
"death.attack.fireball.item": (args) =>
`${args[0]} was fireballed by ${args[1]} using ${args[2]}`,
"death.attack.thrown": (args) => `${args[0]} was pummeled by ${args[1]}`,
"death.attack.thrown.item": (args) =>
`${args[0]} was pummeled by ${args[1]} using ${args[2]}`,
"death.attack.indirectMagic": (args) =>
`${args[0]} was killed by ${args[1]} using magic`,
"death.attack.indirectMagic.item": (args) =>
`${args[0]} was killed by ${args[1]} using ${args[2]}`,
"death.attack.thorns": (args) =>
`${args[0]} was killed trying to hurt ${args[1]}`,
"death.attack.fall": (args) => `${args[0]} hit the ground too hard`,
"death.attack.outOfWorld": (args) => `${args[0]} fell out of the world`,
"death.fell.accident.ladder": (args) => `${args[0]} fell off a ladder`,
"death.fell.accident.vines": (args) => `${args[0]} fell off some vines`,
"death.fell.accident.water": (args) => `${args[0]} fell out of the water`,
"death.fell.accident.generic": (args) =>
`${args[0]} fell from a high place`,
"death.fell.killer": (args) => `${args[0]} was doomed to fall`,
"death.fell.assist": (args) =>
`${args[0]} was doomed to fall by ${args[1]}`,
"death.fell.assist.item": (args) =>
`${args[0]} was doomed to fall by ${args[1]} using ${args[2]}`,
"death.fell.finish": (args) =>
`${args[0]} fell too far and was finished by ${args[1]}`,
"death.fell.finish.item": (args) =>
`${args[0]} fell too far and was finished by ${args[1]} using ${args[2]}`,
"death.attack.lightningBolt": (args) =>
`${args[0]} was struck by lightning`,
"death.attack.inFire": (args) => `${args[0]} went up in flames`,
"death.attack.inFire.player": (args) =>
`${args[0]} walked into fire whilst fighting ${args[1]}`,
"death.attack.onFire": (args) => `${args[0]} burned to death`,
"death.attack.onFire.player": (args) =>
`${args[0]} was burnt to a crisp whilst fighting ${args[1]}`,
"death.attack.lava": (args) => `${args[0]} tried to swim in lava`,
"death.attack.lava.player": (args) =>
`${args[0]} tried to swim in lava to escape ${args[1]}`,
"death.attack.inWall": (args) => `${args[0]} suffocated in a wall`,
"death.attack.drown": (args) => `${args[0]} drowned`,
"death.attack.drown.player": (args) =>
`${args[0]} drowned whilst trying to escape ${args[1]}`,
"death.attack.starve": (args) => `${args[0]} starved to death`,
"death.attack.cactus": (args) => `${args[0]} was pricked to death`,
"death.attack.cactus.player": (args) =>
`${args[0]} walked into a cactus whilst trying to escape ${args[1]}`,
"death.attack.generic": (args) => `${args[0]} died`,
"death.attack.explosion": (args) => `${args[0]} blew up`,
"death.attack.explosion.player": (args) =>
`${args[0]} was blown up by ${args[1]}`,
"death.attack.magic": (args) => `${args[0]} was killed by magic`,
"death.attack.wither": (args) => `${args[0]} withered away`,
"death.attack.anvil": (args) =>
`${args[0]} was squashed by a falling anvil`,
"death.attack.fallingBlock": (args) =>
`${args[0]} was squashed by a falling block`,
"commands.gamemode.success.self": (args) =>
`Set own game mode to ${args[0]}`,
"commands.gamemode.success.other": (args) =>
`Set ${args[0]}'s game mode to ${args[1]}`,
"gameMode.survival": () => "Survival Mode",
"gameMode.creative": () => "Creative Mode",
"gameMode.adventure": () => "Adventure Mode",
"gameMode.spectator": () => "Spectator Mode",
"gameMode.changed": () => "Your game mode has been updated",
"commands.time.set": (args) =>
args[0] ? `Set time to ${args[0]}` : "Set the time",
"commands.time.added": (args) =>
args[0] ? `Added ${args[0]} to the time` : "Added to the time",
"commands.time.query": (args) =>
args[0] ? `The time is ${args[0]}` : "Queried the time",
"commands.weather.clear": () => "Changed weather to clear",
"commands.weather.rain": () => "Changed weather to rain",
"commands.weather.thunder": () => "Changed weather to thunder",
"commands.tp.success": (args) => `Teleported ${args[0]} to ${args[1]}`,
"commands.tp.success.coordinates": (args) =>
`Teleported ${args[0]} to ${args[1]}, ${args[2]}, ${args[3]}`,
"commands.give.success": (args) => `Gave ${args[0]} ${args[1]} ${args[2]}`,
"commands.clear.success": (args) =>
`Cleared inventory of ${args[0]}, removing ${args[1]} items`,
"commands.kill.successful": (args) => `Killed ${args[0]}`,
"commands.xp.success": (args) => `Gave ${args[0]} experience to ${args[1]}`,
"commands.xp.success.levels": (args) =>
`Gave ${args[0]} levels to ${args[1]}`,
"commands.effect.success": (args) =>
`Given ${args[0]} to ${args[1]} for ${args[2]} seconds`,
"commands.effect.success.removed": (args) =>
`Took ${args[0]} from ${args[1]}`,
"commands.effect.success.removed.all": (args) =>
`Took all effects from ${args[0]}`,
"commands.difficulty.success": (args) => `Set difficulty to ${args[0]}`,
"options.difficulty.peaceful": () => "Peaceful",
"options.difficulty.easy": () => "Easy",
"options.difficulty.normal": () => "Normal",
"options.difficulty.hard": () => "Hard",
"commands.seed.success": (args) => `Seed: ${args[0]}`,
"commands.setworldspawn.success": (args) =>
`Set world spawn to ${args[0]}, ${args[1]}, ${args[2]}`,
"commands.spawnpoint.success": (args) =>
`Set ${args[0]}'s spawn point to ${args[1]}, ${args[2]}, ${args[3]}`,
"commands.gamerule.success": () => "Game rule has been updated",
"commands.op.success": (args) => `Made ${args[0]} a server operator`,
"commands.deop.success": (args) =>
`Made ${args[0]} no longer a server operator`,
"commands.ban.success": (args) => `Banned ${args[0]}`,
"commands.unban.success": (args) => `Unbanned ${args[0]}`,
"commands.banip.success": (args) => `Banned IP ${args[0]}`,
"commands.kick.success": (args) => `Kicked ${args[0]} from the game`,
"commands.say.usage": () => "Usage: /say <message>",
"commands.message.display.incoming": (args) =>
`${args[0]} whispers to you: ${args[1]}`,
"commands.message.display.outgoing": (args) =>
`You whisper to ${args[0]}: ${args[1]}`,
"achievement.get": () => "Achievement get!",
"achievement.taken": () => "Taken!",
"achievement.unknown": () => "???",
"achievement.requires": (args) => `Requires '${args[0]}'`,
"achievement.openInventory": () => "Taking Inventory",
"achievement.openInventory.desc": (args) =>
`Press '${args[0]}' to open your inventory.`,
"achievement.mineWood": () => "Getting Wood",
"achievement.mineWood.desc": () =>
"Attack a tree until a block of wood pops out",
"achievement.buildWorkBench": () => "Benchmarking",
"achievement.buildWorkBench.desc": () =>
"Craft a workbench with four blocks of planks",
"achievement.buildPickaxe": () => "Time to Mine!",
"achievement.buildPickaxe.desc": () =>
"Use planks and sticks to make a pickaxe",
"achievement.buildFurnace": () => "Hot Topic",
"achievement.buildFurnace.desc": () =>
"Construct a furnace out of eight stone blocks",
"achievement.acquireIron": () => "Acquire Hardware",
"achievement.acquireIron.desc": () => "Smelt an iron ingot",
"achievement.buildHoe": () => "Time to Farm!",
"achievement.buildHoe.desc": () => "Use planks and sticks to make a hoe",
"achievement.makeBread": () => "Bake Bread",
"achievement.makeBread.desc": () => "Turn wheat into bread",
"achievement.bakeCake": () => "The Lie",
"achievement.bakeCake.desc": () => "Wheat, sugar, milk and eggs!",
"achievement.buildBetterPickaxe": () => "Getting an Upgrade",
"achievement.buildBetterPickaxe.desc": () => "Construct a better pickaxe",
"achievement.overpowered": () => "Overpowered",
"achievement.overpowered.desc": () => "Build a Notch apple",
"achievement.cookFish": () => "Delicious Fish",
"achievement.cookFish.desc": () => "Catch and cook fish!",
"achievement.onARail": () => "On A Rail",
"achievement.onARail.desc": () =>
"Travel by minecart at least 1 km from where you started",
"achievement.buildSword": () => "Time to Strike!",
"achievement.buildSword.desc": () =>
"Use planks and sticks to make a sword",
"achievement.killEnemy": () => "Monster Hunter",
"achievement.killEnemy.desc": () => "Attack and destroy a monster",
"achievement.killCow": () => "Cow Tipper",
"achievement.killCow.desc": () => "Harvest some leather",
"achievement.breedCow": () => "Repopulation",
"achievement.breedCow.desc": () => "Breed two cows with wheat",
"achievement.flyPig": () => "When Pigs Fly",
"achievement.flyPig.desc": () => "Fly a pig off a cliff",
"achievement.snipeSkeleton": () => "Sniper Duel",
"achievement.snipeSkeleton.desc": () =>
"Kill a skeleton with an arrow from more than 50 meters",
"achievement.diamonds": () => "DIAMONDS!",
"achievement.diamonds.desc": () => "Acquire diamonds with your iron tools",
"achievement.diamondsToYou": () => "Diamonds to you!",
"achievement.diamondsToYou.desc": () => "Throw diamonds at another player.",
"achievement.portal": () => "We Need to Go Deeper",
"achievement.portal.desc": () => "Build a portal to the Nether",
"achievement.ghast": () => "Return to Sender",
"achievement.ghast.desc": () => "Destroy a Ghast with a fireball",
"achievement.blazeRod": () => "Into Fire",
"achievement.blazeRod.desc": () => "Relieve a Blaze of its rod",
"achievement.potion": () => "Local Brewery",
"achievement.potion.desc": () => "Brew a potion",
"achievement.theEnd": () => "The End?",
"achievement.theEnd.desc": () => "Locate the End",
"achievement.theEnd2": () => "The End.",
"achievement.theEnd2.desc": () => "Defeat the Ender Dragon",
"achievement.spawnWither": () => "The Beginning?",
"achievement.spawnWither.desc": () => "Spawn the Wither",
"achievement.killWither": () => "The Beginning.",
"achievement.killWither.desc": () => "Kill the Wither",
"achievement.fullBeacon": () => "Beaconator",
"achievement.fullBeacon.desc": () => "Create a full beacon",
"achievement.exploreAllBiomes": () => "Adventuring Time",
"achievement.exploreAllBiomes.desc": () => "Discover all biomes",
"achievement.enchantments": () => "Enchanter",
"achievement.enchantments.desc": () =>
"Use a book, obsidian and diamonds to construct an enchantment table",
"achievement.overkill": () => "Overkill",
"achievement.overkill.desc": () =>
"Deal nine hearts of damage in a single hit",
"achievement.bookcase": () => "Librarian",
"achievement.bookcase.desc": () =>
"Build some bookshelves to improve your enchantment table",
"commands.whitelist.add.success": (args) =>
`Added ${args[0]} to the whitelist`,
"commands.whitelist.remove.success": (args) =>
`Removed ${args[0]} from the whitelist`,
"commands.whitelist.enabled": () => "Whitelist is now turned on",
"commands.whitelist.disabled": () => "Whitelist is now turned off",
"commands.stop.start": () => "Stopping the server",
"commands.save.enabled": () => "Turned on world auto-saving",
"commands.save.disabled": () => "Turned off world auto-saving",
"commands.save.success": () => "Saved the world",
"commands.defaultgamemode.success": (args) =>
`Default game mode is now ${args[0]}`,
"commands.setblock.success": () => "Block placed",
"commands.fill.success": (args) => `Successfully filled ${args[0]} blocks`,
"commands.summon.success": () => "Object successfully summoned",
"commands.summon.failed": () => "Unable to summon object",
"commands.summon.outOfWorld": () =>
"Cannot summon the object out of the world",
"commands.me.usage": () => "/me <action>",
"commands.help.header": (args) =>
`--- Showing help page ${args[0]} of ${args[1]} (/help <page>) ---`,
"commands.help.footer": () =>
"Tip: Use the <tab> key while typing a command to auto-complete the command or its arguments",
"commands.players.list": (args) =>
`There are ${args[0]}/${args[1]} players online:`,
"commands.publish.started": (args) =>
`Local game hosted on port ${args[0]}`,
"commands.publish.failed": () => "Unable to host local game",
"commands.debug.start": () => "Started debug profiling",
"commands.debug.stop": (args) =>
`Stopped debug profiling after ${args[0]} seconds (${args[1]} ticks)`,
"commands.tellraw.jsonException": (args) => `Invalid json: ${args[0]}`,
"commands.message.sameTarget": () =>
"You can't send a private message to yourself!",
"commands.playsound.success": (args) =>
`Played sound '${args[0]}' to ${args[1]}`,
"commands.particle.success": (args) => `Playing effect ${args[0]}`,
"commands.particle.notFound": (args) => `Unknown effect name (${args[0]})`,
"commands.generic.exception": () =>
"An unknown error occurred while attempting to perform this command",
"commands.generic.permission": () =>
"You do not have permission to use this command",
"commands.generic.syntax": () => "Invalid command syntax",
"commands.generic.player.notFound": () => "That player cannot be found",
"commands.generic.entity.notFound": () => "That entity cannot be found",
"commands.generic.notFound": () =>
"Unknown command. Try /help for a list of commands",
"commands.generic.num.invalid": (args) =>
`'${args[0]}' is not a valid number`,
"commands.generic.num.tooSmall": (args) =>
`The number you have entered (${args[0]}) is too small, it must be at least ${args[1]}`,
"commands.generic.num.tooBig": (args) =>
`The number you have entered (${args[0]}) is too big, it must be at most ${args[1]}`,
"commands.generic.usage": (args) => `Usage: ${args[0]}`,
"commands.achievement.unknownAchievement": (args) =>
`Unknown achievement or statistic '${args[0]}'`,
"commands.achievement.alreadyHave": (args) =>
`Player ${args[0]} already has achievement ${args[1]}`,
"commands.achievement.give.success.one": (args) =>
`Successfully given ${args[0]} the stat ${args[1]}`,
"commands.achievement.give.success.all": (args) =>
`Successfully given all achievements to ${args[0]}`,
"commands.testfor.success": (args) => `Found ${args[0]}`,
"commands.testfor.failure": (args) =>
`${args[0]} did not match the required data structure`,
"commands.scoreboard.objectives.add.success": (args) =>
`Added new objective '${args[0]}' successfully`,
"commands.scoreboard.objectives.remove.success": (args) =>
`Removed objective '${args[0]}' successfully`,
"commands.scoreboard.objectives.setdisplay.successSet": (args) =>
`Set the display objective in slot '${args[0]}' to '${args[1]}'`,
"commands.scoreboard.players.set.success": (args) =>
`Set score of ${args[1]} for player ${args[0]} to ${args[2]}`,
"commands.scoreboard.players.add.success": (args) =>
`Added ${args[2]} to ${args[1]} for ${args[0]} (now ${args[3]})`,
"commands.scoreboard.players.reset.success": (args) =>
`Reset scores of player ${args[0]}`,
"commands.scoreboard.teams.add.success": (args) =>
`Added new team '${args[0]}' successfully`,
"commands.scoreboard.teams.remove.success": (args) =>
`Removed team ${args[0]}`,
"commands.scoreboard.teams.join.success": (args) =>
`Added ${args[0]} player(s) to team ${args[1]}: ${args[2]}`,
"commands.execute.failed": (args) =>
`Failed to execute '${args[0]}' as ${args[1]}`,
"commands.testforblock.success": (args) =>
`Successfully found the block at ${args[0]},${args[1]},${args[2]}.`,
"commands.testforblock.failed.tile": (args) =>
`The block at ${args[0]},${args[1]},${args[2]} is ${args[3]} (expected: ${args[4]}).`,
"commands.setblock.success": () => "Block placed",
"commands.setblock.failed": () => "Unable to place block",
"commands.fill.success": (args) => `Successfully filled ${args[0]} blocks`,
"commands.fill.failed": () => "No blocks filled",
"commands.clone.success": (args) => `Successfully cloned ${args[0]} blocks`,
"commands.clone.failed": () => "No blocks cloned",
"commands.blockdata.success": (args) => `Block data updated to: ${args[0]}`,
"commands.entitydata.success": (args) =>
`Entity data updated to: ${args[0]}`,
"commands.enchant.success": () => "Enchanting succeeded",
"commands.enchant.notFound": (args) =>
`There is no such enchantment with ID ${args[0]}`,
"commands.replaceitem.success": (args) =>
`Replaced slot ${args[0]} with ${args[1]} * ${args[2]}`,
"commands.replaceitem.failed": (args) =>
`Could not replace slot ${args[0]} with ${args[1]} * ${args[2]}`,
"commands.stats.success": (args) =>
`Storing ${args[0]} stats in ${args[1]} on ${args[2]}`,
"commands.trigger.success": (args) =>
`Trigger ${args[0]} changed with ${args[1]} ${args[2]}`,
"commands.spreadplayers.success.teams": (args) =>
`Successfully spread ${args[0]} teams around ${args[1]},${args[2]}`,
"commands.spreadplayers.success.players": (args) =>
`Successfully spread ${args[0]} players around ${args[1]},${args[2]}`,
"commands.worldborder.set.success": (args) =>
`Set world border to ${args[0]} blocks wide (from ${args[1]} blocks)`,
"commands.worldborder.center.success": (args) =>
`Set world border center to ${args[0]},${args[1]}`,
"commands.title.success": () => "Title command successfully executed",
"entity.Item.name": () => "Item",
"entity.XPOrb.name": () => "Experience Orb",
"entity.SmallFireball.name": () => "Small Fireball",
"entity.Fireball.name": () => "Fireball",
"entity.Arrow.name": () => "Arrow",
"entity.Snowball.name": () => "Snowball",
"entity.Painting.name": () => "Painting",
"entity.ArmorStand.name": () => "Armor Stand",
"entity.Mob.name": () => "Mob",
"entity.Monster.name": () => "Monster",
"entity.Creeper.name": () => "Creeper",
"entity.Skeleton.name": () => "Skeleton",
"entity.Spider.name": () => "Spider",
"entity.Giant.name": () => "Giant",
"entity.Zombie.name": () => "Zombie",
"entity.Slime.name": () => "Slime",
"entity.Ghast.name": () => "Ghast",
"entity.PigZombie.name": () => "Zombie Pigman",
"entity.Enderman.name": () => "Enderman",
"entity.Endermite.name": () => "Endermite",
"entity.Silverfish.name": () => "Silverfish",
"entity.CaveSpider.name": () => "Cave Spider",
"entity.Blaze.name": () => "Blaze",
"entity.LavaSlime.name": () => "Magma Cube",
"entity.MushroomCow.name": () => "Mooshroom",
"entity.Villager.name": () => "Villager",
"entity.VillagerGolem.name": () => "Iron Golem",
"entity.SnowMan.name": () => "Snow Golem",
"entity.EnderDragon.name": () => "Ender Dragon",
"entity.WitherBoss.name": () => "Wither",
"entity.Witch.name": () => "Witch",
"entity.Guardian.name": () => "Guardian",
"entity.Pig.name": () => "Pig",
"entity.Sheep.name": () => "Sheep",
"entity.Cow.name": () => "Cow",
"entity.Chicken.name": () => "Chicken",
"entity.Squid.name": () => "Squid",
"entity.Wolf.name": () => "Wolf",
"entity.Ozelot.name": () => "Ocelot",
"entity.Cat.name": () => "Cat",
"entity.Bat.name": () => "Bat",
"entity.EntityHorse.name": () => "Horse",
"entity.horse.name": () => "Horse",
"entity.donkey.name": () => "Donkey",
"entity.mule.name": () => "Mule",
"entity.skeletonhorse.name": () => "Skeleton Horse",
"entity.zombiehorse.name": () => "Zombie Horse",
"entity.Rabbit.name": () => "Rabbit",
"entity.KillerBunny.name": () => "The Killer Bunny",
"entity.PrimedTnt.name": () => "Block of TNT",
"entity.FallingSand.name": () => "Falling Block",
"entity.Minecart.name": () => "Minecart",
"entity.Boat.name": () => "Boat",
"entity.generic.name": () => "unknown",
"entity.Villager.farmer": () => "Farmer",
"entity.Villager.fisherman": () => "Fisherman",
"entity.Villager.shepherd": () => "Shepherd",
"entity.Villager.fletcher": () => "Fletcher",
"entity.Villager.librarian": () => "Librarian",
"entity.Villager.cleric": () => "Cleric",
"entity.Villager.armor": () => "Armorer",
"entity.Villager.weapon": () => "Weapon Smith",
"entity.Villager.tool": () => "Tool Smith",
"entity.Villager.butcher": () => "Butcher",
"entity.Villager.leather": () => "Leatherworker",
};
const translationFunc = translations[key];
if (translationFunc) {
return translationFunc(args);
}
if (args.length > 0) {
return `${key}: ${args.join(" ")}`;
}
return key;
}
function parseChatComponent(component) {
if (!component) return "";
if (typeof component === "string") {
try {
component = JSON.parse(component);
} catch (err) {
try {
const relaxedJson = component.replace(
/([{,])\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*:/g,
'$1"$2":',
);
component = JSON.parse(relaxedJson);
} catch (err2) {
return component.replace(/^"|"$/g, "");
}
}
}
let result = "";
if (component.translate) {
const args = component.with
? component.with.map((w) => {
if (typeof w === "string" || typeof w === "number") {
return String(w);
}
return parseChatComponent(w);
})
: [];
const translated = getTranslation(component.translate, args);
return translated;
}
if (component.text !== undefined && component.text !== null) {
result += String(component.text);
}
if (component.score) {
result += String(component.score.value || "");
}
if (component.selector) {
result += component.selector;
}
if (component.extra && Array.isArray(component.extra)) {
result += component.extra.map((e) => parseChatComponent(e)).join("");
}
return result;
}
module.exports = { getTranslation, parseChatComponent };
+43
View File
@@ -0,0 +1,43 @@
function compressRLE(data) {
const output = [];
let i = 0;
while (i < data.length) {
const byte = data[i];
let count = 1;
while (i + count < data.length && data[i + count] === byte && count < 256) {
count++;
}
if (count <= 3) {
if (byte === 0xff) {
output.push(0xff, count - 1);
} else {
for (let j = 0; j < count; j++) {
output.push(byte);
}
}
} else {
output.push(0xff, count - 1, byte);
}
i += count;
}
return Buffer.from(output);
}
function countSetBits(n) {
let count = 0;
while (n) {
count += n & 1;
n >>= 1;
}
return count;
}
module.exports = {
compressRLE,
countSetBits,
};
+159
View File
@@ -0,0 +1,159 @@
function readSlot(reader) {
const id = reader.readShort();
if (id === -1 || id === 0) {
return null;
}
const count = reader.readUnsignedByte();
const damage = reader.readShort();
const nbtLength = reader.readShort();
if (nbtLength > 0) {
reader.skip(nbtLength);
}
return {
blockId: id,
itemCount: count & 0xff,
itemDamage: damage,
};
}
function readItemInstance(reader) {
const id = reader.readShort();
if (id === -1 || id === 0) {
return null;
}
const count = reader.readByte();
const damage = reader.readShort();
const nbtPresent = reader.readByte();
if (nbtPresent !== 0) {
//for now, just ignore NBT because lazy
}
return {
blockId: id,
itemCount: count & 0xff,
itemDamage: damage,
};
}
function readItem(reader) {
const itemId = reader.readShort();
if (itemId === -1) {
return null;
}
const count = reader.readByte();
const damage = reader.readShort();
return {
blockId: itemId,
itemCount: count,
itemDamage: damage,
};
}
function writeItemNBT(writer, item) {
const PacketWriter = require("../PacketWriter");
let customName = null;
if (item.nbtData && item.nbtData.value && item.nbtData.value.display) {
const display = item.nbtData.value.display.value;
if (display.Name) {
customName = display.Name.value;
try {
const parsed = JSON.parse(customName);
if (parsed.text) {
customName = parsed.text;
} else if (typeof parsed === "string") {
customName = parsed;
}
} catch (err) {
/* do nothing */
}
}
}
if (!customName) {
writer.writeShort(-1);
return;
}
const nbtWriter = new PacketWriter();
nbtWriter.writeByte(10);
nbtWriter.writeUTF("");
nbtWriter.writeByte(10);
nbtWriter.writeUTF("display");
nbtWriter.writeByte(8);
nbtWriter.writeUTF("Name");
nbtWriter.writeUTF(customName);
nbtWriter.writeByte(0);
nbtWriter.writeByte(0);
const nbtData = nbtWriter.toBuffer();
writer.writeShort(nbtData.length);
writer.writeBytes(nbtData);
}
function writeItem(writer, item, mapJavaItemToLCE) {
if (!item || item.blockId === -1 || item.itemId === -1 || item === null) {
writer.writeShort(-1);
return;
}
let javaItemId =
item.itemId !== undefined
? item.itemId
: item.blockId !== undefined
? item.blockId
: -1;
if (javaItemId === -1 || javaItemId === undefined) {
writer.writeShort(-1);
return;
}
let lceItemId = mapJavaItemToLCE(javaItemId);
let auxValue =
item.itemDamage !== undefined ? item.itemDamage : item.metadata || 0;
if (
lceItemId === undefined ||
lceItemId === null ||
lceItemId === -1 ||
lceItemId === 0
) {
lceItemId = 1;
auxValue = 0;
}
if (lceItemId < 0 || lceItemId > 2267) {
lceItemId = 1;
auxValue = 0;
}
writer.writeShort(lceItemId);
const count = item.itemCount || item.count || 1;
writer.writeByte(Math.max(1, Math.min(255, count)));
writer.writeShort(Math.max(0, Math.min(32767, auxValue)));
writeItemNBT(writer, item);
}
module.exports = {
readSlot,
readItemInstance,
readItem,
writeItemNBT,
writeItem,
};
+13
View File
@@ -0,0 +1,13 @@
function normalizeYaw(yaw) {
let normalized = yaw % 360;
if (normalized > 180) {
normalized -= 360;
} else if (normalized < -180) {
normalized += 360;
}
return normalized;
}
module.exports = {
normalizeYaw,
};
+15
View File
@@ -0,0 +1,15 @@
function getTranslation(key, args = []) {
const translations = {};
const translationFunc = translations[key];
if (translationFunc) {
return translationFunc(args);
}
if (args.length > 0) {
return `${key}: ${args.join(" ")}`;
}
return key;
}
module.exports = { getTranslation };
+3
View File
@@ -0,0 +1,3 @@
@echo off
node index.js
pause