An ease-of-access interface to provide the Minecraft game instance, chat and console logging mechanisms, and the Baritone chat prefix. @author Brady @since 8/1/2018
| 37 | * @since 8/1/2018 |
| 38 | */ |
| 39 | public interface Helper { |
| 40 | |
| 41 | /** |
| 42 | * Instance of {@link Helper}. Used for static-context reference. |
| 43 | */ |
| 44 | Helper HELPER = new Helper() {}; |
| 45 | |
| 46 | /** |
| 47 | * The main game instance returned by {@link Minecraft#getInstance()}. |
| 48 | * Deprecated since {@link IPlayerContext#minecraft()} should be used instead (In the majority of cases). |
| 49 | */ |
| 50 | @Deprecated |
| 51 | Minecraft mc = Minecraft.getInstance(); |
| 52 | |
| 53 | /** |
| 54 | * The tag to assign to chat messages when {@link Settings#useMessageTag} is {@code true}. |
| 55 | */ |
| 56 | GuiMessageTag MESSAGE_TAG = new GuiMessageTag(0xFF55FF, null, Component.literal("Baritone message."), "Baritone"); |
| 57 | |
| 58 | static Component getPrefix() { |
| 59 | // Inner text component |
| 60 | final Calendar now = Calendar.getInstance(); |
| 61 | final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3; |
| 62 | MutableComponent baritone = Component.literal(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone"); |
| 63 | baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE)); |
| 64 | |
| 65 | // Outer brackets |
| 66 | MutableComponent prefix = Component.literal(""); |
| 67 | prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE)); |
| 68 | prefix.append("["); |
| 69 | prefix.append(baritone); |
| 70 | prefix.append("]"); |
| 71 | |
| 72 | return prefix; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Send a message to display as a toast popup |
| 77 | * |
| 78 | * @param title The title to display in the popup |
| 79 | * @param message The message to display in the popup |
| 80 | */ |
| 81 | default void logToast(Component title, Component message) { |
| 82 | Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message)); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Send a message to display as a toast popup |
| 87 | * |
| 88 | * @param title The title to display in the popup |
| 89 | * @param message The message to display in the popup |
| 90 | */ |
| 91 | default void logToast(String title, String message) { |
| 92 | logToast(Component.literal(title), Component.literal(message)); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Send a message to display as a toast popup |
no outgoing calls
no test coverage detected