Search in sources :

Example 1 with NavigatorMod

use of net.wurstclient.features.mods.other.NavigatorMod in project Wurst-MC-1.12 by Wurst-Imperium.

the class Mod method setBlocked.

public void setBlocked(boolean blocked) {
    this.blocked = blocked;
    active = enabled && !blocked;
    if (!(this instanceof NavigatorMod))
        UIRenderer.modList.updateState(this);
    if (enabled)
        try {
            onToggle();
            if (blocked)
                onDisable();
            else
                onEnable();
        } catch (Throwable e) {
            CrashReport report = CrashReport.makeCrashReport(e, "Toggling Wurst mod");
            CrashReportCategory category = report.makeCategory("Affected mod");
            category.setDetail("Mod name", () -> name);
            category.setDetail("Attempted action", () -> blocked ? "Block" : "Unblock");
            throw new ReportedException(report);
        }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) NavigatorMod(net.wurstclient.features.mods.other.NavigatorMod) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 2 with NavigatorMod

use of net.wurstclient.features.mods.other.NavigatorMod in project Wurst-MC-1.12 by Wurst-Imperium.

the class Mod method setEnabled.

public final void setEnabled(boolean enabled) {
    if (this.enabled == enabled)
        return;
    this.enabled = enabled;
    active = enabled && !blocked;
    if (!(this instanceof NavigatorMod))
        UIRenderer.modList.updateState(this);
    if (blocked && enabled)
        return;
    try {
        onToggle();
        if (enabled)
            onEnable();
        else
            onDisable();
    } catch (Throwable e) {
        CrashReport report = CrashReport.makeCrashReport(e, "Toggling Wurst mod");
        CrashReportCategory category = report.makeCategory("Affected mod");
        category.setDetail("Mod name", () -> name);
        category.setDetail("Attempted action", () -> enabled ? "Enable" : "Disable");
        throw new ReportedException(report);
    }
    if (stateSaved)
        ConfigFiles.MODS.save();
}
Also used : CrashReport(net.minecraft.crash.CrashReport) NavigatorMod(net.wurstclient.features.mods.other.NavigatorMod) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Aggregations

CrashReport (net.minecraft.crash.CrashReport)2 CrashReportCategory (net.minecraft.crash.CrashReportCategory)2 ReportedException (net.minecraft.util.ReportedException)2 NavigatorMod (net.wurstclient.features.mods.other.NavigatorMod)2