mirror of
https://github.com/danbulant/flying-squid
synced 2026-09-20 06:33:59 +00:00
bring (static) multi version support to everything else + fix some formatting
This commit is contained in:
parent
0b53189116
commit
48be4f2266
13 changed files with 54 additions and 47 deletions
|
|
@ -1,22 +1,22 @@
|
||||||
const mcServer=require("flying-squid");
|
const mcServer = require('flying-squid')
|
||||||
|
|
||||||
mcServer.createMCServer({
|
mcServer.createMCServer({
|
||||||
"motd": "A Minecraft Server \nRunning flying-squid",
|
'motd': 'A Minecraft Server \nRunning flying-squid',
|
||||||
"port": 25565,
|
'port': 25565,
|
||||||
"max-players": 10,
|
'max-players': 10,
|
||||||
"online-mode": true,
|
'online-mode': true,
|
||||||
"logging": true,
|
'logging': true,
|
||||||
"gameMode": 1,
|
'gameMode': 1,
|
||||||
"generation": {
|
'generation': {
|
||||||
"name": "diamond_square",
|
'name': 'diamond_square',
|
||||||
"options":{
|
'options': {
|
||||||
"worldHeight": 80
|
'worldHeight': 80
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"kickTimeout": 10000,
|
'kickTimeout': 10000,
|
||||||
"plugins": {
|
'plugins': {
|
||||||
|
|
||||||
},
|
},
|
||||||
"modpe": false,
|
'modpe': false,
|
||||||
"view-distance": 10
|
'view-distance': 10
|
||||||
});
|
})
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "require-self",
|
"prepare": "require-self",
|
||||||
"lint": "standard test/*.test.js src/**/*.js src/**/**/*.js src/*.js *.js",
|
"lint": "standard test/*.test.js src/**/*.js src/**/**/*.js src/*.js examples/*.js *.js",
|
||||||
"test": "jest --verbose --runInBand"
|
"test": "jest --verbose --runInBand"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ module.exports = {
|
||||||
createMCServer: createMCServer,
|
createMCServer: createMCServer,
|
||||||
Behavior: require('./lib/behavior'),
|
Behavior: require('./lib/behavior'),
|
||||||
Command: require('./lib/command'),
|
Command: require('./lib/command'),
|
||||||
version: require('./lib/version'),
|
|
||||||
generations: require('./lib/generations'),
|
generations: require('./lib/generations'),
|
||||||
experience: require('./lib/experience'),
|
experience: require('./lib/experience'),
|
||||||
UserError: require('./lib/user_error'),
|
UserError: require('./lib/user_error'),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ module.exports = (obj) => {
|
||||||
|
|
||||||
let resp
|
let resp
|
||||||
|
|
||||||
|
func = func || (() => {})
|
||||||
|
|
||||||
await obj.emitThen(eventName + '_cancel', data, cancel).catch((err) => setTimeout(() => { throw err }, 0))
|
await obj.emitThen(eventName + '_cancel', data, cancel).catch((err) => setTimeout(() => { throw err }, 0))
|
||||||
await obj.emitThen(eventName, data, cancelled, cancelCount).catch((err) => setTimeout(() => { throw err }, 0))
|
await obj.emitThen(eventName, data, cancelled, cancelCount).catch((err) => setTimeout(() => { throw err }, 0))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const UserError = require('flying-squid').UserError
|
const UserError = require('flying-squid').UserError
|
||||||
|
|
||||||
module.exports.player = function (player, serv) {
|
module.exports.player = function (player, serv, {version}) {
|
||||||
player.commands.add({
|
player.commands.add({
|
||||||
base: 'help',
|
base: 'help',
|
||||||
info: 'to show all commands',
|
info: 'to show all commands',
|
||||||
|
|
@ -80,7 +80,7 @@ module.exports.player = function (player, serv) {
|
||||||
info: 'to get version of the server',
|
info: 'to get version of the server',
|
||||||
usage: '/version',
|
usage: '/version',
|
||||||
action () {
|
action () {
|
||||||
return 'This server is running flying-squid version ' + require('../../../package').version
|
return 'This server is running flying-squid version ' + version
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
const version = require('flying-squid').version
|
|
||||||
const windows = require('prismarine-windows')(version).windows
|
|
||||||
const Item = require('prismarine-item')(version)
|
|
||||||
const Vec3 = require('vec3')
|
const Vec3 = require('vec3')
|
||||||
|
|
||||||
module.exports.player = function (player, serv) {
|
module.exports.player = function (player, serv, {version}) {
|
||||||
|
const Item = require('prismarine-item')(version)
|
||||||
|
const windows = require('prismarine-windows')(version).windows
|
||||||
|
|
||||||
player.heldItemSlot = 0
|
player.heldItemSlot = 0
|
||||||
player.heldItem = new Item(256, 1)
|
player.heldItem = new Item(256, 1)
|
||||||
player.inventory = new windows.InventoryWindow(0, 'Inventory', 44)
|
player.inventory = new windows.InventoryWindow(0, 'Inventory', 44)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
const blocks = require('minecraft-data')(require('flying-squid').version).blocks
|
|
||||||
const Vec3 = require('vec3').Vec3
|
const Vec3 = require('vec3').Vec3
|
||||||
|
|
||||||
module.exports.entity = function (entity) {
|
module.exports.entity = function (entity, serv, {version}) {
|
||||||
|
const blocks = require('minecraft-data')(version).blocks
|
||||||
|
|
||||||
entity.calculatePhysics = async (delta) => {
|
entity.calculatePhysics = async (delta) => {
|
||||||
if (entity.gravity) {
|
if (entity.gravity) {
|
||||||
addGravity(entity, 'x', delta)
|
addGravity(entity, 'x', delta)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
const blocks = require('minecraft-data')(require('flying-squid').version).blocks
|
|
||||||
const Vec3 = require('vec3').Vec3
|
const Vec3 = require('vec3').Vec3
|
||||||
|
|
||||||
const materialToSound = {
|
const materialToSound = {
|
||||||
|
|
@ -11,7 +10,9 @@ const materialToSound = {
|
||||||
'wood': 'wood'
|
'wood': 'wood'
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.player = function (player, serv) {
|
module.exports.player = function (player, serv, {version}) {
|
||||||
|
const blocks = require('minecraft-data')(version).blocks
|
||||||
|
|
||||||
player._client.on('block_place', ({direction, heldItem, location} = {}) => {
|
player._client.on('block_place', ({direction, heldItem, location} = {}) => {
|
||||||
if (direction === -1 || heldItem.blockId === -1 || !blocks[heldItem.blockId]) return
|
if (direction === -1 || heldItem.blockId === -1 || !blocks[heldItem.blockId]) return
|
||||||
const referencePosition = new Vec3(location.x, location.y, location.z)
|
const referencePosition = new Vec3(location.x, location.y, location.z)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
const version = require('flying-squid').version
|
|
||||||
const entitiesByName = require('minecraft-data')(version).entitiesByName
|
|
||||||
const mobsById = require('minecraft-data')(version).mobs
|
|
||||||
const objectsById = require('minecraft-data')(version).objects
|
|
||||||
const Entity = require('prismarine-entity')
|
const Entity = require('prismarine-entity')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const requireIndex = require('../requireindex')
|
const requireIndex = require('../requireindex')
|
||||||
const plugins = requireIndex(path.join(__dirname, '..', 'plugins'))
|
const plugins = requireIndex(path.join(__dirname, '..', 'plugins'))
|
||||||
const Item = require('prismarine-item')(version)
|
|
||||||
const UserError = require('flying-squid').UserError
|
const UserError = require('flying-squid').UserError
|
||||||
|
|
||||||
const Vec3 = require('vec3').Vec3
|
const Vec3 = require('vec3').Vec3
|
||||||
|
|
||||||
module.exports.server = function (serv, options) {
|
module.exports.server = function (serv, options) {
|
||||||
|
const version = options.version
|
||||||
|
|
||||||
|
const mobsById = require('minecraft-data')(version).mobs
|
||||||
|
const objectsById = require('minecraft-data')(version).objects
|
||||||
|
|
||||||
serv.initEntity = (type, entityType, world, position) => {
|
serv.initEntity = (type, entityType, world, position) => {
|
||||||
if (Object.keys(serv.entities).length > options['max-entities']) { throw new Error('Too many mobs !') }
|
if (Object.keys(serv.entities).length > options['max-entities']) { throw new Error('Too many mobs !') }
|
||||||
serv.entityMaxId++
|
serv.entityMaxId++
|
||||||
|
|
@ -74,6 +74,10 @@ module.exports.server = function (serv, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.player = function (player, serv, options) {
|
module.exports.player = function (player, serv, options) {
|
||||||
|
const version = options.version
|
||||||
|
const entitiesByName = require('minecraft-data')(version).entitiesByName
|
||||||
|
const Item = require('prismarine-item')(version)
|
||||||
|
|
||||||
player.commands.add({
|
player.commands.add({
|
||||||
base: 'summon',
|
base: 'summon',
|
||||||
info: 'Summon an entity',
|
info: 'Summon an entity',
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
const items = require('minecraft-data')(require('flying-squid').version).items
|
|
||||||
const Item = require('prismarine-item')(require('flying-squid').version)
|
|
||||||
const Vec3 = require('vec3').Vec3
|
const Vec3 = require('vec3').Vec3
|
||||||
|
|
||||||
module.exports.player = function (player, serv) {
|
module.exports.player = function (player, serv, {version}) {
|
||||||
|
const items = require('minecraft-data')(version).items
|
||||||
|
const Item = require('prismarine-item')(version)
|
||||||
|
|
||||||
player._client.on('block_place', ({direction, heldItem, location} = {}) => {
|
player._client.on('block_place', ({direction, heldItem, location} = {}) => {
|
||||||
if (direction === -1 || heldItem.blockId === -1 || !items[heldItem.blockId]) return
|
if (direction === -1 || heldItem.blockId === -1 || !items[heldItem.blockId]) return
|
||||||
const item = Item.fromNotch(heldItem)
|
const item = Item.fromNotch(heldItem)
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
module.exports = '1.8'
|
|
||||||
|
|
@ -8,7 +8,7 @@ const {
|
||||||
generateLine,
|
generateLine,
|
||||||
generatePortal,
|
generatePortal,
|
||||||
makeWorldWithPortal
|
makeWorldWithPortal
|
||||||
} = require('flying-squid')('1.8').portal_detector
|
} = require('flying-squid').portal_detector('1.8')
|
||||||
|
|
||||||
const { Vec3 } = require('vec3')
|
const { Vec3 } = require('vec3')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue