Implement the user's requested Minecraft 1.21.11 Fabric mod feature in this project. The command /OrbitalWindcharge should give the executing player a special fishing rod. When that rod is cast/thrown, do NOT wait for or use the fishing hook's eventual landing position: determine the target from the player's look direction at cast time (raycast from the eye to the first block/entity hit within a sensible range; use a sensible endpoint fallback if nothing is hit), then spawn exactly 300 actual wind-charge projectiles/effects at that target point. The special rod must have exactly 1 durability remaining and break on that cast/throw. Ensure the behavior runs server-side and works in multiplayer; ordinary fishing rods should remain unchanged. Use the existing project template/conventions and appropriate Fabric APIs/mixins for this version. Do not add tests. Make only the feature implementation and any necessary registration/resources; report the files/approach and any behavior caveats when done.

Kodari AI
KodariOct 26 at 6:42 am 6
OrbitalWindchargeRod
A Fabric mod for Minecraft 1.21.11 that adds a special fishing rod obtainable via the /OrbitalWindcharge command. When cast, it raycasts from the player's eye along their look direction to determine the target point, then spawns 300 wind-charge projectiles at that location. The rod has exactly 1 durability and breaks after a single cast, functioning server-side in multiplayer while leaving ordinary fishing rods unchanged.
  1. Add the special fishing-rod item and cast-time target/burst behavior.

  2. Register /OrbitalWindcharge and the item, with the required Fabric project/resource files.

Implemented the Fabric 1.21.11 mod.

  • /OrbitalWindcharge gives the executing player a custom rod with exactly one durability remaining.

  • Casting it raycasts up to 64 blocks from the player’s eye, selects the nearest block or entity hit (or the ray endpoint if nothing is hit), spawns 300 actual wind-charge projectiles in a burst at that point, then breaks the rod. The behavior is server-side; ordinary fishing rods are unchanged.

  • Added the project setup, mod and command registration, item model and name, and a custom rod texture. No tests were added.

Caveat: spawning 300 projectiles at once can create substantial server load and knockback effects.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 219
src/main/java/dev/kodari/orbitalwindcharge/OrbitalWindchargeMod.java
package dev.kodari.orbitalwindcharge;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileUtil;
import net.minecraft.entity.projectile.WindChargeEntity;
import net.minecraft.item.FishingRodItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.World;

public final class OrbitalWindchargeMod implements ModInitializer {
    public static final String MOD_ID = "orbitalwindcharge";
    private static final int ROD_MAX_DAMAGE = 64;
    private static final int WIND_CHARGE_COUNT = 300;
    private static final double TARGET_RANGE = 64.0;
    private static final Item ORBITAL_WINDCHARGE_ROD = registerRod();

    @Override
    public void onInitialize() {
        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) ->
                dispatcher.register(CommandManager.literal("OrbitalWindcharge").executes(context -> {
                    PlayerEntity player = context.getSource().getPlayerOrThrow();
                    ItemStack rod = new ItemStack(ORBITAL_WINDCHARGE_ROD);
                    rod.setDamage(rod.getMaxDamage() - 1);
                    player.giveItemStack(rod);
                    return 1;
                })));
    }

    private static Item registerRod() {
        Identifier id = Identifier.of(MOD_ID, "orbital_windcharge_rod");
        RegistryKey<Item> key = RegistryKey.of(RegistryKeys.ITEM, id);
        return Registry.register(Registries.ITEM, key,
                new OrbitalWindchargeRod(new Item.Settings().maxDamage(ROD_MAX_DAMAGE).registryKey(key)));
    }

    private static Vec3d findTarget(ServerWorld world, PlayerEntity player) {
        Vec3d start = player.getEyePos();
        Vec3d direction = player.getRotationVec(1.0F);
        Vec3d end = start.add(direction.multiply(TARGET_RANGE));

        BlockHitResult blockHit = world.raycast(new RaycastContext(
                start,
                end,
                RaycastContext.ShapeType.OUTLINE,
                RaycastContext.FluidHandling.NONE,
                player
        ));
        EntityHitResult entityHit = ProjectileUtil.raycast(
                player,
                start,
                end,
                player.getBoundingBox().stretch(direction.multiply(TARGET_RANGE)).expand(1.0),
                entity -> entity != player,
                TARGET_RANGE * TARGET_RANGE
        );

        if (entityHit != null && (blockHit.getType() != HitResult.Type.BLOCK
                || start.squaredDistanceTo(entityHit.getPos()) < start.squaredDistanceTo(blockHit.getPos()))) {
            return entityHit.getPos();
        }
        if (blockHit.getType() == HitResult.Type.BLOCK) {
            return blockHit.getPos();
        }
        return end;
    }

    private static void spawnWindCharges(ServerWorld world, PlayerEntity owner, Vec3d target) {
        double goldenAngle = Math.PI * (3.0 - Math.sqrt(5.0));
        for (int i = 0; i < WIND_CHARGE_COUNT; i++) {
            double y = 1.0 - 2.0 * (i + 0.5) / WIND_CHARGE_COUNT;
            double radius = Math.sqrt(1.0 - y * y);
            double angle = i * goldenAngle;
            Vec3d velocity = new Vec3d(radius * Math.cos(angle), y, radius * Math.sin(angle)).multiply(0.7);
            WindChargeEntity charge = new WindChargeEntity(owner, world, target.x, target.y, target.z);
            charge.setVelocity(velocity);
            world.spawnEntity(charge);
        }
    }

    private static final class OrbitalWindchargeRod extends FishingRodItem {
        private OrbitalWindchargeRod(Item.Settings settings) {
            super(settings);
        }

        @Override
        public ActionResult use(World world, PlayerEntity user, Hand hand) {
            if (world instanceof ServerWorld serverWorld) {
                Vec3d target = findTarget(serverWorld, user);
                spawnWindCharges(serverWorld, user, target);
                user.getStackInHand(hand).damage(1, user, hand);
            }
            return ActionResult.SUCCESS;
        }
    }
}