#getBlockFromViewDirection() function does not work under liquid

1 messages · Page 1 of 1 (latest)

floral fable
#

I have a script that when using an item gets the block that is in front of the player. This works fine if the player is outside a liquid, but when inside the getBlockFromViewDirection() function always returns a block at position 0,0,0

copper bobcat
#

bao_icon_scripting .......

floral fable
#
            const callBase = player.getBlockFromViewDirection({includeLiquidBlocks:true,includePassableBlocks:false,maxDistance:32})
            if(typeof callBase !== "undefined"){
                console.warn(JSON.stringify({
                    location: callBase.location,
                    maxDistance: Math.min(6,3*(system.currentTick-queue.playerCallingTick[player.id].tick)/10 + 1),
                    closest: 1,
                    families: ['pikmin'],
                    tags: ['pikmin:move'],
                    excludeTags: ['pikmin:hasOwner','pikmin:called']
                }))
                console.warn(callBase.typeId)
            }
copper bobcat
#

that is strange indeed

#

return water for me

floral fable
#

What version of the game do you use?

copper bobcat
#

1.19.83

#

oh preview

#

sorry, i didnt notice that tag

#

dang, sure is a bug

#

remove includePassableBlocks

floral fable
#

It seems that the error is in includeLiquidBlocks, since if this has a true or false value the bug occurs

copper bobcat
#
const callBase = player.getBlockFromViewDirection({ includeLiquidBlocks: true, maxDistance: 32 })
if (!callBase.isSolid()) return
#

it's weird how it's not getting water when ur on surface

#

actually it gets water

#

with this code

#

actually idk

floral fable
#
            const callBase = player.getBlockFromViewDirection({includePassableBlocks:false,maxDistance:32})
            if(typeof callBase !== "undefined"){
                console.warn(callBase.typeId)
            }

Now this code is working for me

copper bobcat
#

its prob the "include" options that's bugging themselves that defaults to 0 0 0 when it's confused

floral fable
#

includeLiquidBlocks generates problems I think

floral fable
copper bobcat
#

thats gud then