0

For context, I'm making a mod and I have been trying to make a wave of water blocks to damage entities. The way I'll be doing it is by tracking an invisible fireball and the fireball will go only 10 block away from the player before being killed. I can summon the fireball but I don't know how to kill it. Here's a snippet of the code, using Fabric 1.19.2 and IntelliJ

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (!user.getWorld().isClient){
        double xUser = user.getEyePos().getX();
        double yUser = user.getEyeY();
        double zUser = user.getEyePos().getZ();
        double Pitch = user.getPitch();
        Pitch = (Pitch+90) / 180 * Math.PI;
        double BodyYaw = user.getHeadYaw();
        //converting from [
        BodyYaw = (BodyYaw + 90) / 180 * Math.PI;
        double theta = BodyYaw;
        double phi = Pitch;
        double x = xUser + 10 * Math.sin(phi) * Math.cos(theta);
        double z = zUser + 10 * Math.sin(phi) * Math.sin(theta);
        double y = yUser + 10 * Math.cos(phi);
        Vec3d vector = new Vec3d((x-xUser)/20,(y-yUser-0.5d)/20,(z-zUser)/20);
        FireballEntity fireball = new FireballEntity(world, user, vector.x, vector.y, vector.z, 0);
        fireball.setPitch((float)Pitch);
        fireball.setPos(xUser, yUser, zUser);
        fireball.setHeadYaw((float)BodyYaw);
        fireball.setInvisible(false);
        fireball.setNoGravity(true);
        world.spawnEntity(fireball);
        }
    return super.use(world, user, hand);
}
pppery
  • 3,731
  • 22
  • 33
  • 46

0 Answers0