Added a craft all option

This commit is contained in:
Stormybytes
2021-09-07 20:38:10 +07:00
parent 269da8e051
commit 7a82b2dfda

View File

@@ -1,14 +1,5 @@
package cloudburst.rejects.modules; package cloudburst.rejects.modules;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.gui.screen.recipebook.RecipeResultCollection;
import net.minecraft.item.Item;
import net.minecraft.recipe.Recipe;
import net.minecraft.screen.CraftingScreenHandler;
import net.minecraft.screen.slot.SlotActionType;
import cloudburst.rejects.MeteorRejectsAddon; import cloudburst.rejects.MeteorRejectsAddon;
import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.BoolSetting;
@@ -17,6 +8,14 @@ import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventHandler;
import net.minecraft.client.gui.screen.recipebook.RecipeResultCollection;
import net.minecraft.item.Item;
import net.minecraft.recipe.Recipe;
import net.minecraft.screen.CraftingScreenHandler;
import net.minecraft.screen.slot.SlotActionType;
import java.util.Arrays;
import java.util.List;
public class AutoCraft extends Module { public class AutoCraft extends Module {
@@ -35,6 +34,13 @@ public class AutoCraft extends Module {
.defaultValue(false) .defaultValue(false)
.build() .build()
); );
private final Setting<Boolean> craftAll = sgGeneral.add(new BoolSetting.Builder()
.name("craft-all")
.description("Crafts maximum possible amount amount per craft (shift-clicking)")
.defaultValue(false)
.build()
);
public AutoCraft() { public AutoCraft() {
super(MeteorRejectsAddon.CATEGORY, "auto-craft", "Automatically crafts items."); super(MeteorRejectsAddon.CATEGORY, "auto-craft", "Automatically crafts items.");
@@ -57,9 +63,9 @@ public class AutoCraft extends Module {
List<Item> itemList = items.get(); List<Item> itemList = items.get();
List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults(); List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults();
for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) { for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) { for (Recipe<?> recipe : recipeResultCollection.getRecipes(false)) {
if (!itemList.contains(recipe.getOutput().getItem())) continue; if (!itemList.contains(recipe.getOutput().getItem())) continue;
mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false); mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, craftAll.get());
mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 1, SlotActionType.QUICK_MOVE, mc.player); mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 1, SlotActionType.QUICK_MOVE, mc.player);
} }
} }