node-minecraft-protocol/examples/server_channel/server_channel.js
extremeheat 9b029e8b6f
1.20.5 (#1309)
* 1.20.5

* update examples

* Update for 1.20.5 chat_command_signed with seperateSignedChatCommandPacket feature

* updates

* update java

* re-enable packet tests

* Update client.js

add debug code after decompress

* Update client.js

* Update ci.yml

* Add `arrayWithLengthOffset` type to interpeter

* Update minecraft.js

* Update compiler-minecraft.js

* Update minecraft.js

* lint

* remote custom ci install

* Update package.json

* Update packetTest.js add Slot, SlotComponent

* Update packetTest.js

* Update packetTest.js

* Fix lint.

* Fix declare_recipes, Slot

* Update package.json

---------

Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
2024-10-12 23:55:36 +02:00

40 lines
965 B
JavaScript

const mc = require('minecraft-protocol')
const server = mc.createServer({
'online-mode': false, // optional
encryption: false, // optional
version: '1.18.2'
})
const mcData = require('minecraft-data')(server.version)
const loginPacket = mcData.loginPacket
server.on('playerJoin', function (client) {
client.registerChannel('minecraft:brand', ['string', []])
client.on('minecraft:brand', console.log)
client.write('login', {
...loginPacket,
enforceSecureChat: false,
entityId: client.id,
isHardcore: false,
gameMode: 0,
previousGameMode: 1,
worldName: 'minecraft:overworld',
hashedSeed: [0, 0],
maxPlayers: server.maxPlayers,
viewDistance: 10,
reducedDebugInfo: false,
enableRespawnScreen: true,
isDebug: false,
isFlat: false
})
client.write('position', {
x: 0,
y: 1.62,
z: 0,
yaw: 0,
pitch: 0,
flags: 0x00
})
client.writeChannel('minecraft:brand', 'vanilla')
})