node-minecraft-protocol/examples/server_channel/server_channel.js

44 lines
1 KiB
JavaScript
Raw Normal View History

const mc = require('minecraft-protocol')
2017-07-13 08:03:52 -04:00
const server = mc.createServer({
'online-mode': false, // optional
encryption: false, // optional
host: '0.0.0.0', // optional
port: 25565, // optional
2020-06-23 11:10:22 -04:00
version: '1.16'
})
const mcData = require('minecraft-data')(server.version)
const loginPacket = mcData.loginPacket
server.on('login', function (client) {
client.registerChannel('MC|Brand', ['string', []])
client.on('MC|Brand', console.log)
client.write('login', {
entityId: client.id,
isHardcore: false,
gameMode: 0,
previousGameMode: 255,
worldNames: loginPacket.worldNames,
dimensionCodec: loginPacket.dimensionCodec,
dimension: loginPacket.dimension,
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('MC|Brand', 'vanilla')
})