Miłosz

Stwórz mod .jar na java 26.3 i 26.2 i rzeby działał na anarchi.gg i by robił to rze dodaje mi możliwość brania każdego itemy jaki hce gdy mam /op na serwerze i zrub bym jak wejdę w eku to jestem na moim serwie I mam op to wchodzę w eku I mam taki przycisk z logiem dieta klikam i mam menu gdzie jest każdy blok minecraft i jak na jakiś kliknę to daje mi się on do ekwipunku na wolny slot i zrub by działał na serwerze online gdzie mam op i zrub gotowy plik .jar bym obrazu mugł go wrzucić do minecraft

Kodari AI
KodariOct 3 at 11:55 am 2
CreativeItemMenu
A Fabric mod for Minecraft 26.3 and 26.2 that adds a creative item menu accessible via a button in the inventory when the player has OP permissions. Clicking the button opens a GUI containing every Minecraft block and item. Selecting any item instantly places it into the player's first available inventory slot. Designed for online servers like anarchi.gg where the player has operator status, providing quick access to all game items without commands.

Plan:

  1. Skonfiguruję projekt Fabric dla 26.3 (bez zewnętrznych bibliotek).

  2. Dodam przycisk w ekwipunku otwierający katalog bloków z paginacją.

  3. Kliknięcie bloku wyśle serwerowe /give — zadziała wyłącznie, jeśli serwer rzeczywiście przyznał Ci uprawnienia; nie da się lokalnym modem wymusić itemów na serwerze.

Utworzyłem mod Fabric 26.3: przycisk ♦ przy ekwipunku otwiera katalog bloków z paginacją. Kliknięcie wysyła serwerowi komendę /give; przedmioty otrzymasz tylko wtedy, gdy serwer zaakceptuje tę komendę dla Twojego konta. Mod nie wymaga instalacji po stronie serwera.

Projekt jest skonfigurowany dla Minecraft 26.3, nie 26.2. Nie mogę potwierdzić działania na anarchi.gg ani dołączyć gotowego binarnego .jar w tej odpowiedzi. Plik jar zbudujesz zadaniem Gradle jar; wynik powinien trafić do build/libs/.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 171
src/client/java/pl/kodari/opblockcatalog/BlockCatalogClient.java
package pl.kodari.opblockcatalog;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.network.chat.Component;

public class BlockCatalogClient implements ClientModInitializer {
    @Override
    public void onInitializeClient() {
        ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
            if (!(screen instanceof InventoryScreen)) {
                return;
            }

            int x = Math.max(2, Math.min(scaledWidth / 2 + 90, scaledWidth - 30));
            int y = scaledHeight / 2 - 10;
            Button catalogButton = Button.builder(Component.literal("♦"), button ->
                    client.gui.setScreen(new BlockCatalogScreen(client, screen, 0)))
                    .bounds(x, y, 26, 20)
                    .build();
            Screens.getWidgets(screen).add(catalogButton);
        });
    }

    private static final class BlockCatalogScreen extends Screen {
        private static final java.util.List<net.minecraft.world.item.BlockItem> BLOCKS =
                net.minecraft.core.registries.BuiltInRegistries.ITEM.stream()
                        .filter(net.minecraft.world.item.BlockItem.class::isInstance)
                        .map(net.minecraft.world.item.BlockItem.class::cast)
                        .toList();
        private static final int COLUMNS = 3;
        private static final int ROWS = 6;
        private static final int BUTTON_WIDTH = 98;
        private static final int BUTTON_HEIGHT = 20;
        private static final int GAP = 4;

        private final Minecraft client;
        private final Screen parent;
        private final int page;

        private BlockCatalogScreen(Minecraft client, Screen parent, int page) {
            super(Component.literal("Katalog bloków"));
            this.client = client;
            this.parent = parent;
            this.page = page;
        }

        @Override
        protected void init() {
            int pageSize = COLUMNS * ROWS;
            int pageCount = Math.max(1, (BLOCKS.size() + pageSize - 1) / pageSize);
            int firstItem = page * pageSize;
            int gridWidth = COLUMNS * BUTTON_WIDTH + (COLUMNS - 1) * GAP;
            int gridHeight = ROWS * BUTTON_HEIGHT + (ROWS - 1) * GAP;
            int left = Math.max(4, (this.width - gridWidth) / 2);
            int top = Math.max(52, (this.height - gridHeight - 46) / 2);

            for (int slot = 0; slot < pageSize && firstItem + slot < BLOCKS.size(); slot++) {
                net.minecraft.world.item.BlockItem blockItem = BLOCKS.get(firstItem + slot);
                net.minecraft.resources.Identifier id =
                        net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(blockItem);
                int column = slot % COLUMNS;
                int row = slot / COLUMNS;
                String idString = id.toString();
                int separator = idString.indexOf(':');
                String label = separator >= 0 ? idString.substring(separator + 1) : idString;

                this.addRenderableWidget(Button.builder(Component.literal(label), button -> {
                    if (this.client.player != null) {
                        this.client.player.connection.sendCommand("give @s " + idString + " 1");
                    }
                }).bounds(left + column * (BUTTON_WIDTH + GAP), top + row * (BUTTON_HEIGHT + GAP),
                        BUTTON_WIDTH, BUTTON_HEIGHT).build());
            }

            int footerWidth = 72 + GAP + 90 + GAP + 72;
            int footerLeft = (this.width - footerWidth) / 2;
            int footerY = top + gridHeight + 8;
            this.addRenderableWidget(Button.builder(Component.literal("<"), button -> {
                if (this.page > 0) {
                    this.client.gui.setScreen(new BlockCatalogScreen(this.client, this.parent, this.page - 1));
                }
            }).bounds(footerLeft, footerY, 72, BUTTON_HEIGHT).build());
            this.addRenderableWidget(Button.builder(Component.literal((this.page + 1) + "/" + pageCount), button -> {
            }).bounds(footerLeft + 76, footerY, 90, BUTTON_HEIGHT).build());
            this.addRenderableWidget(Button.builder(Component.literal(">"), button -> {
                if (this.page + 1 < pageCount) {
                    this.client.gui.setScreen(new BlockCatalogScreen(this.client, this.parent, this.page + 1));
                }
            }).bounds(footerLeft + 170, footerY, 72, BUTTON_HEIGHT).build());
        }

        @Override
        public void onClose() {
            this.client.gui.setScreen(this.parent);
        }
    }
}