Search in sources :

Example 1 with Setting

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

the class HudValuePreset method apply.

@Override
public void apply() {
    HudElement module = this.getModule();
    Set<Setting<?>> generated = GeneratedSettings.getGenerated(module);
    for (Setting<?> setting : generated) {
        module.unregister(setting);
    }
    GeneratedSettings.clear(module);
    Map.Entry<String, JsonElement> enabled = null;
    for (Map.Entry<String, JsonElement> entry : values.entrySet()) {
        if (entry.getKey().equalsIgnoreCase("Enabled")) {
            enabled = entry;
            continue;
        }
        setSetting(module, entry);
    }
    // set enabled last, so all settings are to date when we enter onEnable.
    if (enabled != null) {
        setSetting(module, enabled);
    }
}
Also used : JsonElement(com.google.gson.JsonElement) BindSetting(me.earth.earthhack.api.setting.settings.BindSetting) Setting(me.earth.earthhack.api.setting.Setting) HudElement(me.earth.earthhack.api.hud.HudElement) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with Setting

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

the class ValuePreset method apply.

@Override
public void apply() {
    Module module = this.getModule();
    Set<Setting<?>> generated = GeneratedSettings.getGenerated(module);
    for (Setting<?> setting : generated) {
        module.unregister(setting);
    }
    GeneratedSettings.clear(module);
    Map.Entry<String, JsonElement> enabled = null;
    for (Map.Entry<String, JsonElement> entry : values.entrySet()) {
        if (entry.getKey().equalsIgnoreCase("Enabled")) {
            enabled = entry;
            continue;
        }
        setSetting(module, entry);
    }
    // set enabled last, so all settings are to date when we enter onEnable.
    if (enabled != null) {
        setSetting(module, enabled);
    }
}
Also used : JsonElement(com.google.gson.JsonElement) BindSetting(me.earth.earthhack.api.setting.settings.BindSetting) Setting(me.earth.earthhack.api.setting.Setting) Module(me.earth.earthhack.api.module.Module) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with Setting

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

the class ListenerTick method invoke.

@Override
public void invoke(TickEvent event) {
    if (mc.currentScreen instanceof GuiShulkerBox) {
        for (int i = 0; i < 36; i++) {
            if (module.delayTimer.passed(module.delay.getValue())) {
                Setting<?> setting = module.getSettingFromSlot(i);
                if (setting == null)
                    continue;
                int itemId = Integer.parseInt(setting.getName().split(":")[1]);
                if (itemId == 0)
                    continue;
                Item item = Item.getItemById(itemId);
                int shulkerSlot = InventoryUtil.findItem(item, ((GuiShulkerBox) mc.currentScreen).inventorySlots);
                ItemStack stackInSlot = ((GuiContainer) mc.currentScreen).inventorySlots.getInventory().get(i + 27);
                if (stackInSlot.getMaxStackSize() == 1 || stackInSlot.getMaxStackSize() == stackInSlot.getCount() || stackInSlot.getItem() != item && stackInSlot.getItem() != Items.AIR || shulkerSlot == -1 || shulkerSlot > 26)
                    continue;
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, shulkerSlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, i + 27, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, shulkerSlot, 0, ClickType.PICKUP, mc.player);
                module.delayTimer.reset();
            }
        }
    } else if (mc.currentScreen instanceof GuiChest && module.shouldRegear && module.grabShulker.getValue() && !module.hasKit()) {
        int slot = -1;
        // TODO: improve method of finding kits in chests
        for (int i = 0; i < 28; i++) {
            boolean foundExp = false;
            boolean foundCrystals = false;
            boolean foundGapples = false;
            ItemStack stack = ((GuiContainer) mc.currentScreen).inventorySlots.getInventory().get(i);
            if (stack.getItem() instanceof ItemShulkerBox) {
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound != null && tagCompound.hasKey("BlockEntityTag", 10)) {
                    NBTTagCompound blockEntityTag = tagCompound.getCompoundTag("BlockEntityTag");
                    if (blockEntityTag.hasKey("Items", 9)) {
                        NonNullList<ItemStack> nonNullList = NonNullList.withSize(27, ItemStack.EMPTY);
                        ItemStackHelper.loadAllItems(blockEntityTag, nonNullList);
                        for (ItemStack stack1 : nonNullList) {
                            if (stack1.getItem() == Items.GOLDEN_APPLE) {
                                foundGapples = true;
                            } else if (stack1.getItem() == Items.EXPERIENCE_BOTTLE) {
                                foundExp = true;
                            } else if (stack1.getItem() == Items.END_CRYSTAL) {
                                foundCrystals = true;
                            }
                        }
                        if (foundExp && foundGapples && foundCrystals) {
                            slot = i;
                        } else {
                            if (!module.hasKit() && module.getShulkerBox() == null) {
                                module.shouldRegear = false;
                                mc.player.closeScreen();
                                return;
                            }
                        }
                    }
                }
            }
        }
        if (slot != -1) {
            int emptySlot = InventoryUtil.findInInventory(stack -> stack.isEmpty() || stack.getItem() == Items.AIR, false);
            if (emptySlot != -1) {
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, slot, 0, ClickType.QUICK_MOVE, mc.player);
            }
        }
        mc.player.closeScreen();
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) InventoryEnderChest(net.minecraft.inventory.InventoryEnderChest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SimpleRemovingSetting(me.earth.earthhack.impl.util.helpers.addable.setting.SimpleRemovingSetting) Items(net.minecraft.init.Items) Item(net.minecraft.item.Item) Setting(me.earth.earthhack.api.setting.Setting) TickEvent(me.earth.earthhack.impl.event.events.misc.TickEvent) BlockEnderChest(net.minecraft.block.BlockEnderChest) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox) ItemStack(net.minecraft.item.ItemStack) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ItemStackHelper(net.minecraft.inventory.ItemStackHelper) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) NonNullList(net.minecraft.util.NonNullList) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) ClickType(net.minecraft.inventory.ClickType) Item(net.minecraft.item.Item) NonNullList(net.minecraft.util.NonNullList) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox) ItemStack(net.minecraft.item.ItemStack) GuiChest(net.minecraft.client.gui.inventory.GuiChest)

