FunIsaacXD
📎 1 file 6,444 chars
📄
pasted-code-1794954508110.txt
txt 77 lines
▶
Create a complete Minecraft Java Edition 26.3 Fabric mod (using Fabric API) that implements an Admin-Controlled Slot Machine Event System inspired by the "DEDsafío" Minecraft series.

### 1. Admin Trigger Item & Permissions
- Create a custom admin item: `Admin Event Controller` (enchanted golden lever/star icon) obtainable only via Creative mode or `/give`.
- Right-clicking with this item checks if the player has operator permissions (`permissionLevel >= 2` or Creative mode). If not, cancel the action and show a red actionbar message: "No tienes permisos de administrador para usar esto."
- If the player is an admin, open the configuration GUI (`AdminSlotConfigScreen`).

### 2. Admin Configuration GUI (`AdminSlotConfigScreen`)
Design a clean, scrollable or paged GUI screen before spinning the slot machine, containing:

1. **Color / Event Category Selector (Cycle Button or Grid of Colored Buttons):**
   Allows the admin to select the exact winning slot color/category:
   - **ROJO (Momento Revil):** Extreme combat danger / hostile mob buffs.
   - **ROSA (Momento Nutria):** Troll mechanics, roleplay, or custom admin-triggered actions.
   - **NARANJA (Momento Misión / Reto):** Timed server-wide or player challenges/quests.
   - **AMARILLO (Momento Caos / Entorno):** Environmental traps and dangerous block interactions.
   - **AZUL (Momento Tormenta / Clima):** Severe weather hazards and lightning events.
   - **MORADO (Momento Ender / Dimensión):** Void, Enderman, and teleportation alterations.
   - **NEGRO (Momento Pesadilla / UHC):** Hardcore survival restrictions and darkness.
   - **VERDE (Momento Suerte):** Positive buffs and loot blessings.
   - **BLANCO (Momento Purificación):** Cleanses active negative modifiers and restores peace.
   - **DORADO (Momento Épico / Jackpot):** Rare server-wide special reward or mega-event.
   - **ALEATORIO (Random):** Randomly selects one of the colors above.

2. **Custom Announcement Text Field (`EditBoxWidget`):**
   - A text input box where the admin types the exact custom title/message displayed to all players when the slot machine stops (e.g., "¡LAS PUERTAS AHORA MATAN!" or "MISIÓN: CONSIGUE UN DIAMANTE EN 5 MIN").

3. **Dynamic Consequence Selector (Sub-menu / Extra Box):**
   - Based on the selected Color, dynamically display a secondary list of toggleable world modifiers or custom input fields:
     - *If ROJO (Revil):*
       - `[ ] Creepers Eléctricos` (All Creepers spawn charged).
       - `[ ] Esqueletos Francotiradores` (Skeletons spawn with Power V bows).
       - `[ ] Zombis Velocistas` (Zombies spawn with Speed II and Strength I).
       - `[ ] Daño Duplicado` (All hostile mobs deal 2x damage).
     - *If ROSA (Nutria / Custom):*
       - `[ ] Solo Anuncio / Acción Manual` (Triggers the slot animation and custom text only, so the admin can execute the troll/event manually later).
       - `[ ] Comando Custom (Inmediato o Guardado)` (Extra text field to enter a server command like `/summon...` or `/effect...`, with a toggle to run immediately when the slot stops OR save it to trigger later via `/dedsafio nutria trigger`).
     - *If NARANJA (Misión / Reto):*
       - `[ ] Temporizador en Pantalla` (Displays a countdown timer bossbar/HUD in minutes entered by the admin, e.g., 5:00, accompanied by the custom text).
       - `[ ] Castigo al Fallar` (Optional toggle to strike lightning or apply Wither if the admin fails the mission via command).
     - *If AMARILLO (Caos / Entorno):*
       - `[ ] Puertas Mortales` (Opening/interacting with any door deals 20 HP / 10 hearts of damage).
       - `[ ] Agua Ácida` (Touching water inflicts continuous Poison/Wither).
       - `[ ] Menas Explosivas` (Mining any ore has a 15% chance to cause a small TNT explosion).
     - *If AZUL (Tormenta / Clima):*
       - `[ ] Tormenta Eléctrica Letal` (Forces permanent thunderstorm and strikes lightning near random players every 20 seconds).
       - `[ ] Lluvia Tóxica` (Players exposed to rain without a roof take slowness and hunger).
     - *If MORADO (Ender / Dimensión):*
       - `[ ] Mirada Letal` (Endermen aggro from 64 blocks and inflict Blindness).
       - `[ ] Teletransporte Caótico` (Taking damage has a 20% chance to randomly teleport the player nearby).
     - *If NEGRO (Pesadilla / UHC):*
       - `[ ] Modo UHC (Sin Regeneración Natural)` (Disables `naturalRegeneration` gamerule).
       - `[ ] Oscuridad Eterna` (Applies periodic Darkness effect and forces midnight).
     - *If VERDE (Suerte):*
       - `[ ] Bendición de Vida` (Gives all players Regeneration II, Absorption, and Saturation for 5 minutes).
     - *If BLANCO (Purificación):*
       - `[ ] Limpiar Todo` (Resets all active negative DEDsafío world modifiers, restores daylight, and clears weather).
     - *If DORADO (Épico / Jackpot):*
       - `[ ] Lluvia de Regalos / Ítem Custom` (Gives every online player a Totem of Undying + Golden Apples, or runs a custom reward command).

