#Get block result of raytrace?

7 messages · Page 1 of 1 (latest)

true perch
#

I'm currently trying to replicate what someone did for a modjam (https://streamable.com/yn7gnb) to experiment with custom item actions, and I can't seem to find a way to correctly deviate the positions given, given that I can't get the block result of a raytrace. rayTrace(10).block is undefined/null.

onEvent('item.registry', event => {
    event.create('observing_eye').displayName('Observing Eye').useAnimation('bow').use((level, player, hand) => {
        player.setMotion(0, 0, 0)
        return true
    }).useDuration(itemstack => {
        return 20
    }).finishUsing((itemstack, level, entity) => {
        global.observingEyeFunc(itemstack, level, entity)
        return itemstack
    })
})

global.observingEyeFunc = (itemstack, level, entity) => {
    entity.addItemCooldown('kubejs:observing_eye', 100)
    let pitch = entity.getPitch()
    let yaw = entity.getYaw()
    let raytrace = entity.rayTrace(10)
    //use entity.addMotion() in the direction of the pitch and yaw
    function getDirection(pitch, yaw) {
        //get deviation of raytraced block from current position
        let x = raytrace.block.x - entity.block.x 
        return [x, y, z]
    }
    let direction = getDirection(pitch, yaw)
    entity.addMotion(direction[0], direction[1], direction[2])
    return itemstack
}
flint wadiBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

obsidian orbit
#

it will only be defined if it actually hits a block

#

youll probably need to do trig yourself to find the end pos

true perch
#

is there even a way to get quaternions without having to go through pain?

#

because it just said quaternion is not defined

flint wadiBOT
#

@true perch Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!