auto crafting, closes #24
This commit is contained in:
@@ -43,6 +43,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
||||
modules.add(new AntiVanish());
|
||||
modules.add(new Auto32K());
|
||||
modules.add(new AutoBedTrap());
|
||||
modules.add(new AutoCraft());
|
||||
modules.add(new AutoExtinguish());
|
||||
modules.add(new AutoEz());
|
||||
modules.add(new AutoHighway());
|
||||
|
||||
@@ -20,14 +20,10 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.system.CallbackI.B;
|
||||
import org.lwjgl.system.CallbackI.P;
|
||||
|
||||
import net.minecraft.block.BedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class AutoBedTrap extends Module {
|
||||
|
||||
67
src/main/java/cloudburst/rejects/modules/AutoCraft.java
Normal file
67
src/main/java/cloudburst/rejects/modules/AutoCraft.java
Normal file
@@ -0,0 +1,67 @@
|
||||
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 meteordevelopment.meteorclient.events.world.TickEvent;
|
||||
import meteordevelopment.meteorclient.settings.BoolSetting;
|
||||
import meteordevelopment.meteorclient.settings.ItemListSetting;
|
||||
import meteordevelopment.meteorclient.settings.Setting;
|
||||
import meteordevelopment.meteorclient.settings.SettingGroup;
|
||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
|
||||
public class AutoCraft extends Module {
|
||||
|
||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||
|
||||
private final Setting<List<Item>> items = sgGeneral.add(new ItemListSetting.Builder()
|
||||
.name("items")
|
||||
.description("Items you want to get crafted.")
|
||||
.defaultValue(Arrays.asList())
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> antiDesync = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("anti-desync")
|
||||
.description("Try to prevent inventory desync.")
|
||||
.defaultValue(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
public AutoCraft() {
|
||||
super(MeteorRejectsAddon.CATEGORY, "auto-craft", "Automatically crafts items.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onTick(TickEvent.Post event) {
|
||||
if (mc.interactionManager == null) return;
|
||||
if (items.get().isEmpty()) return;
|
||||
|
||||
if (!(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) return;
|
||||
|
||||
|
||||
if (antiDesync.get())
|
||||
mc.player.getInventory().updateItems();
|
||||
|
||||
// Danke schön GhostTypes
|
||||
// https://github.com/GhostTypes/orion/blob/main/src/main/java/me/ghosttypes/orion/modules/main/AutoBedCraft.java
|
||||
CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
|
||||
List<Item> itemList = items.get();
|
||||
List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults();
|
||||
for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
|
||||
for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
|
||||
if (!itemList.contains(recipe.getOutput().getItem())) continue;
|
||||
mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
|
||||
mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 1, SlotActionType.QUICK_MOVE, mc.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user