mineflayer
mineflayer copied to clipboard
No chest open
- [ ] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: latest, not sure how to check
- server: Fabric
- node: v14.12
Detailed description of a problem
Trying to open chest
Your current code
const chest = await bot.openChest(bot.blockAt(vec3(1,0,0)))
Error
Expected behavior
Open chest
Additional context
Tried without await and this it what i get
In Minecraft
The first screenshot is because you have a syntax issue in your code and has nothing to do with mineflayer. I suggest you learn about async javascript first before trying to use the mineflayer api. The second screenshot is because you are trying to open a chest that is located at the position 1 0 0 in the world. openChest can only open containers and at 1 0 0 there is most likely something that is not a container type.
The first screenshot is because you have a syntax issue in your code and has nothing to do with mineflayer. I suggest you learn about async javascript first before trying to use the mineflayer api. The second screenshot is because you are trying to open a chest that is located at the position 1 0 0 in the world. openChest can only open containers and at 1 0 0 there is most likely something that is not a container type.
I do have a lack of knoledge in async js. So 1 0 0 is not relative position but a cordinate. then when testing earlier i was able to place a sapling there.
You probably use a relative offset to the bots position like bot.entity.position.offset(1, 0, 0)
You probably use a relative offset to the bots position like
bot.entity.position.offset(1, 0, 0)
bot.placeBlock(bot.blockAt(bot.entity.position.offset(1, -1, 0)), vec3(0, 1, 0))
yes
First chech to make sure the blockAt call works, then place the block. The problem yoh are having if you are passing a null block to placeBlock function
The first screenshot is because you have a syntax issue in your code and has nothing to do with mineflayer. I suggest you learn about async javascript first before trying to use the mineflayer api. The second screenshot is because you are trying to open a chest that is located at the position 1 0 0 in the world. openChest can only open containers and at 1 0 0 there is most likely something that is not a container type.
After What you said about learning async js, i did and i get what u mean now. sorry for not responding
First chech to make sure the blockAt call works, then place the block. The problem yoh are having if you are passing a null block to placeBlock function
How do so i 'check'
How do so i 'check'
console.log if it is null it is not working
How do so i 'check'
console.log if it is null it is not working
It worked in singleplayer but in mutliplayer. I get null.
block = bot.blockAt(vec3(-3742, 70 -3490)), vec3(0, 1, 0)
Edit: nvm i forgot the comma after 70. it is printing stuff but cannot really place block my code:
setInterval(async ()=>{
try {
await bot.equip(mcData.itemsByName['birch_sapling'].id, "hand");
} catch (e) {console.log('Can not equip Sapling')}
try {
block = bot.blockAt(vec3(-3742, 70, -3490)), vec3(0, 1, 0)
console.log(block)
await bot.placeBlock(block);
} catch (e) {console.log('Can not place block')}
},1000);
The farm :
Worked in singleplayer
block = bot.blockAt(vec3(-3742, 70 -3490)), vec3(0, 1, 0)
This is all wrong. You are not setting block to the result off blockAt you are setting block to the result off vec3(...). I suggest you join the discord and ask for help there. It will be a lot quicker then trying to debug your code with github comments.
block = bot.blockAt(vec3(-3742, 70 -3490)), vec3(0, 1, 0)
This is all wrong. You are not setting block to the result off blockAt you are setting block to the result off vec3(...). I suggest you join the discord and ask for help there. It will be a lot quicker then trying to debug your code with github comments.
yea i figured that out after debuging a little. and now magically i switched my code from a chest problem to a tree farm auto bot problem
setInterval(async ()=>{
for(let i=30; i<=34; i++) {
try {
await bot.equip(i, "hand");
// await bot.equip(mcData.itemsByName['birch_sapling'].id, "hand");
} catch (e) {console.log('Can not equip Sapling')}
try {
await bot.placeBlock(bot.blockAt(vec3(-3742, 70, -3490)), vec3(0, 1, 0));
} catch (e) {
i=i-1;
}
}
},1000);
Now i am trying to switch between the saplings in order but due to its failing sometime as there is a block already there. it skips the order of sapling.
I still haven't this out so any answers can help!
As IceTank said, it's better if you join the Discord server as it's easier to maintain a conversation over there