Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Часть функционала Фаст действия с инвентарём забрать всё / сложить всё / выкинуть

  • Автор темы Автор темы capsize
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
20 Окт 2025
Сообщения
40
Реакции
0
Выберите загрузчик игры
  1. Fabric
пр, я главный лгбт кодер и пастер югейма делаю тутор на то чтобы в инвентаре/сундуках и тд было забрать все / сложить все/ выкинуть на 1.21 фабрик

создаем миксин : MixinInventoryScreen или если есть то туда делаем он добавляет кнопку Drop All которая по очереди выкидывает все шмотки код : ( если что все миксины регаем а то работать не будет )
// инвентори скрин класс должен быть //
@Mixin(InventoryScreen.class)
public abstract class MixinInventoryScreen extends HandledScreen<PlayerScreenHandler> {

@Inject(method = "init", at = @At("TAIL"))
private void addDropButton(CallbackInfo ci) {
// сама кнопка типо //
this.addDrawableChild(
ButtonWidget.builder(Text.literal("Drop All"), button -> dropItems())
.dimensions(this.width / 2 - 50, this.height / 2 - 125, 100, 20)
.build()
);
}

private void dropItems() {
if (client.player == null || client.interactionManager == null) return;

int windowId = this.getScreenHandler().syncId;
int slots = this.getScreenHandler().slots.size();

// в разныхз потоках тд тп //
new Thread(() -> {
for (int i = 0; i < slots; i++) {
// закрыт инвентарь - не выкидываем разную залупу в инвентаре //
if (client.currentScreen != this) break;

// проверка есть ли вообще что то в инвентаре //
if (!this.getScreenHandler().getSlot(i).hasStack()) continue;

int slotId = i;
client.execute(() -> {
// сам выброс предметов //
client.interactionManager.clickSlot(windowId, slotId, 1, SlotActionType.THROW, client.player);
});

try {
Thread.sleep(50); // Задержка, чтобы сервак не кикнул за спам пакетами ну типо поняли да тупой античит будет кикать если так не делать //
} catch (InterruptedException ignored) {}
}
}).start();
}
}

дальше для сундуков делаем MixinHandledScreen но если у вас все это есть то не надо вот код :

в хендлед скрин чтобы работало везде
@Mixin(HandledScreen.class)
public abstract class MixinHandledScreen<T extends ScreenHandler> extends Screen {

@Inject(method = "init", at = @At("TAIL"))
private void addContainerButtons(CallbackInfo ci) {
проверка на то что это сундук и тд а не какая то залупень
if ((Object)this instanceof GenericContainerScreen || (Object)this instanceof ShulkerBoxScreen) {

сама кнопка сложить всё
this.addDrawableChild(
ButtonWidget.builder(Text.literal("Store All"), b -> moveItems(true))
.dimensions(this.x + this.backgroundWidth + 5, this.y, 60, 20)
.build()
);

// сама кнопка "забрать всё"
this.addDrawableChild(
ButtonWidget.builder(Text.literal("Take All"), b -> moveItems(false))
.dimensions(this.x + this.backgroundWidth + 5, this.y + 25, 60, 20)
.build()
);
}
}

private void moveItems(boolean store) {
if (client.player == null || client.interactionManager == null) return;

int windowId = this.getScreenHandler().syncId;
int containerSlots = 0;

// чекаем скок слотов в сундуках и тд //
if ((Object)this instanceof GenericContainerScreen screen) {
containerSlots = screen.getScreenHandler().getRows() * 9;
} else if ((Object)this instanceof ShulkerBoxScreen) {
containerSlots = 27;
}

int totalSlots = this.getScreenHandler().slots.size();
int start = store ? containerSlots : 0;
int end = store ? totalSlots : containerSlots;

new Thread(() -> {
for (int i = start; i < end; i++) {
if (client.currentScreen != this) break;

if (!this.getScreenHandler().getSlot(i).hasStack()) continue;

int slotId = i;
client.execute(() -> {
// юзаем шифт чтобы быстро брать и тд //
client.interactionManager.clickSlot(windowId, slotId, 0, SlotActionType.QUICK_MOVE, client.player);
});

try {
Thread.sleep(50);
} catch (InterruptedException ignored) {}
}
}).start();
}
}


ну вот и все у вас готово быстродействие с сундуками и инвентарем. всем пака :roflanPominki:
 
гпт сделает за 20 секунд и ничего добавлять и самому делать не надо будет смысл твоего поста?
 
Назад
Сверху Снизу