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

My bot dont wants to activate "bot.setControlState" or another control #3504

Open
1 task
Mingau-Projects opened this issue Nov 15, 2024 · 3 comments
Open
1 task
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

@Mingau-Projects
Copy link

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

Versions

  • mineflayer: 4.23.0
  • server: spigot/paper 1.21.1
  • node: im using node.js in replit, because my computer can't run javaScript

Detailed description of a problem

my robot only stand and more nothing, only look at me

What did you try yet?

i tried an example from https://www.youtube.com/watch?v=P7TIRIDuGjc here is the code on the description.

Your current code

const express = require('express');
const mineflayer = require("mineflayer");
const app = express();

app.use(express.json());

app.get("/", (_, res) => res.sendFile(__dirname + "/index.html"));
app.listen(process.env.PORT);

setInterval(() => {
	http.get(`http://ed4dded2-c5a5-40d3-a7e1-0217baab05a7-00-1hqclivsm9rpp.kirk.repl.co/`);
}, 224000);

var settings = {
	username: "giro_2027",
	host: "MineOfDonkeys.aternos.me",
	version: "1.21.1",
	port: "42003"
};

const bot = mineflayer.createBot(settings);

bot.on("move", () => {
	let friend = bot.nearestEntity();

	if (friend) {
		bot.lookAt(friend.position.offset(0, friend.height, 0));
	}
});

bot.on("kicked", console.log);
bot.on("error", console.log);
bot.on("end", console.log);
bot.on("spawn", console.log)

//here is the part that dont works

var walking = false;

bot.on("entityHurt", (entity)=>{
              if(entity != bot.entity){
		walking = !walking;
		bot.setControlState("forward", walking);
});

bot.on("move", (entity)=>{
	if(entity == "armor_stand"){
		bot.simpleClick(entity, "right");
	};
});

Expected behavior

My expectation was that the robot will click on armor stands (gravestones) and chase anything that causes damage to him (alternating).

@Mingau-Projects Mingau-Projects 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 Nov 15, 2024
@miles-igd
Copy link

miles-igd commented Nov 16, 2024

entityHurt doesn't work as implemented in new versions of Minecraft at the moment, see #3501

@extremeheat
Copy link
Member

entityHurt doesn't work as implemented in new versions of Minecraft at the moment, see #3501

In future please make PR for issues you can fix. I added the fix to #3489.

@Gjum
Copy link
Member

Gjum commented Nov 30, 2024

I am also unable to get the bot to move using setControlState(). It seems to be an issue on Windows only.

When running this minimal script, "my position" keeps printing the same coordinates.

Looking at the bot in-game, it starts moving for one physics tick, but does not move further.

If the original issue is really only due to entityHurt, I can open a separate issue for this.

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

4 participants