4. **"GIRAR TRAGAPERRAS" (Spin) Button:**
   - Sends a C2S packet to the server with the selected Color, Custom Text, and chosen Modifier settings.

### 3. Slot Machine HUD Overlay (All Players)
- Broadcast an S2C packet to **all connected players**.
- Render a sleek **3-Reel Slot Machine HUD** at the top-center of every player's screen (without blocking movement or mouse control).
- The 3 reels cycle rapidly through all 10 color icons/blocks for ~4 seconds with ticking/note-block sound effects, stopping one by one (Reel 1 -> Reel 2 -> Reel 3) on the exact color chosen by the admin.
- When all 3 reels lock onto the winning color:
  - Play a fitting sound effect (`ENTITY_WITHER_SPAWN` for Red/Black, `ENTITY_LIGHTNING_BOLT_THUNDER` for Blue, `UI_TOAST_CHALLENGE_COMPLETE` for Gold/Green/White, `BLOCK_NOTE_BLOCK_CHIME` for Pink/Orange).
  - Display a colored banner directly underneath showing the **Color Name** and the **Admin's Custom Text** for 5 seconds before fading out.

### 4. Server Persistence & Admin Commands
- Save active world modifiers in a `PersistentState` so rules like Deadly Doors, UHC Mode, or Charged Creepers persist until turned off.
- Provide commands:
  - `/dedsafio reset` (Disables all active modifiers and timers).
  - `/dedsafio nutria trigger` (Executes the saved custom Pink/Nutria command).
  - `/dedsafio timer stop` (Stops an active Orange mission timer).
Kodari AI
KodariTue at 10:36 pm 15
DedsafioSlotMachine
An admin-controlled slot machine event system for Minecraft Fabric 26.3. Admins use a custom enchanted lever item to open a configuration GUI with 11 color-coded event categories (Red combat, Pink troll, Orange missions, etc.), custom announcement text field, and dynamic consequence selectors per category. Spinning broadcasts a 3-reel HUD overlay to all players with synchronized stopping animation and sound effects. Active world modifiers persist via PersistentState, with commands to reset, trigger saved commands, and stop timers.

Created the project foundation and admin controller. Obtain it from Creative inventory or with /give @s dedsafio:admin_event_controller.

The event system is incomplete: the configuration controls, slot HUD, modifiers, persistence, and commands are not yet implemented. The controller currently opens a placeholder screen. The project has not been compiled.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
13 206
src/main/java/com/kodari/dedsafio/DedsafioMod.java
package com.kodari.dedsafio;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.ChatFormatting;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.Permissions;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public final class DedsafioMod implements ModInitializer {
    private static final Identifier ID = Identifier.fromNamespaceAndPath("dedsafio", "admin_event_controller");
    public static final Item CONTROLLER = Registry.register(BuiltInRegistries.ITEM, ID,
            new ControllerItem(new Item.Properties().setId(ResourceKey.create(Registries.ITEM, ID)).stacksTo(1)));

    @Override
    public void onInitialize() {
        PayloadTypeRegistry.clientboundPlay().register(OpenConfigPayload.TYPE, OpenConfigPayload.CODEC);
        CreativeModeTabEvents.modifyOutputEvent(ResourceKey.create(Registries.CREATIVE_MODE_TAB,
                Identifier.withDefaultNamespace("tools_and_utilities"))).register(output ->
                output.accept(new ItemStack(CONTROLLER), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS));
    }

    private static final class ControllerItem extends Item {
        private ControllerItem(Properties properties) {
            super(properties);
        }

        @Override
        public InteractionResult use(Level level, Player player, InteractionHand hand) {
            if (player instanceof ServerPlayer serverPlayer) {
                if (!player.isCreative() && !serverPlayer.createCommandSourceStack().permissions()
                        .hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
                    serverPlayer.sendOverlayMessage(Component.literal("No tienes permisos de administrador para usar esto.")
                            .withStyle(ChatFormatting.RED));
                } else {
                    ServerPlayNetworking.send(serverPlayer, new OpenConfigPayload(""));
                }
            }
            return InteractionResult.SUCCESS;
        }
    }
}