Gwggev Tsamshehebs

Can you make me a mod where a command gives you a fishing rod that drops dragon fireballs in a array of circles like 5 rows of circle and each 12 blocks away from each other with every row being a little larger than the rest

Kodari AI
KodariNov 2 at 8:01 am 3
DragonFireCircleRod
A Fabric mod for Minecraft 1.21.1 that adds a command to give players a special fishing rod. When used, the rod launches dragon fireballs in a circular pattern across five rows. Each row is spaced 12 blocks apart, with each successive row having a larger radius than the previous, creating an expanding array of explosive projectiles.
  • Add a command that gives a special fishing rod.

  • Make the rod launch five expanding rings of dragon fireballs, spaced 12 blocks apart.

Created the Dragon Fireball Rod. An operator can use /dragonrod to get it, then right-click to rain fireballs in five rings centered on the player, with 12 blocks between rings.

This is a command-only item; it has no survival recipe.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 144
src/main/java/com/kodari/dragonrod/DragonRodMod.java
package com.kodari.dragonrod;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.command.DefaultPermissions;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.entity.projectile.DragonFireballEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;

public class DragonRodMod implements ModInitializer {
    private static final String MARKER = "dragon_fireball_rod";

    @Override
    public void onInitialize() {
        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) ->
            dispatcher.register(CommandManager.literal("dragonrod")
                .requires(source -> source.getPermissions().hasPermission(DefaultPermissions.GAMEMASTERS))
                .executes(context -> {
                    ItemStack rod = new ItemStack(Items.FISHING_ROD);
                    NbtCompound data = new NbtCompound();
                    data.putBoolean(MARKER, true);
                    rod.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(data));
                    rod.set(DataComponentTypes.CUSTOM_NAME, Text.literal("Dragon Fireball Rod"));
                    return context.getSource().getPlayerOrThrow().giveItemStack(rod) ? 1 : 0;
                }))
        );

        UseItemCallback.EVENT.register((player, world, hand) -> {
            ItemStack stack = player.getStackInHand(hand);
            NbtComponent data = stack.get(DataComponentTypes.CUSTOM_DATA);
            if (!stack.isOf(Items.FISHING_ROD) || data == null || !data.copyNbt().getBoolean(MARKER, false)) {
                return ActionResult.PASS;
            }

            if (world instanceof ServerWorld serverWorld) {
                for (int ring = 1; ring <= 5; ring++) {
                    double radius = ring * 12.0;
                    int count = ring * 8;
                    for (int i = 0; i < count; i++) {
                        double angle = 2.0 * Math.PI * i / count;
                        DragonFireballEntity fireball = new DragonFireballEntity(serverWorld, player, new Vec3d(0, -1, 0));
                        fireball.setPosition(player.getX() + Math.cos(angle) * radius,
                            player.getY() + 24.0,
                            player.getZ() + Math.sin(angle) * radius);
                        serverWorld.spawnEntity(fireball);
                    }
                }
            }
            return ActionResult.SUCCESS;
        });
    }
}