mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 05:51:12 +00:00
bring (static) multi version support to portal detection
This commit is contained in:
parent
988e3fde96
commit
0b53189116
3 changed files with 14 additions and 9 deletions
|
|
@ -1,8 +1,9 @@
|
|||
const {detectFrame, generatePortal, addPortalToWorld} = require('flying-squid').portal_detector
|
||||
const Vec3 = require('vec3').Vec3
|
||||
const UserError = require('flying-squid').UserError
|
||||
|
||||
module.exports.player = function (player, serv) {
|
||||
module.exports.player = function (player, serv, {version}) {
|
||||
const {detectFrame, generatePortal, addPortalToWorld} = require('flying-squid').portal_detector(version)
|
||||
|
||||
player.use_flint_and_steel = async (referencePosition, direction, position) => {
|
||||
let block = await player.world.getBlock(referencePosition)
|
||||
if (block.name === 'obsidian') {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ const Vec3 = require('vec3').Vec3
|
|||
const flatMap = require('flatmap')
|
||||
const range = require('range').range
|
||||
|
||||
module.exports = {detectFrame, findPotentialLines, findBorder, getAir, generateLine, generatePortal, addPortalToWorld, makeWorldWithPortal}
|
||||
|
||||
async function findLineInDirection (world, startingPoint, type, direction, directionV) {
|
||||
const line = []
|
||||
let point = startingPoint
|
||||
|
|
@ -91,8 +89,8 @@ function getAir (border) {
|
|||
return flatMap(bottom, pos => range(1, top[0].y - bottom[0].y).map(i => pos.offset(0, i, 0)))
|
||||
}
|
||||
|
||||
const World = require('prismarine-world')(require('./version'))
|
||||
const Chunk = require('prismarine-chunk')(require('./version'))
|
||||
let World
|
||||
let Chunk
|
||||
|
||||
function generateLine (startingPoint, direction, length) {
|
||||
return range(0, length).map(i => startingPoint.plus(direction.scaled(i)))
|
||||
|
|
@ -129,3 +127,11 @@ async function makeWorldWithPortal (portal, additionalAir, additionalObsidian) {
|
|||
|
||||
return world
|
||||
}
|
||||
|
||||
function loader(version) {
|
||||
World = require('prismarine-world')(version)
|
||||
Chunk = require('prismarine-chunk')(version)
|
||||
return {detectFrame,findPotentialLines,findBorder,getAir,generateLine,generatePortal,addPortalToWorld,makeWorldWithPortal}
|
||||
}
|
||||
|
||||
module.exports = loader
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-env jest */
|
||||
|
||||
const {
|
||||
portal_detector: {
|
||||
detectFrame,
|
||||
findPotentialLines,
|
||||
findBorder,
|
||||
|
|
@ -9,8 +8,7 @@ const {
|
|||
generateLine,
|
||||
generatePortal,
|
||||
makeWorldWithPortal
|
||||
}
|
||||
} = require('flying-squid')
|
||||
} = require('flying-squid')('1.8').portal_detector
|
||||
|
||||
const { Vec3 } = require('vec3')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue