Начинающий
- Статус
- Оффлайн
- Регистрация
- 16 Мар 2024
- Сообщения
- 425
- Реакции
- 3
делал делал я значит и вот возникла ошибка находится она в строке 25 а именно
addDrawableChild ниже я прикрепил код помогите пж
addDrawableChild ниже я прикрепил код помогите пж
Код:
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);
}
}
}