Skip to content

Inventory drop all button #5532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import meteordevelopment.meteorclient.mixininterface.IDropItems;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.screen.ingame.RecipeBookScreen;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.PlayerScreenHandler;
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;

/**
* @author NDev007
* @since 27.06.2025
*/

@Mixin(InventoryScreen.class)
public abstract class InventoryScreenMixin extends RecipeBookScreen<PlayerScreenHandler> implements IDropItems {

public InventoryScreenMixin(PlayerScreenHandler handler, RecipeBookWidget<?> recipeBook, PlayerInventory inventory, Text title) {
super(handler, recipeBook, inventory, title);
}

@Override
public void dropItems() {
if (this.client == null || this.client.interactionManager == null || this.client.player == null) {
return;
}

for (int i = 0; i < this.handler.slots.size(); ++i) {
if (this.client.currentScreen != this) {
break;
}
this.client.interactionManager.clickSlot(this.handler.syncId, i, 0, SlotActionType.PICKUP, this.client.player);
this.client.interactionManager.clickSlot(this.handler.syncId, -999, 0, SlotActionType.PICKUP, this.client.player);
}
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/RecipeBookScreen;init()V", shift = At.Shift.AFTER))
private void onInit(CallbackInfo ci) {
InventoryTweaks invTweaks = Modules.get().get(InventoryTweaks.class);

if (invTweaks.isActive() && invTweaks.showButtons()){
this.addDrawableChild(ButtonWidget.builder(
Text.literal("Drop all"),
(button) -> {
this.dropItems();
}
)
.dimensions(this.width / 2 - 32, this.height / 2 - 110, 64, 20)
.build());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixininterface;

/**
* @author NDev007
* @since 27.06.2025
*/
public interface IDropItems {
void dropItems();
}
1 change: 1 addition & 0 deletions src/main/resources/meteor-client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"IdentifierAccessor",
"InGameHudMixin",
"InGameOverlayRendererMixin",
"InventoryScreenMixin",
"ItemEntityRendererMixin",
"ItemGroupsMixin",
"ItemMixin",
Expand Down