auto crafting, closes #24

This commit is contained in:
C10udburst
2021-08-27 13:08:46 +02:00
parent b38af10345
commit ef207bdf66
4 changed files with 69 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ An addon to Meteor Client that adds modules and commands that were too useless t
- AntiVanish - AntiVanish
- Auto32K (Removed from Meteor in [67f93](https://github.com/MeteorDevelopment/meteor-client/commit/67f93de1e5e287ea62ddef041441306f01249c3d#diff-95d3e3b18ffadf76eef2358f30d424843d57acf8bde5ebd49a3f6befa6ff0529)) - Auto32K (Removed from Meteor in [67f93](https://github.com/MeteorDevelopment/meteor-client/commit/67f93de1e5e287ea62ddef041441306f01249c3d#diff-95d3e3b18ffadf76eef2358f30d424843d57acf8bde5ebd49a3f6befa6ff0529))
- AutoBedTrap (Ported from [BleachHack-CupEdition](https://github.com/CUPZYY/BleachHack-CupEdition/blob/master/CupEdition-1.17/src/main/java/bleach/hack/module/mods/AutoBedtrap.java)) - AutoBedTrap (Ported from [BleachHack-CupEdition](https://github.com/CUPZYY/BleachHack-CupEdition/blob/master/CupEdition-1.17/src/main/java/bleach/hack/module/mods/AutoBedtrap.java))
- AutoCraft (More generalized version of [AutoBedCraft](https://github.com/GhostTypes/orion/blob/main/src/main/java/me/ghosttypes/orion/modules/main/AutoBedCraft.java) from orion)
- AutoExtinguish - AutoExtinguish
- AutoEz - AutoEz
- AutoHighway (Taken from [Meteor AutoHighway Addon](https://github.com/VoidCyborg/meteor-auto-highway-addon)) - AutoHighway (Taken from [Meteor AutoHighway Addon](https://github.com/VoidCyborg/meteor-auto-highway-addon))

View File

@@ -43,6 +43,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
modules.add(new AntiVanish()); modules.add(new AntiVanish());
modules.add(new Auto32K()); modules.add(new Auto32K());
modules.add(new AutoBedTrap()); modules.add(new AutoBedTrap());
modules.add(new AutoCraft());
modules.add(new AutoExtinguish()); modules.add(new AutoExtinguish());
modules.add(new AutoEz()); modules.add(new AutoEz());
modules.add(new AutoHighway()); modules.add(new AutoHighway());

View File

@@ -20,14 +20,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; 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.BedBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Items;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
public class AutoBedTrap extends Module { public class AutoBedTrap extends Module {

View 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);
}
}
}
}