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);
}
}
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);
}
}
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();
}
}
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;
}
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;
}
Aggregations