diff options
author | Lulonaut <lulonaut@lulonaut.tech> | 2023-11-10 06:44:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 16:44:17 +1100 |
commit | 4b29acc13ec502a9450585b5b17374f217f20ae7 (patch) | |
tree | 8496cff8dfb4082283b9f62b59b3b9d966689805 /src | |
parent | d33907135ac7143296213e9631ccea89b94d856f (diff) | |
download | NotEnoughUpdates-4b29acc13ec502a9450585b5b17374f217f20ae7.tar.gz NotEnoughUpdates-4b29acc13ec502a9450585b5b17374f217f20ae7.tar.bz2 NotEnoughUpdates-4b29acc13ec502a9450585b5b17374f217f20ae7.zip |
Remove AbiphoneWarning and fix AbiphoneFavourites lore placement (#919)
Diffstat (limited to 'src')
4 files changed, 2 insertions, 223 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index 56074648..45aa6612 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -28,7 +28,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; -import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; @@ -605,10 +604,6 @@ public class RenderListener { AuctionBINWarning.getInstance().render(); } - if (AbiphoneWarning.getInstance().shouldShow()) { - AbiphoneWarning.getInstance().render(); - } - if (PresetWarning.getInstance().shouldShow()) { PresetWarning.getInstance().render(); } @@ -887,11 +882,6 @@ public class RenderListener { event.setCanceled(true); return; } - if (AbiphoneWarning.getInstance().shouldShow()) { - AbiphoneWarning.getInstance().mouseInput(mouseX, mouseY); - event.setCanceled(true); - return; - } if (PresetWarning.getInstance().shouldShow()) { PresetWarning.getInstance().mouseInput(mouseX, mouseY); event.setCanceled(true); @@ -1063,11 +1053,6 @@ public class RenderListener { event.setCanceled(true); return; } - if (AbiphoneWarning.getInstance().shouldShow()) { - AbiphoneWarning.getInstance().keyboardInput(); - event.setCanceled(true); - return; - } if (PresetWarning.getInstance().shouldShow()) { PresetWarning.getInstance().keyboardInput(); event.setCanceled(true); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java index 750e674d..3e096d5b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java @@ -30,7 +30,6 @@ import io.github.moulberry.notenoughupdates.events.SlotClickEvent; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -96,11 +95,11 @@ public class AbiphoneFavourites { } if (isAbiphoneShowOnlyFavourites()) { - list.removeIf(s -> s.contains("§eRight-click to remove contact!")); + list.removeIf(s -> s.contains("§8Right-click to remove!")); return; } - int index = list.indexOf("§5§o") + 1; + int index = list.size() - 1; if (getFavouriteContacts().contains(name)) { list.set(0, rawName + " §f- §6Favourite"); list.add(index, "§eShift-click to remove from the favourites!"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java deleted file mode 100644 index 69b0a1b6..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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.autosubscribe.NEUAutoSubscribe; -import io.github.moulberry.notenoughupdates.core.GuiElement; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import io.github.moulberry.notenoughupdates.events.SlotClickEvent; -import io.github.moulberry.notenoughupdates.util.ItemUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; - -@NEUAutoSubscribe -public class AbiphoneWarning extends GuiElement { - private static final AbiphoneWarning INSTANCE = new AbiphoneWarning(); - - private boolean showWarning = false; - private String contactName = null; - private int contactSlot = -1; - - public static AbiphoneWarning getInstance() { - return INSTANCE; - } - - private boolean shouldPerformCheck() { - if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - showWarning = false; - return false; - } - - if (Utils.getOpenChestName().startsWith("Abiphone ")) { - return true; - } else { - showWarning = false; - return false; - } - } - - public boolean shouldShow() { - return shouldPerformCheck() && showWarning; - } - - @SubscribeEvent - public void onMouseClick(SlotClickEvent event) { - if (!shouldPerformCheck()) return; - if (!NotEnoughUpdates.INSTANCE.config.misc.abiphoneWarning) return; - if (event.slotId == -999) return; - if (event.clickedButton == 0) return; - - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - - ItemStack clickedContact = chest.inventorySlots.getSlot(event.slotId).getStack(); - if (clickedContact == null) return; - - List<String> list = ItemUtils.getLore(clickedContact); - if (list.isEmpty()) return; - - String last = list.get(list.size() - 1); - if (last.contains("Right-click to remove contact!")) { - showWarning = true; - contactName = clickedContact.getDisplayName(); - contactSlot = event.slotId; - event.setCanceled(true); - } - } - - public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) { - if (shouldShow()) { - cir.setReturnValue(false); - } - } - - @Override - public void render() { - final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - final int width = scaledResolution.getScaledWidth(); - final int height = scaledResolution.getScaledHeight(); - - GlStateManager.disableLighting(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, 500); - - Gui.drawRect(0, 0, width, height, 0x80000000); - - RenderUtils.drawFloatingRectDark(width / 2 - 90, height / 2 - 45, 180, 90); - - int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU"); - Minecraft.getMinecraft().fontRendererObj.drawString( - "\u00a7lNEU", - width / 2 + 90 - neuLength - 3, height / 2 - 45 + 4, 0xff000000 - ); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Are you SURE?", - width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040 - ); - - String sellLine = "\u00a77[ \u00a7r" + contactName + "\u00a77 ]"; - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - sellLine, - width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff - ); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Continue removing this contact?", - width / 2, height / 2 - 45 + 50, false, 170, 0xffa0a0a0 - ); - - RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); - RenderUtils.drawFloatingRectDark(width / 2 + 3, height / 2 + 23, 40, 16, false); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GREEN + "[Y]es", - width / 2 - 23, height / 2 + 31, true, 36, 0xff00ff00 - ); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.RED + "[N]o", - width / 2 + 23, height / 2 + 31, true, 36, 0xffff0000 - ); - - GlStateManager.popMatrix(); - } - - @Override - public boolean mouseInput(int mouseX, int mouseY) { - final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - final int width = scaledResolution.getScaledWidth(); - final int height = scaledResolution.getScaledHeight(); - - if (Mouse.getEventButtonState()) { - if (mouseY >= height / 2 + 23 && mouseY <= height / 2 + 23 + 16) { - if (mouseX >= width / 2 - 43 && mouseX <= width / 2 - 3) { - makeClick(); - } - showWarning = false; - } - - if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 || - mouseY < height / 2 - 45 || mouseY > height / 2 + 45) { - showWarning = false; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - if (!Keyboard.getEventKeyState()) { - if (Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) { - makeClick(); - } - showWarning = false; - } - - return false; - } - - private void makeClick() { - if (contactSlot != -1) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, - contactSlot, 1, 0, Minecraft.getMinecraft().thePlayer - ); - contactSlot = -1; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index 49ef0390..41ae6e66 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -26,11 +26,9 @@ import io.github.moulberry.notenoughupdates.events.GuiContainerBackgroundDrawnEv import io.github.moulberry.notenoughupdates.events.SlotClickEvent; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneFavourites; -import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionSortModeWarning; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; -import io.github.moulberry.notenoughupdates.miscfeatures.DungeonNpcProfitOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.miscfeatures.PresetWarning; @@ -204,7 +202,6 @@ public abstract class MixinGuiContainer extends GuiScreen { GuiCustomEnchant.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); GuiCustomHex.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); AuctionBINWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); - AbiphoneWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); PresetWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); } |