Search in sources :

Example 1 with Module

use of org.bleachhack.module.Module in project BleachHack by BleachDrinker420.

the class ToggleNotify method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    for (int i = 0; i < enabledModules.size(); i++) {
        Module m = enabledModules.get(i);
        if (!m.isEnabled()) {
            if (!(m instanceof ClickGui) && getSetting(1).asToggle().getState())
                notify(m);
            enabledModules.remove(m);
            i--;
        }
    }
    for (Module m : ModuleManager.getModules()) {
        if (m.isEnabled() && !enabledModules.contains(m)) {
            if (!(m instanceof ClickGui) && getSetting(0).asToggle().getState())
                notify(m);
            enabledModules.add(m);
        }
    }
}
Also used : Module(org.bleachhack.module.Module) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with Module

use of org.bleachhack.module.Module in project BleachHack by BleachDrinker420.

the class BleachFileHelper method saveModules.

public static void saveModules() {
    JsonObject json = new JsonObject();
    for (Module mod : ModuleManager.getModules()) {
        JsonObject modjson = new JsonObject();
        if (mod.isEnabled() != mod.isDefaultEnabled() && !mod.getName().equals("ClickGui") && !mod.getName().equals("Freecam")) {
            modjson.add("toggled", new JsonPrimitive(mod.isEnabled()));
        }
        JsonObject setjson = new JsonObject();
        Map<String, ModuleSetting<?>> settingMap = getSettingMap(mod.getSettings());
        for (Entry<String, ModuleSetting<?>> s : settingMap.entrySet()) {
            if (!s.getValue().isDefault())
                setjson.add(s.getKey(), s.getValue().write());
        }
        if (setjson.size() != 0)
            modjson.add("settings", setjson);
        if (modjson.size() != 0)
            json.add(mod.getName(), modjson);
    }
    BleachJsonHelper.setJsonFile("modules.json", json);
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) ModuleSetting(org.bleachhack.setting.module.ModuleSetting) JsonObject(com.google.gson.JsonObject) Module(org.bleachhack.module.Module)

Example 3 with Module

use of org.bleachhack.module.Module in project BleachHack by BleachDrinker420.

the class MixinPlayerEntity method getBlockBreakingSpeed.

@Inject(method = "getBlockBreakingSpeed", at = @At("HEAD"), cancellable = true)
private void getBlockBreakingSpeed(BlockState block, CallbackInfoReturnable<Float> ci) {
    Module speedMine = ModuleManager.getModule(SpeedMine.class);
    if (speedMine.isEnabled()) {
        float breakingSpeed = inventory.getBlockBreakingSpeed(block);
        if (breakingSpeed > 1.0F) {
            int eff = EnchantmentHelper.getEfficiency(this);
            ItemStack itemStack_1 = this.getMainHandStack();
            if (eff > 0 && !itemStack_1.isEmpty()) {
                breakingSpeed += eff * eff + 1;
            }
        }
        if (StatusEffectUtil.hasHaste(this)) {
            breakingSpeed *= 1.0F + (StatusEffectUtil.getHasteAmplifier(this) + 1) * 0.2F;
        }
        if (!speedMine.getSetting(4).asToggle().getState()) {
            if (this.hasStatusEffect(StatusEffects.MINING_FATIGUE)) {
                float fatigueMult;
                switch(this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier()) {
                    case 0:
                        fatigueMult = 0.3F;
                        break;
                    case 1:
                        fatigueMult = 0.09F;
                        break;
                    case 2:
                        fatigueMult = 0.0027F;
                        break;
                    case 3:
                    default:
                        fatigueMult = 8.1E-4F;
                }
                breakingSpeed *= fatigueMult;
            }
        }
        if (!speedMine.getSetting(5).asToggle().getState()) {
            if (this.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(this)) {
                breakingSpeed /= 5.0F;
            }
            if (!this.onGround) {
                breakingSpeed /= 5.0F;
            }
        }
        if (speedMine.getSetting(0).asMode().getMode() == 1)
            breakingSpeed *= speedMine.getSetting(3).asSlider().getValueFloat();
        ci.setReturnValue(breakingSpeed);
    }
}
Also used : Module(org.bleachhack.module.Module) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with Module

use of org.bleachhack.module.Module in project BleachHack by BleachDrinker420.

the class CmdSetting method onCommand.

@Override
@SuppressWarnings("unchecked")
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length < 2) {
        throw new CmdSyntaxException();
    }
    Module module = ModuleManager.getModule(args[0]);
    ModuleSetting<?> setting = module.getSettings().stream().filter(s -> s.getName().equals(args[1])).findFirst().get();
    if (setting == null)
        throw new CmdSyntaxException("Invalid setting \"" + args[1] + "\"");
    Object value = setting.getValue();
    if (value instanceof Double) {
        ((ModuleSetting<Double>) setting).setValue(Double.parseDouble(args[2]));
    } else if (value instanceof Integer) {
        ((ModuleSetting<Integer>) setting).setValue(Integer.parseInt(args[2]));
    } else if (value instanceof String) {
        ((ModuleSetting<String>) setting).setValue(args[2]);
    } else {
        BleachLogger.error("Setting \"" + setting.getClass().getSimpleName() + "\" is not supported!");
        return;
    }
    BleachLogger.info("Set " + args[1] + " in " + module.getName() + " to " + args[2]);
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ModuleSetting(org.bleachhack.setting.module.ModuleSetting) Module(org.bleachhack.module.Module)

Example 5 with Module

use of org.bleachhack.module.Module in project BleachHack by BleachDrinker420.

the class CmdToggle method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length != 1) {
        throw new CmdSyntaxException();
    }
    for (Module m : ModuleManager.getModules()) {
        if (args[0].equalsIgnoreCase(m.getName())) {
            BleachQueue.add(m::toggle);
            BleachLogger.info(m.getName() + " Toggled");
            return;
        }
    }
    BleachLogger.error("Module \"" + args[0] + "\" Not Found!");
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Module(org.bleachhack.module.Module)

Aggregations

Module (org.bleachhack.module.Module)8 CmdSyntaxException (org.bleachhack.command.exception.CmdSyntaxException)3 ModuleSetting (org.bleachhack.setting.module.ModuleSetting)2 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 HashSet (java.util.HashSet)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 ItemStack (net.minecraft.item.ItemStack)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1 ClickGuiWindow (org.bleachhack.gui.clickgui.window.ClickGuiWindow)1 ModuleWindow (org.bleachhack.gui.clickgui.window.ModuleWindow)1 Window (org.bleachhack.gui.window.Window)1 ClickGui (org.bleachhack.module.mods.ClickGui)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1