• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Вопрос Кнопка Drop all в инвентарь на 1.21.4 (уже сделал)(РЕШЕНО)

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
16 Мар 2024
Сообщения
425
Реакции
3
делал делал я значит и вот возникла ошибка находится она в строке 25 а именно
addDrawableChild ниже я прикрепил код помогите пж



Код:
Expand Collapse Copy
package ru.Noname.mixins;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.Noname.common.util.MainUtil;

@Mixin(InventoryScreen.class)
public class InventoryScreenMixin {

    @Inject(method = "init", at = @At("TAIL"))
    private void addDropButton(CallbackInfo ci) {
        InventoryScreen screen = (InventoryScreen) (Object) this;
        MinecraftClient mc = MinecraftClient.getInstance();

        if (mc.player != null && !mc.player.isCreative() && !MainUtil.legitMode) {
            screen.addDrawableChild(
                    ButtonWidget.builder(
                            Text.literal("Drop All"),
                            button -> dropItems(mc, screen)
                    ).dimensions(
                            screen.width / 2 - 50,
                            screen.height / 2 - 125,
                            100,
                            20
                    ).build()
            );
        }
    }

    private void dropItems(MinecraftClient mc, InventoryScreen screen) {
        ClientPlayerEntity player = mc.player;
        if (player == null || mc.interactionManager == null || screen.getScreenHandler() == null) {
            return;
        }

        Inventory inventory = player.getInventory();
        int windowId = screen.getScreenHandler().syncId;

        for (int i = 0; i < inventory.size() && mc.currentScreen == screen; i++) {
            mc.interactionManager.clickSlot(windowId, i, 0, SlotActionType.THROW, player);
        }
    }
}
 
делал делал я значит и вот возникла ошибка находится она в строке 25 а именно
addDrawableChild ниже я прикрепил код помогите пж



Код:
Expand Collapse Copy
package ru.Noname.mixins;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.Noname.common.util.MainUtil;

@Mixin(InventoryScreen.class)
public class InventoryScreenMixin {

    @Inject(method = "init", at = @At("TAIL"))
    private void addDropButton(CallbackInfo ci) {
        InventoryScreen screen = (InventoryScreen) (Object) this;
        MinecraftClient mc = MinecraftClient.getInstance();

        if (mc.player != null && !mc.player.isCreative() && !MainUtil.legitMode) {
            screen.addDrawableChild(
                    ButtonWidget.builder(
                            Text.literal("Drop All"),
                            button -> dropItems(mc, screen)
                    ).dimensions(
                            screen.width / 2 - 50,
                            screen.height / 2 - 125,
                            100,
                            20
                    ).build()
            );
        }
    }

    private void dropItems(MinecraftClient mc, InventoryScreen screen) {
        ClientPlayerEntity player = mc.player;
        if (player == null || mc.interactionManager == null || screen.getScreenHandler() == null) {
            return;
        }

        Inventory inventory = player.getInventory();
        int windowId = screen.getScreenHandler().syncId;

        for (int i = 0; i < inventory.size() && mc.currentScreen == screen; i++) {
            mc.interactionManager.clickSlot(windowId, i, 0, SlotActionType.THROW, player);
        }
    }
}
/up
 
делал делал я значит и вот возникла ошибка находится она в строке 25 а именно
addDrawableChild ниже я прикрепил код помогите пж



Код:
Expand Collapse Copy
package ru.Noname.mixins;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.Noname.common.util.MainUtil;

@Mixin(InventoryScreen.class)
public class InventoryScreenMixin {

    @Inject(method = "init", at = @At("TAIL"))
    private void addDropButton(CallbackInfo ci) {
        InventoryScreen screen = (InventoryScreen) (Object) this;
        MinecraftClient mc = MinecraftClient.getInstance();

        if (mc.player != null && !mc.player.isCreative() && !MainUtil.legitMode) {
            screen.addDrawableChild(
                    ButtonWidget.builder(
                            Text.literal("Drop All"),
                            button -> dropItems(mc, screen)
                    ).dimensions(
                            screen.width / 2 - 50,
                            screen.height / 2 - 125,
                            100,
                            20
                    ).build()
            );
        }
    }

    private void dropItems(MinecraftClient mc, InventoryScreen screen) {
        ClientPlayerEntity player = mc.player;
        if (player == null || mc.interactionManager == null || screen.getScreenHandler() == null) {
            return;
        }

        Inventory inventory = player.getInventory();
        int windowId = screen.getScreenHandler().syncId;

        for (int i = 0; i < inventory.size() && mc.currentScreen == screen; i++) {
            mc.interactionManager.clickSlot(windowId, i, 0, SlotActionType.THROW, player);
        }
    }
}
уже сделал
мне помощь уже не нужна
 
Назад
Сверху Снизу