Luca Schmidt

mach mir das ich feuerbälle werfen kann und die explosion mit feuer und der kraft eines tnt

Kodari AI
KodariNov 13 at 10:05 pm 2
FireballLauncher
A Minecraft Fabric mod for version 1.21.1 that allows players to launch explosive fireballs. Right-clicking with a specific item (Blaze Rod) while sneaking charges and fires a powerful fireball projectile. The fireball travels in the player's look direction, explodes on impact with the force of TNT, and ignites surrounding blocks with fire. Includes configurable explosion power, fire spread toggle, and cooldown system to balance gameplay. The mod adds a custom fireball entity with particle effects and sound feedback for an immersive experience.
  • Feuerkugeln lassen sich mit Feuerladungen per Rechtsklick werfen.

  • Beim Aufprall explodieren sie mit TNT-Stärke und entzünden Feuer.

Wirf eine Feuerladung per Rechtsklick, um einen Feuerball abzufeuern. Beim Aufprall explodiert er mit TNT-Stärke und entfacht Feuer.

Im Überlebensmodus kannst du Feuerladungen herstellen oder als Beute finden.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
7 157
src/main/java/de/kodari/feuerball/FeuerballMod.java
package de.kodari.feuerball;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.entity.projectile.FireballEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;

public class FeuerballMod implements ModInitializer {
    public static final String FIREBALL_TAG = "feuerball.thrown";

    @Override
    public void onInitialize() {
        UseItemCallback.EVENT.register((player, world, hand) -> {
            ItemStack stack = player.getStackInHand(hand);
            if (player.isSpectator() || !stack.isOf(Items.FIRE_CHARGE)) {
                return ActionResult.PASS;
            }

            if (world instanceof ServerWorld serverWorld) {
                Vec3d direction = player.getRotationVec(1.0F);
                FireballEntity fireball = new FireballEntity(world, player, direction, 4);
                fireball.setPosition(player.getEyePos().add(direction.multiply(1.5)));
                fireball.setVelocity(direction.multiply(1.0));
                fireball.addCommandTag(FIREBALL_TAG);
                if (serverWorld.spawnEntity(fireball)) {
                    stack.decrementUnlessCreative(1, player);
                }
            }

            return ActionResult.SUCCESS;
        });
    }
}