Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No works in flat world using minecraft-wrap 1.18.2 #350

Closed
sefirosweb opened this issue Feb 8, 2023 · 3 comments
Closed

No works in flat world using minecraft-wrap 1.18.2 #350

sefirosweb opened this issue Feb 8, 2023 · 3 comments

Comments

@sefirosweb
Copy link
Contributor

Hi guys i'm doing tests with minecraft-wrap

On flatworld the prismarine-viewer no works fine:

image

My code is simply:

To start world:

import mc from 'minecraft-protocol'
import path from 'path'
import mcDataLoader from 'minecraft-data'

//@ts-ignore
import { Wrap } from 'minecraft-wrap'
//@ts-ignore
import { download } from 'minecraft-wrap'

const propOverrides = {
    motd: 'Test Minecraft Server',
    'level-type': 'FLAT',
    'spawn-npcs': 'true',
    'spawn-animals': 'true',
    'online-mode': 'false',
    gamemode: '1a',
    'spawn-monsters': 'false',
    'generate-structures': 'false',
    'enable-command-block': 'true',
    'use-native-transport': 'false',
    'server-port': 255655,
    'view-distance': '40',
    'pvp': 'true'
}

const MC_SERVER_PATH = path.join(__dirname, 'server')

let PORT = 25565
const supportedVersion = "1.18.2"
const mcData = mcDataLoader(supportedVersion)
const version = mcData.version
const MC_SERVER_JAR_DIR = process.env.MC_SERVER_JAR_DIR || `${process.cwd()}/server_jars`
const MC_SERVER_JAR = `${MC_SERVER_JAR_DIR}/minecraft_server.${version.minecraftVersion}.jar`
const wrap = new Wrap(MC_SERVER_JAR, `${MC_SERVER_PATH}_${supportedVersion}`)

wrap.on('line', (line: string) => {
    console.log(line)
})

download(version.minecraftVersion, MC_SERVER_JAR, (err: Error) => {
    if (err) {
        console.log(err)
        return
    }
    propOverrides['server-port'] = PORT
    wrap.startServer(propOverrides, () => {
        console.log(`pinging ${version.minecraftVersion} port : ${PORT}`)

        const serverConection = {
            port: PORT,
            version: supportedVersion
        }

        mc.ping(serverConection, () => {
            setTimeout(() => {
                console.log('pong')
                wrap.writeServer('op Archer\n')
                wrap.writeServer('op Lordvivi\n')
            }, 10000);
        })
    })
})

The code of bot:

const mineflayer = require('mineflayer')
const mineflayerViewer = require('prismarine-viewer').mineflayer
const minecraftHawkEye = require('../index')

// first install the dependency
// npm i mineflayer prismarine-viewer minecrafthawkeye

const bot = mineflayer.createBot({
    host: process.argv[2] ? process.argv[2] : 'host.docker.internal',
    port: process.argv[3] ? parseInt(process.argv[3]) : 25565,
    username: process.argv[4] ? process.argv[4] : 'Archer',
    password: process.argv[5]
})

bot.loadPlugin(minecraftHawkEye)
let intervalShot, intervalPreview, target

bot.on('spawn', () => {
    bot.chat('/kill @e[type=minecraft:arrow]')
    bot.chat('/clear')
    bot.chat(`/give ${bot.username} bow{Enchantments:[{id:unbreaking,lvl:3}]} 1`)
    bot.chat(`/give ${bot.username} minecraft:arrow 300`)
    bot.chat('/time set day')
    bot.chat('Ready!')
    target = bot.hawkEye.getPlayer()
    intervalShot = setInterval(fire, 5000)
    intervalPreview = setInterval(shotPreview, 200)
})

bot.on('die', () => {
    clearInterval(intervalShot)
    clearInterval(intervalPreview)
})

bot.once('spawn', () => {
    mineflayerViewer(bot, { port: 3000 })
})

function shotPreview() {
    bot.viewer.erase('arrowTrajectoryPoints')
    if (target) {
        const arrowTrajectoryPoints = bot.hawkEye.getMasterGrade(target, null, 'bow').arrowTrajectoryPoints // Returns array of Vec3 positions
        if (arrowTrajectoryPoints) {
            bot.viewer.drawPoints('arrowTrajectoryPoints', arrowTrajectoryPoints, 0xff0000, 5)
        }
    }
}

function fire() {
    if (target) {
        bot.hawkEye.oneShot(target, 'bow')
    }
}

The versions of packages:

    "dependencies": {
        "mineflayer": "^4.8.0",
        "prismarine-world": "^3.6.1",
        "vec3": "^0.1.7"
    },
    "devDependencies": {
        "@types/chai": "^4.3.4",
        "@types/mocha": "^10.0.1",
        "chai": "^4.3.7",
        "minecraft-wrap": "^1.5.1",
        "mocha": "^10.2.0",
        "prismarine-viewer": "^1.23.0",
        "standard": "^17.0.0",
        "ts-node": "^10.9.1",
        "typescript": "^4.9.5"
    },

If i execute a vanilla server in 1.18.2 works fine, seems any issue from minecraft wrap <-> viewer

@sefirosweb sefirosweb changed the title No works in flat worrld using minecraft-wrap 1.18.2 No works in flat world using minecraft-wrap 1.18.2 Feb 8, 2023
@sefirosweb
Copy link
Contributor Author

I review the issue and seems they no have supports for 1.18.1+

Need to update the package of minecraft-assets, but this package is not in NPM with the latest version of 1.19

@rom1504
Copy link
Member

rom1504 commented Dec 17, 2023

should work now

@rom1504 rom1504 closed this as completed Dec 17, 2023
@SinanAkkoyun
Copy link

#435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants