Skip to content
Open
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
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -34,6 +36,15 @@ public class AutoSmelter extends Module {
.build()
);

private final Setting<Integer> 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<List<Item>> smeltableItems = sgGeneral.add(new ItemListSetting.Builder()
.name("smeltable-items")
.description("Items to smelt")
Expand All @@ -50,6 +61,12 @@ public class AutoSmelter extends Module {
.build()
);

private final Setting<Boolean> 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");
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down