Closed sefirosweb closed 10 months ago
Hi guys i'm doing tests with minecraft-wrap
On flatworld the prismarine-viewer no works fine:
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
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
should work now
https://github.com/PrismarineJS/prismarine-viewer/issues/435
Hi guys i'm doing tests with minecraft-wrap
On flatworld the prismarine-viewer no works fine:
My code is simply:
To start world:
The code of bot:
The versions of packages:
If i execute a vanilla server in 1.18.2 works fine, seems any issue from minecraft wrap <-> viewer