mojira.dev
MCPE-218029

Entity.getViewDirection() not in the right location when riding

An entity riding have a facing animation, but not exactly to its y rotation (1st screenshot)

Yes it only get its block when not riding

To reproduce:

  • Setup a script to get its view direction

    import { world, system } from "@minecraft/server"
    
    system.runInterval(() => {
        const zombies = world.getDimension("overworld").getEntities({
            type: "minecraft:zombie" // any entity
        })
    
        zombies.forEach(zombie => {
            const viewDir = zombie.getViewDirection()
            const zLoc = zombie.location
    
            const block = zombie.dimension.getBlockFromRay(zLoc, viewDir)?.block //check blocks from its viewDir
            if (!block) return
    
    
            world.sendMessage(`${block.typeId}`) //debugging
        })
    }, 20) // 1 second: 20 ticks
    
  • Setup a cage with different blocks each faces

Problems:

  • Direction vector isn’t accurate, meaning in some cases, it will not pick up the object creators want

  • When making a projectile script, it will not shoot at the target

Attachments

Comments 0

No comments.

Random Persom

(Unassigned)

Unconfirmed

Multiple

1.21.90.20 Preview, 1.21.73 Hotfix

Retrieved