diff options
5 files changed, 183 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 143033b7..8d4abc7d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -78,6 +78,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.TitleUtil; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; @@ -322,6 +323,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(MinionHelperManager.getInstance()); MinecraftForge.EVENT_BUS.register(navigation); MinecraftForge.EVENT_BUS.register(new WorldListener(this)); + MinecraftForge.EVENT_BUS.register(TitleUtil.getInstance()); if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index a5acd5b4..6a94c0b3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -23,6 +23,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; +import io.github.moulberry.notenoughupdates.miscfeatures.EnderNodes; import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay; @@ -306,5 +307,9 @@ public class ChatListener { unformatted.equals("You have successfully picked the lock on this chest!") || (unformatted.startsWith("You received +") && unformatted.endsWith(" Powder"))) OverlayManager.powderGrindingOverlay.message(unformatted); + + if (unformatted.equals("ENDER NODE! You found Endermite Nest!")) { + EnderNodes.dispalyEndermiteNotif(); + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java new file mode 100644 index 00000000..b0823a7d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import io.github.moulberry.notenoughupdates.util.TitleUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; + +public class EnderNodes { + // TODO Add ender node highliter + // TODO Add ender node counter ( maybe money estimation ) + + public static void dispalyEndermiteNotif() { + if (NotEnoughUpdates.INSTANCE.config.notifications.endermiteAlert && SBInfo.getInstance().getLocation() != null && + SBInfo.getInstance().getLocation().equals("combat_3")) { + TitleUtil.getInstance().createTitle("Nested Endermite", + NotEnoughUpdates.INSTANCE.config.notifications.endermiteAlertTicks, + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.notifications.endermiteAlertColor)); + Minecraft.getMinecraft().thePlayer.playSound("random.orb", 1, 1); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java index 85ad2093..3541860d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java @@ -20,7 +20,10 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; @@ -86,4 +89,43 @@ public class Notifications { minStep = 25 ) public int boosterCookieWarningMins = 1440; + + @Expose + @ConfigOption( + name = "Ender Nodes", + desc = "" + ) + @ConfigEditorAccordion(id = 1) + public boolean enderNodeAccordion = false; + + @Expose + @ConfigOption( + name = "Nested Endermite Alert", + desc = "It will alert the user if a nested endermite gets spawned" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean endermiteAlert = true; + + @Expose + @ConfigOption( + name = "Nested Endermite Alert Color", + desc = "The color the alert will be shown" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 1) + public String endermiteAlertColor = "0:255:194:0:174"; + + @Expose + @ConfigOption( + name = "Nested Endermite Alert Display Time", + desc = "How long the display would stay for in ticks" + ) + @ConfigEditorSlider( + minValue = 1, + maxValue = 200, + minStep = 20 + ) + @ConfigAccordionId(id = 1) + public int endermiteAlertTicks = 20; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/TitleUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/TitleUtil.java new file mode 100644 index 00000000..59db7cac --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TitleUtil.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.util; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class TitleUtil { + + private static final TitleUtil INSTANCE = new TitleUtil(); + + public static TitleUtil getInstance() { + return INSTANCE; + } + + private String title = null; + private long titleLifetime = 0; + private int color = 0xFF0000; + + public void createTitle(String title, int ticks, int color) { + this.title = title; + this.titleLifetime = System.nanoTime() + (ticks * 50000000L); + this.color = color; + } + /** + * Adapted from SkyblockAddons under MIT license + * @link https://github.com/BiscuitDevelopment/SkyblockAddons/blob/master/LICENSE + * @author BiscuitDevelopment + */ + private void renderTitles (ScaledResolution scaledResolution) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.theWorld == null || mc.thePlayer == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; + + int scaledWidth = scaledResolution.getScaledWidth(); + int scaledHeight = scaledResolution.getScaledHeight(); + + if (this.title != null) { + int stringWidth = mc.fontRendererObj.getStringWidth(this.title); + float scale = 4f; // Scale is normally 4, but if it's larger than the screen, scale it down... + if (stringWidth * scale > scaledWidth * 0.9f) { + scale = scaledWidth * 0.9f / (float) stringWidth; + } + GlStateManager.pushMatrix(); + GlStateManager.translate((float)(scaledWidth / 2),(float)(scaledHeight / 2), 0.0f); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.pushMatrix(); + GlStateManager.scale(scale, scale, scale); + mc.fontRendererObj.drawString( + this.title, + ((float)-mc.fontRendererObj.getStringWidth(this.title) / 2), + -20.0f, + color, + true + ); + GlStateManager.popMatrix(); + GlStateManager.popMatrix(); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderHUD(RenderGameOverlayEvent event) { + if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return; + if (System.nanoTime() >= titleLifetime) { + titleLifetime = 0; + title = null; + } + renderTitles(event.resolution); + } +} |