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

Can't sent command, cuz of accept_teleportation #3514

Open
1 task done
Aotumuri opened this issue Dec 1, 2024 · 0 comments
Open
1 task done

Can't sent command, cuz of accept_teleportation #3514

Aotumuri opened this issue Dec 1, 2024 · 0 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Aotumuri
Copy link

Aotumuri commented Dec 1, 2024

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: lasted
  • server: vanilla/1.20.6 and 1.21.x
  • node: lasted

Detailed description of a problem

I was creating a bot to send commands, but could not do so because I got the following error.

log of mineflayer
"パケットタイプ: kick_disconnect {
reason: { type: 'compound', value: { with: [Object], translate: [Object] } }
}
Botがキックされました: {
"type": "compound",
"value": {
"with": {
"type": "list",
"value": {
"type": "string",
"value": [
"Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'serverbound/minecraft:accept_teleportation'"
]
}
},
"translate": {
"type": "string",
"value": "disconnect.genericReason"
}
}
}"

log of server
" bot lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'serverbound/minecraft:accept_teleportation' "

What did you try yet?

Did you try any method from the API?
Did you try any example? Any error from those?

Your current code

bot.on("chat", (username, message) => {
    if (username === bot.username) return;
    console.log(`[${username}] ${message}`);
    const args = message.split(" ");
    const command = args[0];
    const param = args[1];
    if (message === "!search") {
        ScanBlocksInRange(-60, 60, -30, 30, 10);
    }else if (command === "!replace") {
        // 指定したブロックで置換
        if (param === null) {
            console.log(args);
            bot.chat("使用方法: replace [block_name]");
        } else {
          replaceTaggedBlocks(param); // 実際のブロックを置換
          bot.chat(`TaggedBlockList 内のブロックをすべて '${param}' に置き換えました。`);
        }
      }
    else if (message === "!debug") {
        listTaggedBlockList();
    }else if (message == "!test")
    {
    const command = `/setblock ~ ~ ~ stone`;
    bot._client.write('command', { command });
    }
});
async function replaceTaggedBlocks(newBlockName) {
  for (const taggedBlock of TaggedBlockList) {
    const position = taggedBlock.position;

    // チャットではなく、直接パケットでコマンドを送信
    const command = `/setblock ${position.x} ${position.y} ${position.z} ${newBlockName}`;
    bot._client.write('command', { command });
    console.log(`送信したコマンド: ${command}`);

    // コマンド送信間隔を調整(スパム防止のため)
    // await new Promise(resolve => setTimeout(resolve, 500)); // 0.5秒待機
  }
}
bot._client.on('packet', (data, meta) => {
  console.log(`パケットタイプ: ${meta.name}`, data);
});

Expected behavior

send and execute commands

Additional context

Add any other context about the problem here.

@Aotumuri Aotumuri added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant