From 4c79701d22633d9626eb9185ddbb904803099b5a Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 29 Feb 2020 11:28:18 -0500 Subject: [PATCH 1/2] Make desktop notifications more useful --- src/api/java/baritone/api/Settings.java | 27 ++++++++++++++++++- .../java/baritone/process/BuilderProcess.java | 4 +++ .../baritone/process/CustomGoalProcess.java | 4 +++ .../java/baritone/process/ExploreProcess.java | 7 +++++ .../java/baritone/process/FarmProcess.java | 4 +++ .../java/baritone/process/MineProcess.java | 4 +++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1bbde3b2..5fd6b64c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1047,10 +1047,35 @@ public final class Settings { public final Setting renderSelectionCorners = new Setting<>(true); /** - * Desktop Notifications + * Desktop notifications */ public final Setting desktopNotifications = new Setting<>(false); + /** + * Desktop notification on path complete + */ + public final Setting notificationOnPathComplete = new Setting<>(true); + + /** + * Desktop notification on farm fail + */ + public final Setting notificationOnFarmFail = new Setting<>(true); + + /** + * Desktop notification on build finished + */ + public final Setting notificationOnBuildFinished = new Setting<>(true); + + /** + * Desktop notification on explore finished + */ + public final Setting notificationOnExploreFinished = new Setting<>(true); + + /** + * Desktop notification on mine fail + */ + public final Setting notificationOnMineFail = new Setting<>(true); + /** * A map of lowercase setting field names to their respective setting */ diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 5af43492..4d57a347 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -39,6 +39,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; +import baritone.utils.NotificationHelper; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.MapArtSchematic; import baritone.utils.schematic.SchematicSystem; @@ -406,6 +407,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil numRepeats++; if (repeat.equals(new Vec3i(0, 0, 0)) || (max != -1 && numRepeats >= max)) { logDirect("Done building"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnBuildFinished.value) { + NotificationHelper.notify("Done building", false); + } onLostControl(); return null; } diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index b45c7d6f..f925bec7 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -23,6 +23,7 @@ import baritone.api.process.ICustomGoalProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; import baritone.utils.BaritoneProcessHelper; +import baritone.utils.NotificationHelper; /** * As set by ExampleBaritoneControl or something idk @@ -93,6 +94,9 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC if (Baritone.settings().disconnectOnArrival.value) { ctx.world().sendQuittingDisconnectingPacket(); } + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnPathComplete.value) { + NotificationHelper.notify("Pathing complete", false); + } return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL); } return new PathingCommand(this.goal, PathingCommandType.SET_GOAL_AND_PATH); diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index 220ae3b1..c42ece0e 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -29,6 +29,7 @@ import baritone.api.process.PathingCommandType; import baritone.api.utils.MyChunkPos; import baritone.cache.CachedWorld; import baritone.utils.BaritoneProcessHelper; +import baritone.utils.NotificationHelper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -83,12 +84,18 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { if (calcFailed) { logDirect("Failed"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnExploreFinished.value) { + NotificationHelper.notify("Exploration failed", true); + } onLostControl(); return null; } IChunkFilter filter = calcFilter(); if (!Baritone.settings().disableCompletionCheck.value && filter.countRemain() == 0) { logDirect("Explored all chunks"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnExploreFinished.value) { + NotificationHelper.notify("Explored all chunks", false); + } onLostControl(); return null; } diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index a91fda60..407157b3 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -31,6 +31,7 @@ import baritone.api.utils.input.Input; import baritone.cache.WorldScanner; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; +import baritone.utils.NotificationHelper; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -257,6 +258,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro if (calcFailed) { logDirect("Farm failed"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnFarmFail.value) { + NotificationHelper.notify("Farm failed", true); + } onLostControl(); return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index a76121b8..b44709e3 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -30,6 +30,7 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; +import baritone.utils.NotificationHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockFalling; @@ -221,6 +222,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro locs.addAll(dropped); if (locs.isEmpty()) { logDirect("No locations for " + filter + " known, cancelling"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { + NotificationHelper.notify("No locations for " + filter + " known, cancelling", true); + } cancel(); return; } From 0434e1c5d3cb73364c5ce8fe93725f16c939ab00 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 29 Feb 2020 12:24:06 -0500 Subject: [PATCH 2/2] Add more entries to MineProcess --- src/main/java/baritone/process/MineProcess.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index b44709e3..6e8ba245 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -89,10 +89,16 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (calcFailed) { if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { logDirect("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance..."); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { + NotificationHelper.notify("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...", true); + } knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); } else { logDirect("Unable to find any path to " + filter + ", canceling mine"); + if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { + NotificationHelper.notify("Unable to find any path to " + filter + ", canceling mine", true); + } cancel(); return null; }