mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

No chest open

Open VaibhavVerma21 opened this issue 2 years ago • 13 comments

  • [ ] 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

image

Expected behavior

Open chest

Additional context

Tried without await and this it what i get image

In Minecraft

image

VaibhavVerma21 avatar Apr 15 '22 15:04 VaibhavVerma21

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.

IceTank avatar Apr 15 '22 16:04 IceTank

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.

VaibhavVerma21 avatar Apr 15 '22 17:04 VaibhavVerma21

You probably use a relative offset to the bots position like bot.entity.position.offset(1, 0, 0)

IceTank avatar Apr 15 '22 17:04 IceTank

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

VaibhavVerma21 avatar Apr 15 '22 17:04 VaibhavVerma21

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

u9g avatar Apr 19 '22 17:04 u9g

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

VaibhavVerma21 avatar Apr 21 '22 12:04 VaibhavVerma21

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'

VaibhavVerma21 avatar Apr 21 '22 12:04 VaibhavVerma21

How do so i 'check'

console.log if it is null it is not working

IceTank avatar Apr 21 '22 14:04 IceTank

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 : image

Worked in singleplayer

VaibhavVerma21 avatar Apr 21 '22 15:04 VaibhavVerma21

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.

IceTank avatar Apr 21 '22 15:04 IceTank

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.

VaibhavVerma21 avatar Apr 21 '22 18:04 VaibhavVerma21

I still haven't this out so any answers can help!

VaibhavVerma21 avatar May 15 '22 18:05 VaibhavVerma21

As IceTank said, it's better if you join the Discord server as it's easier to maintain a conversation over there

amoraschi avatar May 15 '22 18:05 amoraschi