blazeryt1_50272

You type /duel (playername) then they type /duelaccept and then it tps the two players to a random area in the world boarder and then when someone wins play a random minecraft music disc

Kodari AI
KodariAug 23 at 8:23 pm 1
DuelArena
A Minecraft Fabric mod for 1.21.1 that enables player duels. Type /duel (playername) to challenge, then the opponent accepts with /duelaccept. Both players teleport to a random location within the world border. Upon a player's death, the winner is declared and a random music disc is played as victory fanfare. Includes configurable arena boundaries and cooldown timers.
  1. Create the Fabric 1.21.11 project structure and metadata.

  2. Implement /duel <player> challenge/accept flow, border-safe random teleportation, duel state, and winner handling.

  3. Play a random vanilla music disc to the winner when the duel ends.

Created the Fabric 1.21.11 Duel Mod from scratch.

  • /duel <player> sends a challenge.

  • /duelaccept accepts a pending challenge.

  • Players are teleported to a random safe location within the world border.

  • Duel state is tracked and cleaned up on death or disconnect.

  • The winner receives a random vanilla music disc sound.

  • Added Fabric Loom project configuration and metadata.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
LICENSE
settings.gradle
Code
8 382
src/main/java/com/kodari/duel/DuelMod.java
package com.kodari.duel;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DuelMod implements ModInitializer {
    public static final String MOD_ID = "duelmod";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    public static final DuelManager DUELS = new DuelManager();

    @Override
    public void onInitialize() {
        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) ->
            DuelCommands.register(dispatcher)
        );

        ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
            if (entity instanceof net.minecraft.server.network.ServerPlayerEntity player) {
                DUELS.handleDeath(player);
            }
        });

        ServerPlayConnectionEvents.DISCONNECT.register((handler, server) ->
            DUELS.handleDisconnect(handler.getPlayer())
        );

        LOGGER.info("Duel Mod initialized");
    }
}