diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2022-11-02 22:58:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 22:58:30 +0100 |
commit | a09a6ee1d1c8776b1750df47379df8dbc1209ebc (patch) | |
tree | ac8cf5047e200423c8cdbb3aee57787e1d5f6f50 | |
parent | 0d93cc5ca0e2749882da24b95bd02a38b2850b7a (diff) | |
parent | 5f0291595204c06be9c6462dce6b166b03c19f68 (diff) | |
download | NotEnoughUpdates-a09a6ee1d1c8776b1750df47379df8dbc1209ebc.tar.gz NotEnoughUpdates-a09a6ee1d1c8776b1750df47379df8dbc1209ebc.tar.bz2 NotEnoughUpdates-a09a6ee1d1c8776b1750df47379df8dbc1209ebc.zip |
Merge branch 'master' into feature/glowshroomsfeature/glowshrooms
36 files changed, 1277 insertions, 459 deletions
diff --git a/Update Notes/2.1.1.md b/Update Notes/2.1.1.md index 681f8773..b7e59a6c 100644 --- a/Update Notes/2.1.1.md +++ b/Update Notes/2.1.1.md @@ -19,8 +19,10 @@ - Add total trophy fish count to /pv - Vixid - Allow hiding messages below a set skyblock level - nopo - Add Glowing Mushroom Highlighter - nea89 + - Add crimson isle page to /pv - Vixid - Add crimson isle quests to todo overlay - Vixid - Add replace chat social options to both party and guild chat - Vixid - Add class average to dungeons page in /pv - Vixid - Add recipe history and fairy soul waypoint distance - Vixid - Fix buggy cape on player model in /pv - Vixid + diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 4c8ac2b9..45efe151 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -61,6 +61,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.PowerStoneStatsDisplay; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; +import io.github.moulberry.notenoughupdates.miscfeatures.WitherCloakChanger; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures; @@ -266,6 +267,9 @@ public class NotEnoughUpdates { if (config.profileViewer.pageLayout.size() == 9) { config.profileViewer.pageLayout.add(9); } + if (config.profileViewer.pageLayout.size() == 10) { + config.profileViewer.pageLayout.add(10); + } // Remove after 2.1 ig if ("dangerous".equals(config.apiData.repoBranch)) { @@ -291,6 +295,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new Constants()); MinecraftForge.EVENT_BUS.register(new DungeonMap()); MinecraftForge.EVENT_BUS.register(new SunTzu()); + MinecraftForge.EVENT_BUS.register(new WitherCloakChanger()); MinecraftForge.EVENT_BUS.register(new MiningStuff()); MinecraftForge.EVENT_BUS.register(FairySouls.getInstance()); MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java index 3967edb4..d52ed196 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java @@ -33,14 +33,10 @@ import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.MapData; import java.awt.*; -import java.io.BufferedReader; import java.io.File; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; import java.util.Map; public class MapCommand extends ClientCommandBase { @@ -52,35 +48,8 @@ public class MapCommand extends ClientCommandBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (NotEnoughUpdates.INSTANCE.colourMap == null) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft - .getMinecraft() - .getResourceManager() - .getResource( - new ResourceLocation("notenoughupdates:maps/F1Full.json")) - .getInputStream(), StandardCharsets.UTF_8)) - ) { - JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); - - NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128]; - for (int x = 0; x < 128; x++) { - for (int y = 0; y < 128; y++) { - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0); - } - } - for (Map.Entry<String, JsonElement> entry : json.entrySet()) { - int x = Integer.parseInt(entry.getKey().split(":")[0]); - int y = Integer.parseInt(entry.getKey().split(":")[1]); - - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); - } - } catch (Exception ignored) { - } - } - if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); return; } @@ -90,7 +59,7 @@ public class MapCommand extends ClientCommandBase { } if (args.length != 2) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); return; } @@ -157,6 +126,6 @@ public class MapCommand extends ClientCommandBase { return; } - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java index 535c92bf..57b2bed7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -31,6 +31,7 @@ public class Position { private boolean centerX; @Expose private boolean centerY; + private boolean clicked = false; private static final int EDGE_OFFSET = 0; @@ -72,6 +73,13 @@ public class Position { return y; } + public void setClicked(boolean state) { + this.clicked = state; + } + public boolean getClicked() { + return clicked; + } + public int getAbsX(ScaledResolution scaledResolution, int objWidth) { int width = scaledResolution.getScaledWidth(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java index ed45bab6..6fb8f353 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -20,6 +20,8 @@ package io.github.moulberry.notenoughupdates.core.config.gui; import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -29,45 +31,66 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; public class GuiPositionEditor extends GuiScreen { - private final Position position; - private final Position originalPosition; - private final int elementWidth; - private final int elementHeight; - private final Runnable renderCallback; + private final ArrayList<Position> positions; + private final ArrayList<Position> originalPositions; + private final ArrayList<Integer> elementWidths; + private final ArrayList<Integer> elementHeights; + private final ArrayList<Runnable> renderCallback; private final Runnable positionChangedCallback; private final Runnable closedCallback; - private boolean clicked = false; private int grabbedX = 0; private int grabbedY = 0; + private int clickedPos = -1; + + public static boolean renderDrill = false; private int guiScaleOverride = -1; public GuiPositionEditor( - Position position, int elementWidth, int elementHeight, + LinkedHashMap<TextOverlay, Position> overlayPositions, Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback ) { - this.position = position; - this.originalPosition = position.clone(); - this.elementWidth = elementWidth; - this.elementHeight = elementHeight; - this.renderCallback = renderCallback; + ArrayList<Position> pos = new ArrayList<>(); + ArrayList<Position> ogPos = new ArrayList<>(); + ArrayList<Runnable> renderCallbac = new ArrayList<>(); + ArrayList<Integer> width = new ArrayList<>(); + ArrayList<Integer> height = new ArrayList<>(); + for (int i = 0; i < overlayPositions.size(); i++) { + TextOverlay overlay = new ArrayList<>(overlayPositions.keySet()).get(i); + pos.add(overlayPositions.get(overlay)); + ogPos.add(pos.get(i).clone()); + width.add((int) overlay.getDummySize().x); + height.add((int) overlay.getDummySize().y); + renderCallbac.add(() -> { + if (overlay.shouldRenderInGuiEditor) { + overlay.renderDummy(); + OverlayManager.dontRenderOverlay.add(overlay.getClass()); + } + }); + } + + + this.positions = pos; + this.originalPositions = ogPos; + this.renderCallback = renderCallbac; + this.elementWidths = width; + this.elementHeights = height; this.positionChangedCallback = positionChangedCallback; this.closedCallback = closedCallback; } - public GuiPositionEditor withScale(int scale) { - this.guiScaleOverride = scale; - return this; - } - @Override public void onGuiClosed() { super.onGuiClosed(); closedCallback.run(); + renderDrill = false; + clickedPos = -1; } @Override @@ -86,32 +109,34 @@ public class GuiPositionEditor extends GuiScreen { mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; drawDefaultBackground(); + renderDrill = true; + for (Position position : positions) { + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + } - if (clicked) { - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - } - - renderCallback.run(); + renderCallback.get(positions.indexOf(position)).run(); - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); - } - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff - ); - Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff - ); + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff + ); + Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff + ); + } } @Override @@ -127,20 +152,25 @@ public class GuiPositionEditor extends GuiScreen { } mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + for (int i = positions.size() - 1; i >= 0; i--) { + Position position = positions.get(i); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + if (!position.getClicked()) { + if (mouseX >= x && mouseY >= y && + mouseX <= x + elementWidth && mouseY <= y + elementHeight) { + clickedPos = i; + position.setClicked(true); + grabbedX = mouseX; + grabbedY = mouseY; + break; + } + } - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - - if (mouseX >= x && mouseY >= y && - mouseX <= x + elementWidth && mouseY <= y + elementHeight) { - clicked = true; - grabbedX = mouseX; - grabbedY = mouseY; - } - - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); } } @@ -148,19 +178,24 @@ public class GuiPositionEditor extends GuiScreen { @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { - if (keyCode == Keyboard.KEY_R) { - position.set(originalPosition); - } else if (!clicked) { - boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - int dist = shiftHeld ? 10 : 1; - if (keyCode == Keyboard.KEY_DOWN) { - position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_UP) { - position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + if (clickedPos != -1) { + Position position = positions.get(clickedPos); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (keyCode == Keyboard.KEY_R) { + position.set(originalPositions.get(positions.indexOf(position))); + } else if (!position.getClicked()) { + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } } } super.keyTyped(typedChar, keyCode); @@ -169,28 +204,26 @@ public class GuiPositionEditor extends GuiScreen { @Override protected void mouseReleased(int mouseX, int mouseY, int state) { super.mouseReleased(mouseX, mouseY, state); - clicked = false; + for (Position position : positions) { + position.setClicked(false); + } } @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + for (Position position : positions) { + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + ScaledResolution scaledResolution = Utils.pushGuiScale(-1); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); - if (clicked) { - ScaledResolution scaledResolution; - if (guiScaleOverride >= 0) { - scaledResolution = Utils.pushGuiScale(guiScaleOverride); - } else { - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - } - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - positionChangedCallback.run(); - - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java new file mode 100644 index 00000000..b334418c --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java @@ -0,0 +1,198 @@ +/* + * 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.core.config.gui; + +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.io.IOException; + +public class GuiPositionEditorButForTheDungeonMap extends GuiScreen { // nea is gonna LOVE this file's existence + private final Position position; + private final Position originalPosition; + private final int elementWidth; + private final int elementHeight; + private final Runnable renderCallback; + private final Runnable positionChangedCallback; + private final Runnable closedCallback; + private boolean clicked = false; + private int grabbedX = 0; + private int grabbedY = 0; + + private int guiScaleOverride = -1; + + public GuiPositionEditorButForTheDungeonMap( + Position position, int elementWidth, int elementHeight, + Runnable renderCallback, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + this.position = position; + this.originalPosition = position.clone(); + this.elementWidth = elementWidth; + this.elementHeight = elementHeight; + this.renderCallback = renderCallback; + this.positionChangedCallback = positionChangedCallback; + this.closedCallback = closedCallback; + } + + public GuiPositionEditorButForTheDungeonMap withScale(int scale) { + this.guiScaleOverride = scale; + return this; + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + closedCallback.run(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + drawDefaultBackground(); + + if (clicked) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + } + + renderCallback.run(); + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff + ); + Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff + ); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseButton == 0) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + + if (mouseX >= x && mouseY >= y && + mouseX <= x + elementWidth && mouseY <= y + elementHeight) { + clicked = true; + grabbedX = mouseX; + grabbedY = mouseY; + } + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (keyCode == Keyboard.KEY_R) { + position.set(originalPosition); + } else if (!clicked) { + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } + } + super.keyTyped(typedChar, keyCode); + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + clicked = false; + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + + if (clicked) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index 50eff87a..2b14bfed 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java @@ -37,11 +37,14 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; import net.minecraft.util.Vec3i; +import net.minecraftforge.client.event.RenderWorldLastEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import org.lwjgl.util.vector.Vector3f; +import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -412,6 +415,31 @@ public class RenderUtils { renderWayPoint(Arrays.asList(""), new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks, true); } + public static void drawFilledQuadWithTexture(Vec3 p1, Vec3 p2, Vec3 p3, Vec3 p4, float alpha, ResourceLocation texture) { + GlStateManager.pushMatrix(); + Entity v = Minecraft.getMinecraft().getRenderViewEntity(); + double vX = v.lastTickPosX + (v.posX - v.lastTickPosX); + double vY = v.lastTickPosY + (v.posY - v.lastTickPosY); + double vZ = v.lastTickPosZ + (v.posZ - v.lastTickPosZ); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + GlStateManager.enableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableCull(); + GlStateManager.color(1.0f, 1.0f, 1.0f, alpha); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(p1.xCoord-vX, p1.yCoord-vY, p1.zCoord-vZ).tex(0, 0).endVertex(); //Top Left + worldrenderer.pos(p2.xCoord-vX, p2.yCoord-vY, p2.zCoord-vZ).tex(1, 0).endVertex(); //Top Right + worldrenderer.pos(p3.xCoord-vX, p3.yCoord-vY, p3.zCoord-vZ).tex(1, 1).endVertex(); //Bottom Right + worldrenderer.pos(p4.xCoord-vX, p4.yCoord-vY, p4.zCoord-vZ).tex(0, 1).endVertex(); //Bottom Left + tessellator.draw(); + GlStateManager.enableCull(); + GlStateManager.popMatrix(); + } + public static void renderWayPoint(List<String> lines, Vector3f loc, float partialTicks, boolean onlyShowDistance) { GlStateManager.alphaFunc(516, 0.1F); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index 88c89773..e15168f5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -65,8 +65,13 @@ import java.awt.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.*; +import java.util.Map; +import java.util.Objects; +import java.util.Set; public class DungeonMap { private static final ResourceLocation GREEN_CHECK = new ResourceLocation( @@ -498,8 +503,8 @@ public class DungeonMap { mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240; } mapSizeY = mapSizeX; - int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize; - int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize; + int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize + (isFloorOne ? getRenderRoomSize() : 0); + int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize + (isEntrance ? getRenderRoomSize() : 0); int mapCenterX = mapSizeX / 2; int mapCenterY = mapSizeY / 2; int scaleFactor = 8; @@ -669,12 +674,12 @@ public class DungeonMap { float angle = pos.rotation; boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp; - if (!isFloorOne && playerEntityMapPositions.containsKey(name)) { + if (playerEntityMapPositions.containsKey(name)) { MapPosition entityPos = playerEntityMapPositions.get(name); angle = entityPos.rotation; - float deltaX = entityPos.getRenderX() - pos.getRenderX(); - float deltaY = entityPos.getRenderY() - pos.getRenderY(); + float deltaX = entityPos.getRenderX() - pos.getRenderX() + (isFloorOne ? getRenderRoomSize() : 0); + float deltaY = entityPos.getRenderY() - pos.getRenderY() + (isEntrance ? getRenderRoomSize() : 0); x += deltaX; y += deltaY; @@ -1119,6 +1124,7 @@ public class DungeonMap { } private boolean isFloorOne = false; + private boolean isEntrance = false; private boolean failMap = false; private long lastClearCache = 0; @@ -1160,6 +1166,9 @@ public class DungeonMap { if (line.contains("(F1)") || line.contains("(E)") || line.contains("(M1)")) { isFloorOne = true; + if (line.contains("(E)")) { + isEntrance = true; + } break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index 735fa3e6..98d36f2b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -19,11 +19,13 @@ package io.github.moulberry.notenoughupdates.dungeons; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiElementColour; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditorButForTheDungeonMap; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; @@ -46,8 +48,11 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -80,6 +85,8 @@ public class GuiDungeonMapEditor extends GuiScreen { private Field clickedSlider; + private Runnable closedCallback; + class Button { private final int id; private final int x; @@ -150,8 +157,34 @@ public class GuiDungeonMapEditor extends GuiScreen { } - public GuiDungeonMapEditor() { - DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap; + public GuiDungeonMapEditor(Runnable closedCallback) { + + if (NotEnoughUpdates.INSTANCE.colourMap == null) { + try ( + BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft + .getMinecraft() + .getResourceManager() + .getResource( + new ResourceLocation("notenoughupdates:maps/F1Full.json")) + .getInputStream(), StandardCharsets.UTF_8)) + ) { + JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); + + NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128]; + for (int x = 0; x < 128; x++) { + for (int y = 0; y < 128; y++) { + NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0); + } + } + for (Map.Entry<String, JsonElement> entry : json.entrySet()) { + int x = Integer.parseInt(entry.getKey().split(":")[0]); + int y = Integer.parseInt(entry.getKey().split(":")[1]); + + NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); + } + } catch (Exception ignored) { + } + } //Map Border Styles buttons.add(new Button(6, 6, 97 + 30, "None")); @@ -244,6 +277,7 @@ public class GuiDungeonMapEditor extends GuiScreen { } blurField.setText(strVal); } + this.closedCallback = closedCallback; } @Override @@ -589,8 +623,9 @@ public class GuiDungeonMapEditor extends GuiScreen { HashSet<String> players = new HashSet<>(); players.add(Minecraft.getMinecraft().thePlayer.getName()); GlStateManager.color(1, 1, 1, 1); - - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( + Runnable runnable = this.closedCallback; + this.closedCallback = null; + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditorButForTheDungeonMap( NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition, size, size, () -> { ScaledResolution scaledResolution = Utils.pushGuiScale(2); @@ -605,7 +640,7 @@ public class GuiDungeonMapEditor extends GuiScreen { 0 ); Utils.pushGuiScale(-1); - }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor() + }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(runnable) ).withScale(2)); return; } @@ -856,4 +891,11 @@ public class GuiDungeonMapEditor extends GuiScreen { Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); blurOutputVert.unbindFramebufferTexture(); } + + @Override + public void onGuiClosed() { + if (this.closedCallback != null) { + this.closedCallback.run(); + } + } } 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 ca841590..191567a1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -184,17 +184,21 @@ public class RenderListener { DungeonWin.render(event.partialTicks); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -200); + label: for (TextOverlay overlay : OverlayManager.textOverlays) { - if (OverlayManager.dontRenderOverlay != null && - OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) { - continue; + for (Class<? extends TextOverlay> dontRender : OverlayManager.dontRenderOverlay) { + if (dontRender != null && + dontRender.isAssignableFrom(overlay.getClass())) { + continue label; + } } + GlStateManager.translate(0, 0, -1); GlStateManager.enableDepth(); overlay.render(); } GlStateManager.popMatrix(); - OverlayManager.dontRenderOverlay = null; + OverlayManager.dontRenderOverlay = new ArrayList<>(); } if (Keyboard.isKeyDown(Keyboard.KEY_X)) { NotificationHandler.notificationDisplayMillis = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WitherCloakChanger.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WitherCloakChanger.java new file mode 100644 index 00000000..84ee76c5 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WitherCloakChanger.java @@ -0,0 +1,129 @@ +/* + * 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.core.util.render.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +public class WitherCloakChanger { + public static boolean isCloakActive = false; + public static long lastDeactivate = System.currentTimeMillis(); + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onChatMessage(ClientChatReceivedEvent event) { + if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; + if (event.message.getUnformattedText().startsWith("Creeper Veil ")) { + if (isCloakActive && !event.message.getUnformattedText().equals("Creeper Veil Activated!")) { + isCloakActive = false; + lastDeactivate = System.currentTimeMillis(); + } else { + isCloakActive = true; + } + } else if (event.message.getUnformattedText().startsWith("Not enough mana! Creeper Veil De-activated!")) { + isCloakActive = false; + lastDeactivate = System.currentTimeMillis(); + } + } + + @SubscribeEvent + public void onWorldChange(WorldEvent.Unload event) { + isCloakActive = false; + } + + private static final ResourceLocation witherCloakShield = new ResourceLocation( + "notenoughupdates:wither_cloak_shield.png"); + + @SubscribeEvent + public void onRenderLast(RenderWorldLastEvent event) { + if (!NotEnoughUpdates.INSTANCE.isOnSkyblock() || !isCloakActive || + !NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakToggle) return; + Minecraft mc = Minecraft.getMinecraft(); + + //CONSTANTS (Other contribs, mess with these as you wish, but you should know I chose these for a reason) + final double shieldWidth = 0.8d; //How wide they are + final double shieldHeight = 2.0d; //How tall they are + final double accuracy = + 4.0d; //Will be accurate to 1/accuracy of a degree (so updates every 0.25 degrees with an accuracy of 4) + + for (int i = 0; i < NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakCount; i++) { + double angle = (int) ( + ((System.currentTimeMillis() / 30 * NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakSpeed * + -0.5 * accuracy)) % (360 * accuracy)) / accuracy; + angle += (360d / NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakCount) * i; + angle %= 360; + double posX = mc.thePlayer.posX - (shieldWidth / 2); + double posY = mc.thePlayer.posY; + double posZ = mc.thePlayer.posZ + NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakDistance; + + Vec3 topLeft = rotateAboutOrigin( + mc.thePlayer.posX, + mc.thePlayer.posZ, + angle, + new Vec3(posX, posY + shieldHeight, posZ) + ); + Vec3 topRight = rotateAboutOrigin( + mc.thePlayer.posX, + mc.thePlayer.posZ, + angle, + new Vec3(posX + shieldWidth, posY + shieldHeight, posZ) + ); + Vec3 bottomRight = rotateAboutOrigin( + mc.thePlayer.posX, + mc.thePlayer.posZ, + angle, + new Vec3(posX + shieldWidth, posY, posZ) + ); + Vec3 bottomLeft = rotateAboutOrigin(mc.thePlayer.posX, mc.thePlayer.posZ, angle, new Vec3(posX, posY, posZ)); + RenderUtils.drawFilledQuadWithTexture( + topLeft, + topRight, + bottomRight, + bottomLeft, /*NotEnoughUpdates.INSTANCE.config.misc.customWitherCloakTransparency*/ + 1.0f, + witherCloakShield + ); + } + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate( + GL11.GL_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA, + GL11.GL_ONE, + GL11.GL_ONE_MINUS_SRC_ALPHA + ); + } + + private static Vec3 rotateAboutOrigin(double originX, double originZ, double angle, Vec3 point) { + double a = angle * Math.PI / 180; + double newX = originX + (Math.cos(a) * (point.xCoord - originX) + Math.sin(a) * (point.zCoord - originZ)); + double newZ = originZ + (-Math.sin(a) * (point.xCoord - originX) + Math.cos(a) * (point.zCoord - originZ)); + return new Vec3(newX, point.yCoord, newZ); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java index b90b1356..5053ae70 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java @@ -538,6 +538,8 @@ public class GuiEnchantColour extends GuiScreen { if (base64.length() <= sharePrefix.length()) return false; + base64 = base64.trim(); + try { return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix); } catch (IllegalArgumentException e) { @@ -656,6 +658,8 @@ public class GuiEnchantColour extends GuiScreen { if (base64.length() <= sharePrefix.length()) return; + base64 = base64.trim(); + String jsonString; try { jsonString = new String(Base64.getDecoder().decode(base64)); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java index 7aa0d2ec..c40bb331 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java @@ -25,7 +25,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; -import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GlScissorStack; import io.github.moulberry.notenoughupdates.core.GuiElementTextField; @@ -688,6 +687,8 @@ public class GuiInvButtonEditor extends GuiScreen { if (base64.length() <= sharePrefix.length()) return false; + base64 = base64.trim(); + try { return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix); } catch (IllegalArgumentException e) { @@ -817,6 +818,8 @@ public class GuiInvButtonEditor extends GuiScreen { if (base64.length() <= sharePrefix.length()) return; + base64 = base64.trim(); + String jsonString; try { jsonString = new String(Base64.getDecoder().decode(base64)); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityChargedCreeper.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityChargedCreeper.java new file mode 100644 index 00000000..a9b88d6b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityChargedCreeper.java @@ -0,0 +1,49 @@ +/* + * 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.mixins; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscfeatures.WitherCloakChanger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge; +import net.minecraft.entity.monster.EntityCreeper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LayerCreeperCharge.class) +public abstract class MixinEntityChargedCreeper { + + @Inject(method = "doRenderLayer(Lnet/minecraft/entity/monster/EntityCreeper;FFFFFFF)V", at = @At("HEAD"), cancellable = true) + public void cancelChargedCreeperLayer(EntityCreeper creeper, float f, float g, float partialTicks, float h, float i, float j, float scale, CallbackInfo ci) { + //Wither Cloak Creepers: Is toggled on, Are invisible, 20 max health, usually less than 7.5M from the player, only existent when active, and only in sb obviously + boolean isWitherCloak = + NotEnoughUpdates.INSTANCE.config.itemOverlays.customWitherCloakToggle && creeper.isInvisible() && + creeper.getMaxHealth() == 20.0f && creeper.getDistanceToEntity(Minecraft.getMinecraft().thePlayer) < 7.5f && + (WitherCloakChanger.isCloakActive || System.currentTimeMillis() - WitherCloakChanger.lastDeactivate < 300) && + NotEnoughUpdates.INSTANCE.isOnSkyblock(); + if (isWitherCloak) { + if (ci.isCancellable()) { + ci.cancel(); + } + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 75ae33a1..9c4343cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.Category; import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; @@ -72,24 +73,25 @@ import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; -import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class NEUConfig extends Config { - private void editOverlay(String activeConfig, TextOverlay overlay, Position position) { - Vector2f size = overlay.getDummySize(); - int width = (int) size.x; - int height = (int) size.y; - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> { - overlay.renderDummy(); - OverlayManager.dontRenderOverlay = overlay.getClass(); + public void editOverlay() { + final LinkedHashMap<TextOverlay, Position> overlayPositions = new LinkedHashMap<TextOverlay, Position>(); + for (TextOverlay overlay : OverlayManager.textOverlays) { + overlayPositions.put(overlay, overlay.getPosition()); + } + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(overlayPositions, () -> { + }, () -> { }, () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor))); + NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + })); } @Override @@ -106,28 +108,13 @@ public class NEUConfig extends Config { case -1: return; case 0: - ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap"); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(() -> { + NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + }); return; case 1: - editOverlay(activeConfigCategory, OverlayManager.miningOverlay, mining.overlayPosition); - return; - case 2: - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( - NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition, - NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> { - }, - () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor) - )); - return; - case 3: - editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition); - return; case 4: - editOverlay(activeConfigCategory, OverlayManager.petInfoOverlay, petOverlay.petInfoPosition); - return; - case 5: - editOverlay(activeConfigCategory, OverlayManager.timersOverlay, miscOverlays.todoPosition); + editOverlay(); return; case 6: NotEnoughUpdates.INSTANCE.openGui = new NEUOverlayPlacements(); @@ -138,24 +125,12 @@ public class NEUConfig extends Config { case 8: NotEnoughUpdates.INSTANCE.openGui = new GuiEnchantColour(); return; - case 9: - editOverlay(activeConfigCategory, OverlayManager.bonemerangOverlay, itemOverlays.bonemerangPosition); - return; - case 10: - editOverlay(activeConfigCategory, OverlayManager.crystalHollowOverlay, mining.crystalHollowOverlayPosition); - return; - case 11: - editOverlay(activeConfigCategory, OverlayManager.miningSkillOverlay, skillOverlays.miningPosition); - return; case 12: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/dn"); return; case 13: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/pv"); return; - case 14: - editOverlay(activeConfigCategory, OverlayManager.fishingSkillOverlay, skillOverlays.fishingPosition); - return; case 15: String command = NotEnoughUpdates.INSTANCE.config.misc.fariySoul ? "/neusouls on" : "/neusouls off"; ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command); @@ -166,12 +141,6 @@ public class NEUConfig extends Config { case 17: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neusouls unclear"); return; - case 18: - editOverlay(activeConfigCategory, OverlayManager.slayerOverlay, slayerOverlay.slayerPosition); - return; - case 19: - editOverlay(activeConfigCategory, OverlayManager.combatSkillOverlay, skillOverlays.combatPosition); - return; case 20: FairySouls.getInstance().setTrackFairySouls(NotEnoughUpdates.INSTANCE.config.misc.trackFairySouls); return; @@ -199,9 +168,6 @@ public class NEUConfig extends Config { NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, "apis")); return; - case 25: - editOverlay(activeConfigCategory, OverlayManager.powderGrindingOverlay, mining.powderGrindingTrackerPosition); - return; case 26: OverlayManager.powderGrindingOverlay.reset(); return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java index 9179c6ea..cbe7af1a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java @@ -41,18 +41,6 @@ public class Dungeons { @Expose @ConfigOption( - name = "\u00A7cWarning", - desc = "If you are on Entrance, Floor 1 or Master 1 the map wont work properly" - ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) - @ConfigAccordionId(id = 0) - public boolean dungeonF1Warning = false; - - @Expose - @ConfigOption( name = "Edit Dungeon Map", desc = "The NEU dungeon map has its own editor (/neumap).\n" + "Click the button on the left to open it" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index 3222ce46..84bce030 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; @@ -206,7 +207,7 @@ public class ItemOverlays { name = "Etherwarp", desc = "" ) - @ConfigEditorAccordion(id = 7) + @ConfigEditorAccordion(id = 3) public boolean etherwarpAccordion = false; @Expose @@ -215,7 +216,7 @@ public class ItemOverlays { desc = "Zoom in on targeted blocks with etherwarp, making it easier to adjust at a distance" ) @ConfigEditorBoolean - @ConfigAccordionId(id = 7) + @ConfigAccordionId(id = 3) public boolean etherwarpZoom = true; @Expose @@ -224,7 +225,7 @@ public class ItemOverlays { desc = "Display an overlay which tells you if the etherwarp will fail." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 7) + @ConfigAccordionId(id = 3) public boolean enableEtherwarpHelperOverlay = true; @Expose @@ -233,7 +234,7 @@ public class ItemOverlays { desc = "Display an overlay that tells you what block you will TP to." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 7) + @ConfigAccordionId(id = 3) public boolean enableEtherwarpBlockOverlay = true; @Expose @@ -242,7 +243,7 @@ public class ItemOverlays { desc = "Don't display the etherwarp block overlay when you can't TP to the block" ) @ConfigEditorBoolean - @ConfigAccordionId(id = 7) + @ConfigAccordionId(id = 3) public boolean disableOverlayWhenFailed = false; @Expose @@ -252,14 +253,14 @@ public class ItemOverlays { searchTags = "color" ) @ConfigEditorColour - @ConfigAccordionId(id = 7) + @ConfigAccordionId(id = 3) public String etherwarpHighlightColour = "00:70:156:8:96"; @ConfigOption( name = "Bonemerang Overlay", desc = "" ) - @ConfigEditorAccordion(id = 3) + @ConfigEditorAccordion(id = 4) public boolean bonemerangAccordion = false; @Expose @@ -268,7 +269,7 @@ public class ItemOverlays { desc = "Shows info about the bonemerang while holding it." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 3) + @ConfigAccordionId(id = 4) public boolean enableBonemerangOverlay = true; @Expose @@ -277,19 +278,10 @@ public class ItemOverlays { desc = "Highlight entities that will be hit by your bonemerang" ) @ConfigEditorBoolean - @ConfigAccordionId(id = 3) + @ConfigAccordionId(id = 4) public boolean highlightTargeted = true; @Expose - @ConfigOption( - name = "Bonemerang Overlay Position", - desc = "Change the position of the Bonemerang overlay." - ) - @ConfigEditorButton( - runnableId = 9, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) public Position bonemerangPosition = new Position(-1, -1); @Expose @@ -304,7 +296,7 @@ public class ItemOverlays { "\u00a77Targets: \u00a76\u00a7l10" } ) - @ConfigAccordionId(id = 3) + @ConfigAccordionId(id = 4) public List<Integer> bonemerangOverlayText = new ArrayList<>(Arrays.asList(0, 1)); @Expose @@ -315,7 +307,7 @@ public class ItemOverlays { @ConfigEditorDropdown( values = {"Background", "No Shadow", "Shadow Only", "Full Shadow"} ) - @ConfigAccordionId(id = 3) + @ConfigAccordionId(id = 4) public int bonemerangOverlayStyle = 0; @Expose @ConfigOption( @@ -324,7 +316,7 @@ public class ItemOverlays { "Might cause some lag." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 3) + @ConfigAccordionId(id = 4) public boolean bonemerangFastUpdate = false; @ConfigOption( @@ -386,6 +378,89 @@ public class ItemOverlays { @ConfigAccordionId(id = 6) public boolean enableDirtWandOverlay = true; + @ConfigOption( + name="Custom Wither Cloak", + desc = "" + ) + @ConfigEditorAccordion(id = 7) + public boolean customWitherCloakAccordion = false; + + @Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "Enable Custom Wither Cloak", + desc = "Replaces Hypixel Wither Cloak with custom shields due to the Hypixel Wither Cloak being difficult to see through" + ) + @ConfigEditorBoolean + public boolean customWitherCloakToggle = true; + + @Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "Shield Count", + desc = "The amount of shields circling the player\n0 = No shields" + ) + @ConfigEditorSlider( + minValue = 0, + maxValue = 20, + minStep = 1 + ) + public int customWitherCloakCount = 6; + + @Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "Shield Speed", + desc = "How fast they circle the player\n0 = Not moving\nNegative = Spinning opposite direction" + ) + @ConfigEditorSlider( + minValue = -20f, + maxValue = 20f, + minStep = 1.0f + ) + public double customWitherCloakSpeed = 2d; + + /*@Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "Shield Transparency", + desc = "Changes how visible each shield is\n0 = Invisible" + ) + @ConfigEditorSlider( + minValue = 0f, + maxValue = 1, + minStep = 0.1f + ) + public float customWitherCloakTransparency = 1.0f; + + Couldn't get this to work and couldn't for the life of me figure out why - Cobble8 + */ + + @Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "Shield Distance From Player", + desc = "How far (in blocks) each shield is from the player\n" + + "0 = Inside the player" + ) + @ConfigEditorSlider( + minValue = 0f, + maxValue = 3.0f, + minStep = 0.1f + ) + public float customWitherCloakDistance = 1.2f; + + @Expose + @ConfigAccordionId(id = 7) + @ConfigOption( + name = "\u00A7aInspiration:", + desc = "\u00A76u/Sori0612 \u00A77on \u00A7cReddit\n\n\u00A78https://tinyurl.com/creeperveil" + ) + @ConfigEditorFSR( + runnableId = 12 + ) + public boolean customWitherCloakCredit = false; + @Expose @ConfigOption( name = "Pickaxe Ability Cooldown", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java index 78b4cfd4..fdfb6f93 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java @@ -26,56 +26,27 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; public class LocationEdit { - @ConfigOption( - name = "Edit Dungeon Map", - desc = "The NEU dungeon map has it's own editor (/neumap).\n" + - "Click the button on the left to open it" - ) - @ConfigEditorButton( - runnableId = 0, - buttonText = "Edit" - ) - public int editDungeonMap = 0; @ConfigOption( - name = "Edit Pet Info Position", - desc = "Change the position of the pet info overlay" + name = "Edit GUI locations", + desc = "Change the position of NEU's overlays" ) @ConfigEditorButton( runnableId = 4, buttonText = "Edit" ) - public Position petInfoPosition = new Position(-1, -1); - - @ConfigOption( - name = "Edit Todo Position", - desc = "Change the position of the Todo overlay" - ) - @ConfigEditorButton( - runnableId = 5, - buttonText = "Edit" - ) - public Position todoPosition = new Position(100, 0); - - @ConfigOption( - name = "Edit Bonemerang Overlay Position", - desc = "Change the position of the Bonemerang overlay" - ) - @ConfigEditorButton( - runnableId = 9, - buttonText = "Edit" - ) - public Position bonemerangPosition = new Position(-1, -1); + public Position positions = new Position(-1, -1); @ConfigOption( - name = "Edit Slayer Overlay Position", - desc = "Change the position of the Slayer overlay" + name = "Edit Dungeon Map", + desc = "The NEU dungeon map has it's own editor (/neumap).\n" + + "Click the button on the left to open it" ) @ConfigEditorButton( - runnableId = 18, + runnableId = 0, buttonText = "Edit" ) - public Position slayerPosition = new Position(10, 200); + public int editDungeonMap = 0; @ConfigOption( name = "Inventory", @@ -99,106 +70,4 @@ public class LocationEdit { @ConfigAccordionId(id = 1) @ConfigEditorButton(runnableId = 7, buttonText = "Open") public boolean openEditorButton = true; - - @ConfigOption( - name = "Mining Overlays", - desc = "" - ) - @ConfigEditorAccordion(id = 2) - public boolean miningoverlayAccordion = false; - - @ConfigOption( - name = "Edit Dwarven Overlay Position", - desc = "Change the position of the Dwarven Mines information Overlay (commissions, powder & forge statuses)" - ) - @ConfigEditorButton( - runnableId = 1, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position overlayPosition = new Position(10, 100); - - @ConfigOption( - name = "Edit Crystal Overlay Position", - desc = "Change the position of the Crystal Hollows Overlay" - ) - @ConfigEditorButton( - runnableId = 10, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position crystalHollowOverlayPosition = new Position(200, 0); - - @ConfigOption( - name = "Edit Fuel Bar Position", - desc = "Change the position of the drill fuel bar" - ) - @ConfigEditorButton( - runnableId = 2, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position drillFuelBarPosition = new Position(0, -100, true, false); - - @ConfigOption( - name = "Edit Tracker Position", - desc = "Change the position of the Powder Grinding Tracker Overlay (chests and gained powder)" - ) - @ConfigEditorButton( - runnableId = 25, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position powderGrindingTrackerPosition = new Position(10, 265); - - @ConfigOption( - name = "Skill Overlays", - desc = "" - ) - @ConfigEditorAccordion(id = 3) - public boolean skilloverlayAccordion = false; - - @ConfigOption( - name = "Edit Farming Overlay Position", - desc = "Change the position of the Farming overlay" - ) - @ConfigEditorButton( - runnableId = 3, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position farmingPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Mining Overlay Position", - desc = "Change the position of the Mining overlay" - ) - @ConfigEditorButton( - runnableId = 11, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position miningPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Fishing Overlay Position", - desc = "Change the position of the Fishing overlay" - ) - @ConfigEditorButton( - runnableId = 14, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position fishingPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Combat Overlay Position", - desc = "Change the position of the Combat overlay" - ) - @ConfigEditorButton( - runnableId = 19, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position combatPosition = new Position(10, 200); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 7a6b07fd..da84e32e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -108,15 +108,6 @@ public class Mining { public int drillFuelBarWidth = 200; @Expose - @ConfigOption( - name = "Edit Fuel Bar Position", - desc = "Change the position of the drill fuel bar" - ) - @ConfigEditorButton( - runnableId = 2, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 1) public Position drillFuelBarPosition = new Position(0, -100, true, false); @ConfigOption( @@ -154,15 +145,6 @@ public class Mining { public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4)); @Expose - @ConfigOption( - name = "Edit Dwarven Overlay Position", - desc = "Change the position of the Dwarven Mines information Overlay (commissions, powder & forge statuses)" - ) - @ConfigEditorButton( - runnableId = 1, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) public Position overlayPosition = new Position(10, 100); @Expose @@ -261,15 +243,6 @@ public class Mining { public boolean crystalHollowOverlay = true; @Expose - @ConfigOption( - name = "Edit Crystal Overlay Position", - desc = "Change the position of the Crystal Hollows Overlay." - ) - @ConfigEditorButton( - runnableId = 10, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 4) public Position crystalHollowOverlayPosition = new Position(200, 0); @Expose @@ -290,13 +263,13 @@ public class Mining { "\u00a73Electron Transmitter: \u00a7aDone\n" + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + - "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Synthetic Heart: \u00a7cMissing\n" + "\u00a73Control Switch: \u00a7cMissing\n" + "\u00a73FTX 3070: \u00a7cMissing", "\u00a73Electron Transmitter: \u00a7a3\n" + "\u00a73Robotron Reflector: \u00a7e2\n" + "\u00a73Superlite Motor: \u00a7e1\n" + - "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Synthetic Heart: \u00a7c0\n" + "\u00a73Control Switch: \u00a7c0\n" + "\u00a73FTX 3070: \u00a7c0", "\u00a73Automaton parts: \u00a7a5/6", @@ -753,15 +726,6 @@ public class Mining { public List<Integer> powderGrindingTrackerText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6)); @Expose - @ConfigOption( - name = "Edit Tracker Position", - desc = "Change the position of the Powder Grinding Tracker Overlay (chests and gained powder)" - ) - @ConfigEditorButton( - runnableId = 25, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 9) public Position powderGrindingTrackerPosition = new Position(10, 265); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index e73614d1..714dd7b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -410,15 +410,6 @@ public class MiscOverlays { public int defaultColour = 15; @Expose - @ConfigOption( - name = "Edit Todo Overlay Position", - desc = "Change the position of the Todo overlay" - ) - @ConfigEditorButton( - runnableId = 5, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 0) public Position todoPosition = new Position(100, 0); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java index 6f0d5341..fce1f9af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java @@ -41,14 +41,6 @@ public class PetOverlay { public boolean enablePetInfo = false; @Expose - @ConfigOption( - name = "Edit Pet Info Position", - desc = "Change the position of the pet info overlay" - ) - @ConfigEditorButton( - runnableId = 4, - buttonText = "Edit" - ) public Position petInfoPosition = new Position(-1, -1); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java index 951438fb..30915daa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java @@ -74,10 +74,11 @@ public class ProfileViewer { "\u00a7eBingo", "\u00a7eTrophy Fish", "\u00a7eBestiary", + "\u00a7eCrimson Isle", }, allowDeleting = false ) - public List<Integer> pageLayout = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); + public List<Integer> pageLayout = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); @Expose @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java index 2925887f..db0a0e94 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java @@ -112,15 +112,6 @@ public class SkillOverlays { public int farmingPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Farming Overlay Position", - desc = "Change the position of the Farming overlay" - ) - @ConfigEditorButton( - runnableId = 3, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 0) public Position farmingPosition = new Position(10, 200); @Expose @@ -184,15 +175,6 @@ public class SkillOverlays { public int miningPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Mining Overlay Position", - desc = "Change the position of the Mining overlay" - ) - @ConfigEditorButton( - runnableId = 11, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 1) public Position miningPosition = new Position(10, 200); @Expose @@ -258,15 +240,6 @@ public class SkillOverlays { public int fishingPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Fishing Overlay Position", - desc = "Change the position of the Fishing overlay" - ) - @ConfigEditorButton( - runnableId = 14, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) public Position fishingPosition = new Position(10, 200); @Expose @@ -366,15 +339,6 @@ public class SkillOverlays { public int combatPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Combat Overlay Position", - desc = "Change the position of the Combat overlay" - ) - @ConfigEditorButton( - runnableId = 19, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 4) public Position combatPosition = new Position(10, 200); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java index 927d00e5..25bd680b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java @@ -78,14 +78,6 @@ public class SlayerOverlay { public List<Integer> slayerText = new ArrayList<>(Arrays.asList(0, 1, 4, 5, 3, 6)); @Expose - @ConfigOption( - name = "Edit Slayer Overlay Position", - desc = "Change the position of the Slayer overlay" - ) - @ConfigEditorButton( - runnableId = 18, - buttonText = "Edit" - ) public Position slayerPosition = new Position(10, 200); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java index d180efcf..a70035f1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -92,8 +93,12 @@ public class FuelBar { @SubscribeEvent public void onRenderScreen(RenderGameOverlayEvent.Post event) { - if (fuelAmount < 0) return; - if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + if (!GuiPositionEditor.renderDrill) { + if (fuelAmount < 0) return; + if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + } else { + fuelAmount = .3f; + } if (event.type == RenderGameOverlayEvent.ElementType.ALL) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java new file mode 100644 index 00000000..f1cf4878 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java @@ -0,0 +1,47 @@ +/* + * 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.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import org.lwjgl.util.vector.Vector2f; + +import java.util.List; +import java.util.function.Supplier; + +public class FuelBarDummy extends TextOverlay { + public FuelBarDummy( + Position position, + Supplier<List<String>> dummyStrings, + Supplier<TextOverlayStyle> styleSupplier + ) { + super(position, dummyStrings, styleSupplier); + super.shouldRenderInGuiEditor = false; + } + + @Override + public void update() { + + } + @Override + public Vector2f getDummySize() { + return new Vector2f(NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java new file mode 100644 index 00000000..9b00829a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java @@ -0,0 +1,47 @@ +/* + * 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.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import org.lwjgl.util.vector.Vector2f; + +import java.util.List; +import java.util.function.Supplier; + +public class MapDummy extends TextOverlay { + public MapDummy( + Position position, + Supplier<List<String>> dummyStrings, + Supplier<TextOverlayStyle> styleSupplier + ) { + super(position, dummyStrings, styleSupplier); + } + + @Override + public void update() { + } + + @Override + public Vector2f getDummySize() { + int mapSize = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); + return new Vector2f(mapSize, mapSize); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index 5047882d..edb86337 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; public class OverlayManager { - public static Class<? extends TextOverlay> dontRenderOverlay = null; + public static ArrayList<Class<? extends TextOverlay>> dontRenderOverlay = new ArrayList<>(); public static MiningOverlay miningOverlay; public static PowderGrindingOverlay powderGrindingOverlay; @@ -40,6 +40,7 @@ public class OverlayManager { public static BonemerangOverlay bonemerangOverlay; public static CrystalHollowOverlay crystalHollowOverlay; public static SlayerOverlay slayerOverlay; + public static FuelBarDummy fuelBar; public static final List<TextOverlay> textOverlays = new ArrayList<>(); static { @@ -254,13 +255,13 @@ public class OverlayManager { "\u00a73Electron Transmitter: \u00a7aDone\n" + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + - "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Synthetic Heart: \u00a7cMissing\n" + "\u00a73Control Switch: \u00a7cMissing\n" + "\u00a73FTX 3070: \u00a7cMissing", "\u00a73Electron Transmitter: \u00a7a3\n" + "\u00a73Robotron Reflector: \u00a7e2\n" + "\u00a73Superlite Motor: \u00a7e1\n" + - "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Synthetic Heart: \u00a7c0\n" + "\u00a73Control Switch: \u00a7c0\n" + "\u00a73FTX 3070: \u00a7c0", "\u00a73Automaton parts: \u00a7a5/6", @@ -313,6 +314,15 @@ public class OverlayManager { return TextOverlayStyle.BACKGROUND; }); + List<String> fuelDummy = Lists.newArrayList( + "\u00a73This is a fuel bar" + ); + fuelBar = new FuelBarDummy(NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition, () -> { + List<String> strings = new ArrayList<>(); + strings.add(fuelDummy.get(0)); + return strings; + }, () -> TextOverlayStyle.BACKGROUND); + textOverlays.add(miningOverlay); textOverlays.add(powderGrindingOverlay); textOverlays.add(farmingOverlay); @@ -323,6 +333,7 @@ public class OverlayManager { textOverlays.add(bonemerangOverlay); textOverlays.add(crystalHollowOverlay); textOverlays.add(slayerOverlay); + textOverlays.add(fuelBar); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index f8e02fef..7884b2ac 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -43,6 +43,8 @@ public abstract class TextOverlay { public boolean shouldUpdateFrequent = false; + public boolean shouldRenderInGuiEditor = true; + private static final int PADDING_X = 5; private static final int PADDING_Y = 5; @@ -127,6 +129,10 @@ public abstract class TextOverlay { return new Vector2f(x, y); } + public Position getPosition() { + return position; + } + protected void renderLine(String line, Vector2f position, boolean dummy) { } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java new file mode 100644 index 00000000..f9d91935 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java @@ -0,0 +1,403 @@ +/* + * 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.profileviewer; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +public class CrimsonIslePage extends GuiProfileViewerPage { + + private static final ResourceLocation CRIMSON_ISLE = + new ResourceLocation("notenoughupdates:pv_crimson_isle_page.png"); + + private static final DateFormat dateFormat = new SimpleDateFormat("EEE d MMM yyyy"); + private static final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); + private static final String[] dojoGrades = {"F", "D", "C", "B", "A", "S"}; + + private static final ItemStack[] KUUDRA_KEYS = { + NotEnoughUpdates.INSTANCE.manager.createItem("KUUDRA_TIER_KEY"), + NotEnoughUpdates.INSTANCE.manager.createItem("KUUDRA_HOT_TIER_KEY"), + NotEnoughUpdates.INSTANCE.manager.createItem("KUUDRA_BURNING_TIER_KEY"), + NotEnoughUpdates.INSTANCE.manager.createItem("KUUDRA_FIERY_TIER_KEY"), + NotEnoughUpdates.INSTANCE.manager.createItem("KUUDRA_INFERNAL_TIER_KEY"), + }; + + public static final String[] KUUDRA_TIERS = { + "Basic", + "Hot", + "Burning", + "Fiery", + "Infernal" + }; + + private static final LinkedHashMap<String, String> apiDojoTestNames = new LinkedHashMap<String, String>() {{ + put("mob_kb", EnumChatFormatting.GOLD + "Test of Force"); + put("wall_jump", EnumChatFormatting.LIGHT_PURPLE + "Test of Stamina"); + put("archer", EnumChatFormatting.YELLOW + "Test of Mastery"); + put("sword_swap", EnumChatFormatting.RED + "Test of Discipline"); + put("snake", EnumChatFormatting.GREEN + "Test of Swiftness"); + put("lock_head", EnumChatFormatting.BLUE + "Test of Control"); + put("fireball", EnumChatFormatting.GOLD + "Test of Tenacity"); + }}; + + private static final LinkedHashMap<Integer, String> dojoPointsToRank = new LinkedHashMap<Integer, String>() {{ + put(0, EnumChatFormatting.GRAY + "None"); + put(1000, EnumChatFormatting.YELLOW + "Yellow"); + put(2000, EnumChatFormatting.GREEN + "Green"); + put(4000, EnumChatFormatting.BLUE + "Blue"); + put(6000, EnumChatFormatting.GOLD + "Brown"); + put(7000, EnumChatFormatting.DARK_GRAY + "Black"); + }}; + + private static final HashMap<String, String> factions = new HashMap<String, String>() {{ + put("mages", EnumChatFormatting.DARK_PURPLE + "Mages"); + put("barbarians", EnumChatFormatting.RED + "Barbarians"); + put("N/A", EnumChatFormatting.GRAY + "N/A"); + }}; + + private static final LinkedHashMap<Integer, String> factionThresholds = new LinkedHashMap<Integer, String>() {{ + put(-3000, "Hostile"); + put(-1000, "Unfriendly"); + put(0, "Neutral"); + put(1000, "Friendly"); + put(3000, "Trusted"); + put(6000, "Honored"); + put(12000, "Hero"); + }}; + + public CrimsonIslePage(GuiProfileViewer instance) { + super(instance); + } + + @Override + public void drawPage(int mouseX, int mouseY, float partialTicks) { + int guiLeft = GuiProfileViewer.getGuiLeft(); + int guiTop = GuiProfileViewer.getGuiTop(); + + JsonObject profileInfo = GuiProfileViewer.getProfile().getProfileInformation(GuiProfileViewer.getProfileId()); + + if (profileInfo == null || !profileInfo.has("nether_island_player_data")) { + Utils.drawStringCentered( + EnumChatFormatting.RED + "No data found for the Crimson Isles", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 431 / 2f, + guiTop + 101, + true, + 0 + ); + return; + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(CRIMSON_ISLE); + Utils.drawTexturedRect(guiLeft, guiTop, 431, 202, GL11.GL_NEAREST); + + JsonObject netherIslandPlayerData = profileInfo.getAsJsonObject("nether_island_player_data"); + + // Dojo stats + drawDojoStats(netherIslandPlayerData, guiLeft, guiTop); + + // Kuudra stats + drawKuudraStats(netherIslandPlayerData, guiLeft, guiTop); + + // Last matriarch attempt + drawLastMatriarchAttempt(netherIslandPlayerData, guiLeft, guiTop); + + // Faction reputation + drawFactionReputation(netherIslandPlayerData, guiLeft, guiTop); + } + + public void drawKuudraStats(JsonObject data, int guiLeft, int guiTop) { + Utils.drawStringCentered( + EnumChatFormatting.RED + "Kuudra Stats", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + (431 * 0.18f), + guiTop + 14, + true, + 0 + ); + + JsonObject kuudraCompletedTiers = data.getAsJsonObject("kuudra_completed_tiers"); + + // This is different to the one initialised at the start of the class as these refer to the names of the tiers in the API + String[] kuudraTiers = {"none", "hot", "burning", "fiery", "infernal"}; + + RenderHelper.enableGUIStandardItemLighting(); + + for (int i = 0; i < 5; i++) { + // Checking the player has completions for each tier + // and get the number of completions if they do + int completions = + kuudraCompletedTiers.has(kuudraTiers[i]) ? kuudraCompletedTiers.get(kuudraTiers[i]).getAsInt() : 0; + + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI( + KUUDRA_KEYS[i], + guiLeft + 8, + guiTop + 25 + (i * 12) + ); + + Utils.renderAlignedString( + EnumChatFormatting.RED + KUUDRA_TIERS[i] + ": ", + EnumChatFormatting.WHITE + String.valueOf(completions), + guiLeft + 23, + guiTop + 30 + (i * 12), + 110 + ); + } + + Utils.renderAlignedString( + EnumChatFormatting.RED + "Total: ", + EnumChatFormatting.WHITE + String.valueOf(getTotalKuudraRuns(kuudraCompletedTiers)), + guiLeft + 23, + guiTop + 40 + (5 * 12), + 110 + ); + } + + public int getTotalKuudraRuns(JsonObject completedRuns) { + int totalRuns = 0; + for (Map.Entry<String, JsonElement> runs : completedRuns.entrySet()) { + totalRuns += runs.getValue().getAsInt(); + } + return totalRuns; + } + + public void drawDojoStats(JsonObject data, int guiLeft, int guiTop) { + Utils.drawStringCentered( + EnumChatFormatting.YELLOW + "Dojo Stats", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + (431 * 0.49f), + guiTop + 14, + true, + 0 + ); + + JsonObject dojoStats = data.getAsJsonObject("dojo"); + int[] dojoScores = {0, 0, 0, 0, 0, 0, 0}; + int pointsTotal = 0; + + for (int i = 0; i < apiDojoTestNames.size(); i++) { + for (Map.Entry<String, JsonElement> dojoData : dojoStats.entrySet()) { + if (dojoData.getKey().equals("dojo_points_" + apiDojoTestNames.keySet().toArray()[i])) { + dojoScores[i] = dojoData.getValue().getAsInt(); + pointsTotal += dojoData.getValue().getAsInt(); + } + } + } + + for (int i = 0; i < apiDojoTestNames.size(); i++) { + Utils.renderAlignedString( + apiDojoTestNames.get(apiDojoTestNames.keySet().toArray()[i]) + ": ", + EnumChatFormatting.WHITE + String.valueOf(dojoScores[i]) + " (" + + dojoGrades[(dojoScores[i] / 200) >= 6 ? 5 : (dojoScores[i] / 200)] + ")", + guiLeft + (431 * 0.49f) - 65, + guiTop + 30 + (i * 12), + 130 + ); + } + + Utils.renderAlignedString( + EnumChatFormatting.GRAY + "Points: ", + EnumChatFormatting.GOLD + String.valueOf(pointsTotal), + guiLeft + (431 * 0.49f) - 65, + guiTop + 40 + (apiDojoTestNames.size() * 12), + 130 + ); + + Utils.renderAlignedString( + EnumChatFormatting.GRAY + "Rank: ", + getRank(pointsTotal), + guiLeft + (431 * 0.49f) - 65, + guiTop + 52 + (apiDojoTestNames.size() * 12), + 130 + ); + + Utils.renderAlignedString( + EnumChatFormatting.GRAY + "Points to next: ", + getPointsToNextRank(pointsTotal) == 0 + ? EnumChatFormatting.GOLD + "MAXED!" + : String.valueOf(getPointsToNextRank(pointsTotal)), + guiLeft + (431 * 0.49f) - 65, + guiTop + 64 + (apiDojoTestNames.size() * 12), + 130 + ); + } + + public String getRank(int points) { + int lastRank = 0; + for (Map.Entry<Integer, String> rank : dojoPointsToRank.entrySet()) { + if (points < rank.getKey()) { + return dojoPointsToRank.get(lastRank); + } + lastRank = rank.getKey(); + } + return dojoPointsToRank.get(dojoPointsToRank.keySet().toArray()[dojoPointsToRank.size() - 1]); + } + + public int getPointsToNextRank(int pointsTotal) { + int pointsToNextRank = 0; + for (Map.Entry<Integer, String> dojoRank : dojoPointsToRank.entrySet()) { + if (dojoRank.getKey() > pointsTotal) { + pointsToNextRank = dojoRank.getKey(); + break; + } + } + return pointsToNextRank == 0 ? 0 : pointsToNextRank - pointsTotal; + } + + public void drawLastMatriarchAttempt(JsonObject data, int guiLeft, int guiTop) { + Utils.drawStringCentered( + EnumChatFormatting.GOLD + "Last Matriarch Attempt", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + (431 * 0.82f), + guiTop + 104, + true, + 0 + ); + + JsonObject lastMatriarchAttempt = data.getAsJsonObject("matriarch"); + + if (!lastMatriarchAttempt.entrySet().isEmpty()) { + Utils.renderAlignedString( + EnumChatFormatting.GOLD + "Heavy Pearls Acquired: ", + EnumChatFormatting.WHITE + lastMatriarchAttempt.get("pearls_collected").getAsString(), + guiLeft + 290, + guiTop + 119, + 130 + ); + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(lastMatriarchAttempt.get("last_attempt").getAsLong()); + String date = dateFormat.format(calendar.getTime()); + String time = timeFormat.format(calendar.getTime()); + + Utils.renderAlignedString( + EnumChatFormatting.GOLD + "Last Attempt: ", + EnumChatFormatting.WHITE + date, + guiLeft + 290, + guiTop + 131, + 130 + ); + + Utils.renderAlignedString( + EnumChatFormatting.GOLD + " ", + EnumChatFormatting.WHITE + time, + guiLeft + 290, + guiTop + 143, + 130 + ); + return; + } + + Utils.renderAlignedString( + EnumChatFormatting.RED + "No attempts found!", + " ", + guiLeft + 290, + guiTop + 119, + 130 + ); + } + + public void drawFactionReputation(JsonObject data, int guiLeft, int guiTop) { + Utils.drawStringCentered( + EnumChatFormatting.DARK_PURPLE + "Faction Reputation", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + (431 * 0.82f), + guiTop + 14, + true, + 0 + ); + + String selectedFaction = data.has("selected_faction") ? data.get("selected_faction").getAsString() : "N/A"; + + Utils.renderAlignedString( + EnumChatFormatting.GREEN + "Faction: ", + factions.get(selectedFaction), + guiLeft + 290, + guiTop + 30, + 130 + ); + + int mageReputation = data.has("mages_reputation") ? data.get("mages_reputation").getAsInt() : 0; + int barbarianReputation = data.has("barbarians_reputation") ? data.get("barbarians_reputation").getAsInt() : 0; + + // Mage reputation + int mageReputationThreshold = 0; + for (Map.Entry<Integer, String> factionThreshold : factionThresholds.entrySet()) { + if (mageReputation >= factionThreshold.getKey()) { + mageReputationThreshold = factionThreshold.getKey(); + } + } + + Utils.renderAlignedString( + EnumChatFormatting.DARK_PURPLE + "Mage Reputation: ", + EnumChatFormatting.WHITE + String.valueOf(mageReputation), + guiLeft + 290, + guiTop + 42 + (selectedFaction.equals("mages") || selectedFaction.equals("N/A") ? 0 : 24), + 130 + ); + + Utils.renderAlignedString( + EnumChatFormatting.DARK_PURPLE + "Title: ", + EnumChatFormatting.WHITE + factionThresholds.get(mageReputationThreshold), + guiLeft + 290, + guiTop + 54 + (selectedFaction.equals("mages") || selectedFaction.equals("N/A") ? 0 : 24), + 130 + ); + + // Barbarian reputation + int barbarianReputationThreshold = 0; + for (Map.Entry<Integer, String> factionThreshold : factionThresholds.entrySet()) { + if (barbarianReputation >= factionThreshold.getKey()) { + barbarianReputationThreshold = factionThreshold.getKey(); + } + } + + Utils.renderAlignedString( + EnumChatFormatting.RED + "Barbarian Reputation: ", + EnumChatFormatting.WHITE + String.valueOf(barbarianReputation), + guiLeft + 290, + guiTop + 42 + (selectedFaction.equals("barbarians") ? 0 : 24), + 130 + ); + + Utils.renderAlignedString( + EnumChatFormatting.RED + "Title: ", + EnumChatFormatting.WHITE + factionThresholds.get(barbarianReputationThreshold), + guiLeft + 290, + guiTop + 54 + (selectedFaction.equals("barbarians") ? 0 : 24), + 130 + ); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 37605595..cc13e820 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -218,6 +218,7 @@ public class GuiProfileViewer extends GuiScreen { pages.put(ProfileViewerPage.BINGO, new BingoPage(this)); pages.put(ProfileViewerPage.TROPHY_FISH, new TrophyFishPage(this)); pages.put(ProfileViewerPage.BESTIARY, new BestiaryPage(this)); + pages.put(ProfileViewerPage.CRIMSON_ISLE, new CrimsonIslePage(this)); } private static float getMaxLevelXp(JsonArray levels, int offset, int maxLevel) { @@ -1314,7 +1315,8 @@ public class GuiProfileViewer extends GuiScreen { MINING(6, Items.iron_pickaxe, "§5Heart of the Mountain"), BINGO(7, Items.filled_map, "§zBingo"), TROPHY_FISH(8, Items.fishing_rod, "§3Trophy Fish"), - BESTIARY(9, Items.iron_sword, "§cBestiary"); + BESTIARY(9, Items.iron_sword, "§cBestiary"), + CRIMSON_ISLE(10, Item.getItemFromBlock(Blocks.netherrack), "§4Crimson Isle"); public final ItemStack stack; public final int id; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java index b4f1da30..a981183a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java @@ -127,6 +127,7 @@ public class InventoriesPage extends GuiProfileViewerPage { ProfileViewer.Profile profile = GuiProfileViewer.getProfile(); String profileId = GuiProfileViewer.getProfileId(); JsonObject inventoryInfo = profile.getInventoryInfo(profileId); + JsonObject profileInformation = profile.getProfileInformation(profileId); if (inventoryInfo == null) return; int invNameIndex = 0; @@ -153,7 +154,7 @@ public class InventoriesPage extends GuiProfileViewerPage { getInstance().tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false); if (Objects.equals(entry.getKey(), "talisman_bag")) { StringBuilder magicalPowerString = new StringBuilder(EnumChatFormatting.DARK_GRAY + "Magical Power: "); - int magicalPower = PlayerStats.getMagicalPower(inventoryInfo); + int magicalPower = PlayerStats.getMagicalPower(inventoryInfo, profileInformation); getInstance() .tooltipToDisplay.add( magicalPower == -1 diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java index b0cc930a..c5a17aef 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -657,7 +657,7 @@ public class PlayerStats { * @return the amount of Magical Power or -1 * @see io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer.Profile#getInventoryInfo(String) */ - public static int getMagicalPower(JsonObject inventoryInfo) { + public static int getMagicalPower(JsonObject inventoryInfo, JsonObject profileInfo) { if (inventoryInfo == null || !inventoryInfo.has("talisman_bag") || !inventoryInfo.get("talisman_bag").isJsonArray()) { return -1; } @@ -705,6 +705,16 @@ public class PlayerStats { break; } } + if (entry.getKey().equals("ABICASE")) { + if (profileInfo.has("nether_island_player_data") && + profileInfo.get("nether_island_player_data").getAsJsonObject().has("abiphone") && profileInfo.get( + "nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().has("active_contacts")) { // BatChest + int contact = + profileInfo.get("nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().get( + "active_contacts").getAsJsonArray().size(); + powderAmount += Math.floor(contact / 2); + } + } switch (entry.getValue()) { case 0: case 6: diff --git a/src/main/resources/assets/notenoughupdates/pv_crimson_isle_page.png b/src/main/resources/assets/notenoughupdates/pv_crimson_isle_page.png Binary files differnew file mode 100644 index 00000000..b08c0057 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/pv_crimson_isle_page.png diff --git a/src/main/resources/assets/notenoughupdates/wither_cloak_shield.png b/src/main/resources/assets/notenoughupdates/wither_cloak_shield.png Binary files differnew file mode 100644 index 00000000..76cdecfe --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/wither_cloak_shield.png diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 53595874..a0865bed 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -51,6 +51,7 @@ "AccessorGuiContainer", "AccessorGuiEditSign", "AccessorMinecraft", + "MixinEntityChargedCreeper", "MixinGuiEditSign", "MixinGuiTextField" ] |