mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 11:10:44 +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 Vec3 = require('vec3').Vec3
|
||||||
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}) {
|
||||||
|
const {detectFrame, generatePortal, addPortalToWorld} = require('flying-squid').portal_detector(version)
|
||||||
|
|
||||||
player.use_flint_and_steel = async (referencePosition, direction, position) => {
|
player.use_flint_and_steel = async (referencePosition, direction, position) => {
|
||||||
let block = await player.world.getBlock(referencePosition)
|
let block = await player.world.getBlock(referencePosition)
|
||||||
if (block.name === 'obsidian') {
|
if (block.name === 'obsidian') {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ const Vec3 = require('vec3').Vec3
|
||||||
const flatMap = require('flatmap')
|
const flatMap = require('flatmap')
|
||||||
const range = require('range').range
|
const range = require('range').range
|
||||||
|
|
||||||
module.exports = {detectFrame, findPotentialLines, findBorder, getAir, generateLine, generatePortal, addPortalToWorld, makeWorldWithPortal}
|
|
||||||
|
|
||||||
async function findLineInDirection (world, startingPoint, type, direction, directionV) {
|
async function findLineInDirection (world, startingPoint, type, direction, directionV) {
|
||||||
const line = []
|
const line = []
|
||||||
let point = startingPoint
|
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)))
|
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'))
|
let World
|
||||||
const Chunk = require('prismarine-chunk')(require('./version'))
|
let Chunk
|
||||||
|
|
||||||
function generateLine (startingPoint, direction, length) {
|
function generateLine (startingPoint, direction, length) {
|
||||||
return range(0, length).map(i => startingPoint.plus(direction.scaled(i)))
|
return range(0, length).map(i => startingPoint.plus(direction.scaled(i)))
|
||||||
|
|
@ -129,3 +127,11 @@ async function makeWorldWithPortal (portal, additionalAir, additionalObsidian) {
|
||||||
|
|
||||||
return world
|
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 */
|
/* eslint-env jest */
|
||||||
|
|
||||||
const {
|
const {
|
||||||
portal_detector: {
|
|
||||||
detectFrame,
|
detectFrame,
|
||||||
findPotentialLines,
|
findPotentialLines,
|
||||||
findBorder,
|
findBorder,
|
||||||
|
|
@ -9,8 +8,7 @@ const {
|
||||||
generateLine,
|
generateLine,
|
||||||
generatePortal,
|
generatePortal,
|
||||||
makeWorldWithPortal
|
makeWorldWithPortal
|
||||||
}
|
} = require('flying-squid')('1.8').portal_detector
|
||||||
} = require('flying-squid')
|
|
||||||
|
|
||||||
const { Vec3 } = require('vec3')
|
const { Vec3 } = require('vec3')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue