Search in sources :

Example 6 with Setting

use of me.earth.earthhack.api.setting.Setting in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method stack.

private boolean stack() {
    ItemStack drag = mc.player.inventory.getItemStack();
    if (drag.isEmpty()) {
        Map<Item, SettingMap> pref = new HashMap<>();
        Map<Item, Map<Integer, Integer>> corresponding = new HashMap<>();
        for (int i = 44; i > 8; i--) {
            ItemStack stack = InventoryUtil.get(i);
            if (stack.isEmpty()) {
                continue;
            }
            Item item = stack.getItem();
            Map<Integer, Integer> corr = corresponding.get(item);
            if (corr != null) {
                if (stack.getCount() >= stack.getMaxStackSize() || corr.containsKey(stack.getCount())) {
                    continue;
                }
                corr.put(i, stack.getCount());
            } else {
                SettingMap map = pref.get(item);
                if (map == null) {
                    Setting<Integer> setting = getSetting(stack);
                    if (setting == null) {
                        corr = new HashMap<>();
                        if (stack.getCount() != stack.getMaxStackSize()) {
                            corr.put(i, stack.getCount());
                        }
                        corresponding.put(item, corr);
                        continue;
                    }
                    map = new SettingMap(setting, new HashMap<>());
                    pref.put(stack.getItem(), map);
                }
                map.getMap().put(i, stack.getCount());
            }
        }
        Map<Integer, Map.Entry<Integer, Integer>> best = new TreeMap<>();
        for (Map.Entry<Item, SettingMap> entry : pref.entrySet()) {
            SettingMap map = entry.getValue();
            if (map.getMap().size() < 2 || map.getSetting().getValue() == 0) {
                continue;
            }
            ItemStack deprec = new ItemStack(entry.getKey());
            int max = map.getSetting().getValue() * deprec.getMaxStackSize();
            int s = 0;
            int total = 0;
            int fullStacks = 0;
            for (int stackCount : map.getMap().values()) {
                if (stackCount == deprec.getMaxStackSize()) {
                    fullStacks++;
                }
                total += stackCount;
                s++;
            }
            boolean smart = module.smartStack.getValue();
            if (total > max && !smart || fullStacks >= map.getSetting().getValue()) {
                continue;
            }
            int m = map.getSetting().getValue();
            Map<Integer, Integer> sMap = CollectionUtil.sortByValue(map.getMap());
            if (findBest(sMap, entry.getKey(), best, smart, s, m)) {
                return true;
            }
        }
        Map.Entry<Integer, Integer> b = best.values().stream().findFirst().orElse(null);
        if (b != null) {
            click(b.getValue(), b.getKey());
            return true;
        }
        for (Map.Entry<Item, Map<Integer, Integer>> entry : corresponding.entrySet()) {
            Map<Integer, Integer> map = entry.getValue();
            if (map.size() < 2) {
                continue;
            }
            Map<Integer, Integer> sort = CollectionUtil.sortByValue(map);
            if (findBest(sort, entry.getKey(), best, false, 0, 0)) {
                return true;
            }
        }
        b = best.values().stream().findFirst().orElse(null);
        if (b != null) {
            click(b.getValue(), b.getKey());
            return true;
        }
    } else if (module.stackDrag.getValue()) {
        Setting<Integer> setting = getSetting(drag);
        if (setting != null && setting.getValue() == 0) {
            return false;
        }
        for (int i = 44; i > 8; i--) {
            ItemStack stack = InventoryUtil.get(i);
            if (InventoryUtil.canStack(stack, drag) && stack.getCount() + drag.getCount() <= stack.getMaxStackSize()) {
                int finalI = i;
                Item item = stack.getItem();
                Locks.acquire(Locks.WINDOW_CLICK_LOCK, () -> {
                    if (InventoryUtil.get(finalI).getItem() == item) {
                        InventoryUtil.click(finalI);
                    }
                });
                module.timer.reset();
                return true;
            }
        }
    }
    return false;
}
Also used : HashMap(java.util.HashMap) Setting(me.earth.earthhack.api.setting.Setting) TreeMap(java.util.TreeMap) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap)

Example 7 with Setting

use of me.earth.earthhack.api.setting.Setting in project 3arthh4ck by 3arthqu4ke.

the class Suicide method onEnable.

@Override
protected void onEnable() {
    pos = null;
    placed.clear();
    if (ask.getValue()) {
        displaying = true;
        GuiScreen current = mc.currentScreen;
        mc.displayGuiScreen(new YesNoNonPausing((r, id) -> {
            mc.displayGuiScreen(current);
            if (r) {
                displaying = false;
            } else {
                this.disable();
            }
        }, TextColor.RED + "Do you want to kill yourself? (recommended)", "If you don't want to get asked again," + " turn off the \"Ask\" Setting.", 1337));
        return;
    }
    displaying = false;
    if (mode.getValue() == SuicideMode.Command) {
        NetworkUtil.sendPacketNoEvent(new CPacketChatMessage("/kill"));
        this.disable();
    }
}
Also used : Entity(net.minecraft.entity.Entity) TextColor(me.earth.earthhack.impl.util.text.TextColor) DisablingModule(me.earth.earthhack.impl.util.helpers.disabling.DisablingModule) BooleanSetting(me.earth.earthhack.api.setting.settings.BooleanSetting) StopWatch(me.earth.earthhack.impl.util.math.StopWatch) Set(java.util.Set) Setting(me.earth.earthhack.api.setting.Setting) BlockPos(net.minecraft.util.math.BlockPos) NumberSetting(me.earth.earthhack.api.setting.settings.NumberSetting) YesNoNonPausing(me.earth.earthhack.impl.commands.gui.YesNoNonPausing) Sets(com.google.common.collect.Sets) NetworkUtil(me.earth.earthhack.impl.util.network.NetworkUtil) RayTraceResult(net.minecraft.util.math.RayTraceResult) GuiScreen(net.minecraft.client.gui.GuiScreen) SimpleData(me.earth.earthhack.impl.util.client.SimpleData) Category(me.earth.earthhack.api.module.util.Category) EnumSetting(me.earth.earthhack.api.setting.settings.EnumSetting) CPacketChatMessage(net.minecraft.network.play.client.CPacketChatMessage) YesNoNonPausing(me.earth.earthhack.impl.commands.gui.YesNoNonPausing) CPacketChatMessage(net.minecraft.network.play.client.CPacketChatMessage) GuiScreen(net.minecraft.client.gui.GuiScreen)

Example 8 with Setting

use of me.earth.earthhack.api.setting.Setting in project 3arthh4ck by 3arthqu4ke.

the class ResetCommand method execute.

@Override
public void execute(String[] args) {
    if (args.length < 2) {
        ChatUtil.sendMessage("Use this command to reset Modules and Settings.");
        return;
    }
    Module module = Managers.MODULES.getObject(args[1]);
    if (module == null) {
        ChatUtil.sendMessage(TextColor.RED + "Module " + TextColor.WHITE + args[1] + TextColor.RED + " not found!");
        return;
    }
    if (args.length == 2) {
        Scheduler.getInstance().schedule(() -> {
            GuiScreen previous = mc.currentScreen;
            mc.displayGuiScreen(new YesNoNonPausing((result, id) -> {
                mc.displayGuiScreen(previous);
                if (!result) {
                    return;
                }
                for (Setting<?> setting : module.getSettings()) {
                    setting.reset();
                }
                ChatUtil.sendMessage(TextColor.GREEN + "Module " + TextColor.WHITE + module.getName() + TextColor.GREEN + " has been reset.");
            }, "Do you really want to reset the Module " + module.getName() + "?", "", 1337));
        });
    } else {
        List<Setting<?>> settings = new ArrayList<>(args.length - 2);
        for (int i = 2; i < args.length; i++) {
            Setting<?> setting = module.getSetting(args[i]);
            if (setting != null) {
                settings.add(setting);
            } else {
                ChatUtil.sendMessage(TextColor.RED + "Could not find Setting " + TextColor.WHITE + args[i] + TextColor.RED + " in module " + TextColor.WHITE + module.getName() + TextColor.RED + ".");
            }
        }
        if (settings.isEmpty()) {
            return;
        }
        StringBuilder settingString = new StringBuilder(TextColor.RED);
        settingString.append("Do you really want to reset the Setting");
        if (settings.size() > 1) {
            settingString.append("s ");
        } else {
            settingString.append(" ");
        }
        settingString.append(TextColor.WHITE);
        Iterator<Setting<?>> itr = settings.iterator();
        while (itr.hasNext()) {
            Setting<?> s = itr.next();
            settingString.append(s.getName());
            if (itr.hasNext()) {
                settingString.append(TextColor.RED).append(", ").append(TextColor.WHITE);
            }
        }
        settingString.append(TextColor.RED).append(" in the module ").append(TextColor.WHITE).append(module.getName()).append(TextColor.RED).append("?");
        Scheduler.getInstance().schedule(() -> {
            GuiScreen previous = mc.currentScreen;
            mc.displayGuiScreen(new YesNoNonPausing((result, id) -> {
                mc.displayGuiScreen(previous);
                if (!result) {
                    return;
                }
                for (Setting<?> setting : settings) {
                    setting.reset();
                    ChatUtil.sendMessage(TextColor.RED + "Reset " + module.getName() + TextColor.RED + " - " + TextColor.WHITE + setting.getName() + TextColor.RED + ".");
                }
            }, settingString.toString(), "", 1337));
        });
    }
}
Also used : PossibleInputs(me.earth.earthhack.api.command.PossibleInputs) Globals(me.earth.earthhack.api.util.interfaces.Globals) Scheduler(me.earth.earthhack.impl.managers.thread.scheduler.Scheduler) TextColor(me.earth.earthhack.impl.util.text.TextColor) ChatUtil(me.earth.earthhack.impl.util.text.ChatUtil) Iterator(java.util.Iterator) Managers(me.earth.earthhack.impl.managers.Managers) AbstractModuleCommand(me.earth.earthhack.impl.commands.abstracts.AbstractModuleCommand) CommandDescriptions(me.earth.earthhack.impl.commands.util.CommandDescriptions) Module(me.earth.earthhack.api.module.Module) Setting(me.earth.earthhack.api.setting.Setting) YesNoNonPausing(me.earth.earthhack.impl.commands.gui.YesNoNonPausing) CommandUtil(me.earth.earthhack.impl.commands.util.CommandUtil) ArrayList(java.util.ArrayList) GuiScreen(net.minecraft.client.gui.GuiScreen) List(java.util.List) TextUtil(me.earth.earthhack.api.util.TextUtil) YesNoNonPausing(me.earth.earthhack.impl.commands.gui.YesNoNonPausing) Setting(me.earth.earthhack.api.setting.Setting) ArrayList(java.util.ArrayList) GuiScreen(net.minecraft.client.gui.GuiScreen) Module(me.earth.earthhack.api.module.Module)

Example 9 with Setting

use of me.earth.earthhack.api.setting.Setting in project 3arthh4ck by 3arthqu4ke.

the class ModuleCommand method onTabComplete.

@Override
public Completer onTabComplete(Completer completer) {
    String[] args = completer.getArgs();
    if (args.length > 0) {
        Module module = getModule(args[0]);
        if (module instanceof CustomCommandModule) {
            switch(((CustomCommandModule) module).complete(completer)) {
                case RETURN:
                    return completer;
                case SUPER:
                    return super.onTabComplete(completer);
                default:
            }
        }
    }
    if (completer.isSame()) {
        Module module = getModule(args[0]);
        if (module == null) {
            return super.onTabComplete(completer);
        }
        if (args.length == 1) {
            return completer;
        } else if (args.length == 2) {
            Optional<Setting<?>> first = module.getSettings().stream().findFirst();
            if (!first.isPresent()) {
                return completer;
            }
            if (module instanceof CustomCommandModule) {
                String[] custom = ((CustomCommandModule) module).getArgs();
                if (custom != null && custom.length > 0) {
                    boolean found = false;
                    for (String s : custom) {
                        if (found) {
                            completer.setResult(Commands.getPrefix() + args[0] + " " + s);
                            return completer;
                        }
                        if (args[1].equalsIgnoreCase(s)) {
                            found = true;
                        }
                    }
                }
            }
            Setting<?> setting = module.getSetting(args[1]);
            if (setting == null) {
                completer.setResult(Commands.getPrefix() + args[0] + " " + getEscapedName(first.get().getName()));
                return completer;
            }
            boolean found = false;
            for (Setting<?> s : module.getSettings()) {
                if (found) {
                    completer.setResult(Commands.getPrefix() + args[0] + " " + getEscapedName(s.getName()));
                    return completer;
                }
                if (s.equals(setting)) {
                    found = true;
                }
            }
            if (module instanceof CustomCommandModule) {
                String[] custom = ((CustomCommandModule) module).getArgs();
                if (custom != null && custom.length > 0) {
                    completer.setResult(Commands.getPrefix() + args[0] + " " + custom[0]);
                    return completer;
                }
            }
            completer.setResult(Commands.getPrefix() + args[0] + " " + getEscapedName(first.get().getName()));
        } else {
            if (module instanceof CustomCommandModule) {
                String[] custom = ((CustomCommandModule) module).getArgs();
                if (custom != null && custom.length > 0) {
                    for (String s : custom) {
                        if (args[1].equalsIgnoreCase(s)) {
                            return completer;
                        }
                    }
                }
            }
            Setting<?> setting = module.getSetting(args[2]);
            if (setting != null) {
                completer.setResult(Commands.getPrefix() + args[0] + " " + Completer.nextValueInSetting(setting, args[args.length - 1]));
            }
        }
        return completer;
    }
    if (args.length == 2) {
        Module module = getModule(args[0]);
        if (module == null) {
            return completer;
        }
        Setting<?> setting = CommandUtil.getNameableStartingWith(args[1], module.getSettings());
        if (setting == null) {
            return completer;
        }
        return completer.setResult(Commands.getPrefix() + args[0] + " " + getEscapedName(setting.getName()));
    }
    return super.onTabComplete(completer);
}
Also used : CustomCommandModule(me.earth.earthhack.impl.util.helpers.command.CustomCommandModule) Optional(java.util.Optional) Setting(me.earth.earthhack.api.setting.Setting) Module(me.earth.earthhack.api.module.Module) CustomCommandModule(me.earth.earthhack.impl.util.helpers.command.CustomCommandModule)

Example 10 with Setting

use of me.earth.earthhack.api.setting.Setting in project 3arthh4ck by 3arthqu4ke.

the class ListenerTick method doSingleMend.

@SuppressWarnings("unchecked")
private void doSingleMend(ItemStack dragIn, int mendBlock) {
    boolean allBlocked = true;
    for (SingleMendingSlot singleMendingSlot : module.singleMendingSlots) {
        allBlocked = allBlocked && singleMendingSlot.isBlocked();
    }
    if (allBlocked) {
        module.unblockMendingSlots();
    }
    List<DamageStack> stacks = new ArrayList<>(4);
    for (int i = 5; i < 9; i++) {
        ItemStack stack = mc.player.inventoryContainer.getSlot(i).getStack();
        if (EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, stack) != 0) {
            float percent = DamageUtil.getPercent(stack);
            stacks.add(new DamageStack(stack, percent, i));
        }
    }
    // Most damaged will be first, all others will be taken off.
    stacks.sort(Comparator.reverseOrder());
    if (stacks.size() <= 0) {
        int bestSlot = -1;
        MutableWrapper<Float> lowest = new MutableWrapper<>(Float.MAX_VALUE);
        MutableWrapper<ItemStack> bestStack = new MutableWrapper<>(ItemStack.EMPTY);
        for (SingleMendingSlot singleMendingSlot : module.singleMendingSlots) {
            if (!singleMendingSlot.isBlocked()) {
                int slot = AutoArmor.iterateItems(XCARRY.isEnabled(), module.queuedSlots, stack -> {
                    if (AutoArmor.getSlot(stack) == singleMendingSlot.getSlot()) {
                        float percent = DamageUtil.getPercent(stack);
                        if (percent < lowest.get()) {
                            bestStack.set(stack);
                            lowest.set(percent);
                            return true;
                        }
                    }
                    return false;
                });
                bestSlot = slot == -1 ? bestSlot : slot;
            }
        }
        if (bestSlot != -1) {
            EntityEquipmentSlot equipmentSlot = AutoArmor.getSlot(bestStack.get());
            if (equipmentSlot != null) {
                int slot = AutoArmor.fromEquipment(equipmentSlot);
                if (bestSlot != -2) {
                    module.queueClick(bestSlot, bestStack.get(), dragIn, slot).setDoubleClick(module.doubleClicks.getValue());
                }
                module.queueClick(slot, InventoryUtil.get(slot), bestStack.get());
            }
        } else if (!allBlocked) {
            module.unblockMendingSlots();
        }
    } else if (stacks.size() == 1) {
        DamageStack stack = stacks.get(0);
        SingleMendingSlot mendingSlot = Arrays.stream(module.singleMendingSlots).filter(s -> s.getSlot() == AutoArmor.getSlot(stack.getStack())).findFirst().orElse(null);
        if (mendingSlot != null && stack.getDamage() > ((Setting<Integer>) module.damages[stack.getSlot() - 5]).getValue()) {
            MutableWrapper<ItemStack> drag = new MutableWrapper<>(dragIn);
            checkDamageStack(stack, mendBlock, drag);
            mendingSlot.setBlocked(true);
        }
    } else {
        MutableWrapper<ItemStack> drag = new MutableWrapper<>(dragIn);
        boolean skipFirst = true;
        for (DamageStack stack : stacks) {
            if (skipFirst) {
                skipFirst = false;
                continue;
            }
            if (checkDamageStack(stack, mendBlock, drag)) {
                return;
            }
        }
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) SingleMendingSlot(me.earth.earthhack.impl.modules.combat.autoarmor.util.SingleMendingSlot) XCarry(me.earth.earthhack.impl.modules.player.xcarry.XCarry) TextColor(me.earth.earthhack.impl.util.text.TextColor) java.util(java.util) Items(net.minecraft.init.Items) Item(net.minecraft.item.Item) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) Setting(me.earth.earthhack.api.setting.Setting) TickEvent(me.earth.earthhack.impl.event.events.misc.TickEvent) Enchantments(net.minecraft.init.Enchantments) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) DamageUtil(me.earth.earthhack.impl.util.minecraft.DamageUtil) MendingStage(me.earth.earthhack.impl.modules.player.noinventorydesync.MendingStage) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) ItemStack(net.minecraft.item.ItemStack) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ModuleUtil(me.earth.earthhack.impl.util.client.ModuleUtil) MutableWrapper(me.earth.earthhack.impl.util.misc.MutableWrapper) DamageStack(me.earth.earthhack.impl.modules.combat.autoarmor.util.DamageStack) ItemArmor(net.minecraft.item.ItemArmor) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) MutableWrapper(me.earth.earthhack.impl.util.misc.MutableWrapper) DamageStack(me.earth.earthhack.impl.modules.combat.autoarmor.util.DamageStack) SingleMendingSlot(me.earth.earthhack.impl.modules.combat.autoarmor.util.SingleMendingSlot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Setting (me.earth.earthhack.api.setting.Setting)10 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Item (net.minecraft.item.Item)5 ItemStack (net.minecraft.item.ItemStack)5 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)4 InventoryUtil (me.earth.earthhack.impl.util.minecraft.InventoryUtil)4 Items (net.minecraft.init.Items)4 AbstractMap (java.util.AbstractMap)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Set (java.util.Set)3 TreeMap (java.util.TreeMap)3 ModuleCache (me.earth.earthhack.api.cache.ModuleCache)3 Module (me.earth.earthhack.api.module.Module)3 Managers (me.earth.earthhack.impl.managers.Managers)3 Caches (me.earth.earthhack.impl.modules.Caches)3 TextColor (me.earth.earthhack.impl.util.text.TextColor)3 EntityItem (net.minecraft.entity.item.EntityItem)3 ClickType (net.minecraft.inventory.ClickType)3