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);
}
}
}
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);
}
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);
}
}
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]);
}
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!");
}
Aggregations