Why wont my fireball go in the correct direction upon spawning?

15 Views Asked by At

I am making a Minecraft mod in Fabric, and one of the items I am adding is a simple fireball wand. Right click, and spawn a blaze fireball. Using raycast and vectors, I made what I thought would give me a fireball spawning at eye position and flying where my cursor is pointed. However, the fireball is almost always a few blocks off target. without moving my mouse, the fireballs are consistent, so I know its not an accuracy issue but an actual code issue. Below is the code I used to spawn the fireball

BlockHitResult rc = raycast(world, user, RaycastContext.FluidHandling.NONE);
Vec3d dir = new Vec3d(rc.getBlockPos().getX() - user.getEyePos().getX(),
        rc.getBlockPos().getY() - user.getEyePos().getY(),
        rc.getBlockPos().getZ() - user.getEyePos().getZ());
SmallFireballEntity wizardMoment = new SmallFireballEntity(world, 
        user.getEyePos().getX(), 
        user.getEyePos().getY(), 
        user.getEyePos().getZ(), 
        dir.normalize().getX(), 
        dir.normalize().getY(), 
        dir.normalize().getZ());
wizardMoment.setPosition(wizardMoment.getX(), wizardMoment.getY(), wizardMoment.getZ());

I am fairly new at Minecraft modding, I got most of these ideas from looking at the Blaze source code. any help would be appreciated!

0

There are 0 best solutions below