diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java index 35e0c87c30..21a4d238f3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java @@ -7,6 +7,7 @@ import meteordevelopment.meteorclient.mixininterface.IAbstractFurnaceMenu; import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.ItemListSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; @@ -15,6 +16,7 @@ import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; import net.minecraft.world.inventory.AbstractFurnaceMenu; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -34,6 +36,15 @@ public class AutoSmelter extends Module { .build() ); + private final Setting fuelItemsPerRefill = sgGeneral.add(new IntSetting.Builder() + .name("fuel-items-per-refill") + .description("How many fuel items to put into the furnace each time it refills") + .defaultValue(64) + .range(1, 64) + .sliderRange(1, 16) + .build() + ); + private final Setting> smeltableItems = sgGeneral.add(new ItemListSetting.Builder() .name("smeltable-items") .description("Items to smelt") @@ -50,6 +61,12 @@ public class AutoSmelter extends Module { .build() ); + private final Setting autoClose = sgGeneral.add(new BoolSetting.Builder() + .name("auto-close") + .defaultValue(false) + .build() + ); + public AutoSmelter() { super(Categories.World, "auto-smelter", "Automatically smelts items from your inventory"); } @@ -76,6 +93,8 @@ public void tick(AbstractFurnaceMenu c) { // Insert new items insertItems(c); + + if (autoClose.get()) mc.setScreen(null); } private void insertItems(AbstractFurnaceMenu c) { @@ -100,7 +119,10 @@ private void insertItems(AbstractFurnaceMenu c) { return; } + if (slot == -1) return; + InvUtils.move().fromId(slot).toId(0); + c.slots.getFirst().getItem().isEmpty(); } private void checkFuel(AbstractFurnaceMenu c) { @@ -125,7 +147,32 @@ private void checkFuel(AbstractFurnaceMenu c) { return; } - InvUtils.move().fromId(slot).toId(1); + if (slot == -1) return; + + ItemStack sourceStack = c.slots.get(slot).getItem(); + int moveCount = Math.min(fuelItemsPerRefill.get(), Math.min(sourceStack.getCount(), c.slots.get(1).getMaxStackSize(sourceStack))); + + if (moveCount <= 0) return; + + moveFuelItems(c, slot, moveCount); + } + + private void moveFuelItems(AbstractFurnaceMenu c, int fromId, int amount) { + if (amount <= 0 || mc.player == null || mc.gameMode == null) return; + if (!mc.player.containerMenu.getCarried().isEmpty()) return; + + mc.gameMode.handleContainerInput(c.containerId, fromId, 0, ContainerInput.PICKUP, mc.player); + + for (int i = 0; i < amount; i++) { + if (mc.player.containerMenu.getCarried().isEmpty()) break; + mc.gameMode.handleContainerInput(c.containerId, 1, 1, ContainerInput.PICKUP, mc.player); + } + + if (!mc.player.containerMenu.getCarried().isEmpty()) { + mc.gameMode.handleContainerInput(c.containerId, fromId, 0, ContainerInput.PICKUP, mc.player); + } + + c.slots.get(1).getItem().isEmpty(); } private void takeResults(AbstractFurnaceMenu c) {