ibrahim_00123

"Create a Minecraft Fabric/Forge mod for Minecraft 1.21.x that adds an Admin Tools menu for players with operator permissions only. The mod should include INVENTORY GUI buttons for Game Mode switching, Weather and Time controls, Give Items, Heal, Feed, Fly, God Mode, Vanish, Teleport, WorldEdit-style utilities, Player Inventory Viewer, Mob Spawner, and custom admin commands. Every feature must check that the player has OP permission level 4 before executing. The mod should be optimized, configurable, and compatible with multiplayer servers where the player is already authorized."

Kodari AI
KodariJul 4 at 10:22 pm 2

I’ll create a comprehensive Admin Tools mod for Fabric 1.21.11.

AdminTools
A comprehensive admin tools mod for Minecraft 1.21.11 that provides an in-game GUI menu for players with operator permission level 4. Features include game mode switching, weather and time controls, player healing/feeding, fly/god/vanish toggles, item giving, teleportation, basic WorldEdit utilities, player inventory viewing, mob spawning, and custom admin commands. All actions require OP level 4, configurable via JSON, and optimized for multiplayer servers.

I also need to handle the keybinding check on the client. Let me add the keybinding handling in the client tick event:

Let me update the AdminToolsClient to also handle the keybind on tick:

Wait, the Identifier needs to be imported - I see the first version imports net.minecraft.util.Identifier but in the second version I overwrite it. Let me check… The second version does import it. Good.

Now let me also add the icon file for the fabric.mod.json reference. Since we can’t make actual images, I’ll skip that (Minecraft uses a default).

But wait, I need a texture for the admin_bg.png that the screen references. Let me remove that reference since I’m not providing a texture - I’ll just use draw-filled rectangles instead.

Let me update the AdminScreen to not reference the texture:

I already don’t use it in the render code - I use context.fill(...) instead. The BACKGROUND identifier is declared but unused. Let me remove it. Let me fix the screen.

Also, I need to make sure the files I created are correct. Let me fix the AdminScreen to remove the unused texture identifier and also make sure all the imports work.

Let me create the lang file again with all needed keys and then re-create the screen without the unused identifier.

Actually, let me just patch the screen to remove the unused identifier.

I also realize I need to handle the keybinding more carefully. The openScreenKey.wasPressed() needs to be checked. But the player might not have OP level 4. However, the screen is just a UI - all actions will be validated on the server. So it’s fine to open the screen for anyone; they just can’t execute anything.

Let me finalize everything. Let me patch the screen file.Now let me fix the screen to remove the unused texture reference

Now let me create the mixin config and the vanish mixin — I need mixins for the vanish feature:

I need to use inline <create> tags for file creation. Let me create the remaining files:

Now let me also add the client-side mixin for vanish rendering (hide vanished players):

Now let me update the client class to handle the vanish sync properly. Let me rewrite the AdminToolsClient to include vanish tracking:

Now let me also update the fabric.mod.json to include the client mixin:

Now let me update the client mixins config to include the client mixin:

Wait, I need to check the mixin config format. The client field should be able to use fully qualified names since the package is set in package. Let me use the simpler approach - keep the package prefix and just use the simple class name.

Actually, looking at the mixin config format:

  • package is the base package

  • mixins classes are relative to that package

  • client classes are also relative

So com.example.admintools.mixin.client.EntityRenderDispatcherMixin would be relative to com.example.admintools.mixin, making it client.EntityRenderDispatcherMixin.

Let me fix that:

Now let me verify all files are present and correct. Let me think about potential issues:

  1. The AdminPayloads.java uses registern - this is a typo! It should be register. Let me fix that.

  2. The AdminScreen.java - it references BACKGROUND which I removed via patch, but the patch might have left an orphaned import. Let me check.

  3. The AdminCommands.java - I need to use command.getEntityWorld() instead of command.getWorld() for entity methods.

  4. The ActionExecutor.java - uses entity.getEntityWorld() which is correct.

  5. The PermissionHelper.java - checks hasPermissionLevel(4) - correct.

Let me fix the AdminPayloads typo and the AdminScreen import issue.

Actually, let me first check what files I’ve created so far and their current state by reading the key ones.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
18 1,469
src/client/java/com/example/admintools/AdminToolsClient.java
package com.example.admintools;

import com.example.admintools.gui.AdminScreen;
import com.example.admintools.network.AdminPayloads;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.SimpleOption;
import org.lwjgl.glfw.GLFW;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class AdminToolsClient implements ClientModInitializer {

    private static final Set<UUID> VANISHED_PLAYERS = new HashSet<>();

    public static boolean isVanished(UUID uuid) {
        return VANISHED_PLAYERS.contains(uuid);
    }

    @Override
    public void onInitializeClient() {
        var category = KeyBinding.Category.create(net.minecraft.util.Identifier.of("admintools", "keys"));
        KeyBinding openMenuKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.admintools.open_menu", GLFW.GLFW_KEY_M, category)
        );

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (openMenuKey.wasPressed()) {
                if (client.player != null) {
                    client.setScreen(new AdminScreen());
                }
            }
        });

        // Receive vanish sync from server
        ClientPlayNetworking.registerGlobalReceiver(AdminPayloads.VanishSyncPayload.ID, (payload, context) -> {
            if (payload.vanished()) {
                VANISHED_PLAYERS.add(payload.playerUuid());
            } else {
                VANISHED_PLAYERS.remove(payload.playerUuid());
            }
        });
    }
}