Example 4 with Setting

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

the class ListenerMotion method doXCarry.

private boolean doXCarry() {
    int xCarry = getEmptyXCarry();
    ItemStack drag = mc.player.inventory.getItemStack();
    if (xCarry == -1 || !drag.isEmpty() && !module.dragCarry.getValue() || getSetting(drag) != null) {
        return false;
    }
    int stacks = 0;
    Set<Item> invalid = new HashSet<>();
    Map<Item, List<SlotCount>> slots = new HashMap<>();
    for (int i = 44; i > 8; i--) {
        ItemStack stack = InventoryUtil.get(i);
        if (stack.isEmpty()) {
            continue;
        } else {
            stacks++;
        }
        if (invalid.contains(stack.getItem())) {
            continue;
        }
        Setting<Integer> setting = getSetting(stack);
        if (setting == null) {
            slots.computeIfAbsent(stack.getItem(), v -> new ArrayList<>()).add(new SlotCount(stack.getCount(), i));
        } else {
            invalid.add(stack.getItem());
        }
    }
    if (stacks < module.xCarryStacks.getValue()) {
        return false;
    }
    if (drag.isEmpty()) {
        int best = -1;
        int bestSize = 0;
        for (Map.Entry<Item, List<SlotCount>> entry : slots.entrySet()) {
            int size = entry.getValue().size();
            ItemStack deprec = new ItemStack(entry.getKey());
            if (size >= module.minXcarry.getValue() && size > bestSize) {
                for (SlotCount count : entry.getValue()) {
                    if (// no hotbar!
                    count.getSlot() < 36 && count.getCount() == deprec.getMaxStackSize()) {
                        best = count.getSlot();
                        bestSize = size;
                    }
                }
            }
        }
        if (best != -1) {
            click(best, xCarry);
            return true;
        }
    } else {
        List<SlotCount> counts = slots.get(drag.getItem());
        if (counts == null && module.minXcarry.getValue() == 0 || counts != null && counts.size() >= module.minXcarry.getValue()) {
            Item item = InventoryUtil.get(xCarry).getItem();
            Locks.acquire(Locks.WINDOW_CLICK_LOCK, () -> {
                if (InventoryUtil.get(xCarry).getItem() == item) {
                    InventoryUtil.click(xCarry);
                }
            });
            module.timer.reset();
            return true;
        }
    }
    return false;
}
Also used : WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick) Managers(me.earth.earthhack.impl.managers.Managers) Item(net.minecraft.item.Item) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) Setting(me.earth.earthhack.api.setting.Setting) HashMap(java.util.HashMap) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) Stage(me.earth.earthhack.api.event.events.Stage) Map(java.util.Map) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) AutoArmor(me.earth.earthhack.impl.modules.combat.autoarmor.AutoArmor) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) EntityItem(net.minecraft.entity.item.EntityItem) GuiInventory(net.minecraft.client.gui.inventory.GuiInventory) Items(net.minecraft.init.Items) CollectionUtil(me.earth.earthhack.impl.util.misc.collections.CollectionUtil) EnumFacing(net.minecraft.util.EnumFacing) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) AbstractMap(java.util.AbstractMap) List(java.util.List) TreeMap(java.util.TreeMap) MovementUtil(me.earth.earthhack.impl.util.minecraft.MovementUtil) ClickType(net.minecraft.inventory.ClickType) Locks(me.earth.earthhack.impl.util.thread.Locks) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Example 5 with Setting

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

the class ListenerMotion method check.

private boolean check(ItemStack stack, int i, Map<Item, ItemToDrop> items) {
    if (!stack.isEmpty() && !module.isStackValid(stack)) {
        Item item = stack.getItem();
        Setting<Integer> setting = module.getSetting(item.getItemStackDisplayName(stack), RemovingInteger.class);
        items.computeIfAbsent(item, v -> new ItemToDrop(setting)).addSlot(i, stack.getCount());
        return true;
    }
    return false;
}
Also used : WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick) Managers(me.earth.earthhack.impl.managers.Managers) Item(net.minecraft.item.Item) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) Setting(me.earth.earthhack.api.setting.Setting) HashMap(java.util.HashMap) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) Stage(me.earth.earthhack.api.event.events.Stage) Map(java.util.Map) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) AutoArmor(me.earth.earthhack.impl.modules.combat.autoarmor.AutoArmor) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) EntityItem(net.minecraft.entity.item.EntityItem) GuiInventory(net.minecraft.client.gui.inventory.GuiInventory) Items(net.minecraft.init.Items) CollectionUtil(me.earth.earthhack.impl.util.misc.collections.CollectionUtil) EnumFacing(net.minecraft.util.EnumFacing) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) AbstractMap(java.util.AbstractMap) List(java.util.List) TreeMap(java.util.TreeMap) MovementUtil(me.earth.earthhack.impl.util.minecraft.MovementUtil) ClickType(net.minecraft.inventory.ClickType) Locks(me.earth.earthhack.impl.util.thread.Locks) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem)

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