2018-05-13 16:50:16 -04:00
|
|
|
const mc = require('minecraft-protocol')
|
2020-10-25 09:26:26 -04:00
|
|
|
const Chunk = require('prismarine-chunk')('1.16.3')
|
2018-05-13 16:50:16 -04:00
|
|
|
const Vec3 = require('vec3')
|
2020-10-31 10:48:53 -04:00
|
|
|
const server = mc.createServer({
|
2017-11-08 10:27:00 -05:00
|
|
|
'online-mode': true,
|
|
|
|
encryption: true,
|
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 25565,
|
2020-06-23 11:10:22 -04:00
|
|
|
version: '1.16'
|
2018-05-13 16:50:16 -04:00
|
|
|
})
|
2020-10-06 16:46:53 -04:00
|
|
|
const mcData = require('minecraft-data')(server.version)
|
|
|
|
const loginPacket = mcData.loginPacket
|
2020-10-31 10:48:53 -04:00
|
|
|
const chunk = new Chunk()
|
2017-11-08 10:27:00 -05:00
|
|
|
|
2020-10-31 10:48:53 -04:00
|
|
|
for (let x = 0; x < 16; x++) {
|
|
|
|
for (let z = 0; z < 16; z++) {
|
2020-10-25 09:26:26 -04:00
|
|
|
chunk.setBlockType(new Vec3(x, 100, z), mcData.blocksByName.grass_block.id)
|
|
|
|
chunk.setBlockData(new Vec3(x, 100, z), 1)
|
2020-10-31 10:48:53 -04:00
|
|
|
for (let y = 0; y < 256; y++) {
|
2018-05-13 16:50:16 -04:00
|
|
|
chunk.setSkyLight(new Vec3(x, y, z), 15)
|
2017-11-08 10:27:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-13 16:50:16 -04:00
|
|
|
server.on('login', function (client) {
|
2017-11-08 10:27:00 -05:00
|
|
|
client.write('login', {
|
|
|
|
entityId: client.id,
|
2020-10-06 16:46:53 -04:00
|
|
|
isHardcore: false,
|
2017-11-08 10:27:00 -05:00
|
|
|
gameMode: 0,
|
2020-06-23 10:52:18 -04:00
|
|
|
previousGameMode: 255,
|
2020-10-06 16:46:53 -04:00
|
|
|
worldNames: loginPacket.worldNames,
|
|
|
|
dimensionCodec: loginPacket.dimensionCodec,
|
|
|
|
dimension: loginPacket.dimension,
|
2020-06-23 10:52:18 -04:00
|
|
|
worldName: 'minecraft:overworld',
|
2020-10-06 16:46:53 -04:00
|
|
|
hashedSeed: [0, 0],
|
2017-11-08 10:27:00 -05:00
|
|
|
maxPlayers: server.maxPlayers,
|
2020-10-06 16:46:53 -04:00
|
|
|
viewDistance: 10,
|
2019-12-29 17:27:04 -05:00
|
|
|
reducedDebugInfo: false,
|
|
|
|
enableRespawnScreen: true,
|
2020-10-06 16:46:53 -04:00
|
|
|
isDebug: false,
|
|
|
|
isFlat: false
|
2018-05-13 16:50:16 -04:00
|
|
|
})
|
2017-11-08 10:27:00 -05:00
|
|
|
client.write('map_chunk', {
|
|
|
|
x: 0,
|
|
|
|
z: 0,
|
2020-10-25 09:26:26 -04:00
|
|
|
groundUp: true,
|
|
|
|
biomes: chunk.dumpBiomes !== undefined ? chunk.dumpBiomes() : undefined,
|
2020-10-06 16:46:53 -04:00
|
|
|
heightmaps: {
|
|
|
|
type: 'compound',
|
2020-10-25 09:26:26 -04:00
|
|
|
name: '',
|
|
|
|
value: {
|
|
|
|
MOTION_BLOCKING: { type: 'longArray', value: new Array(36).fill([0, 0]) }
|
|
|
|
}
|
|
|
|
}, // send fake heightmap
|
|
|
|
bitMap: chunk.getMask(),
|
|
|
|
chunkData: chunk.dump(),
|
|
|
|
blockEntities: []
|
2018-05-13 16:50:16 -04:00
|
|
|
})
|
2017-11-08 21:28:33 -05:00
|
|
|
client.write('position', {
|
|
|
|
x: 15,
|
|
|
|
y: 101,
|
|
|
|
z: 15,
|
|
|
|
yaw: 137,
|
|
|
|
pitch: 0,
|
|
|
|
flags: 0x00
|
2018-05-13 16:50:16 -04:00
|
|
|
})
|
|
|
|
})
|