From ca13cc0c881480a8d3f0d653eab937f336fd870e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 21 Jan 2021 02:41:02 +0800 Subject: PRE8 --- .../notenoughupdates/NEUEventListener.java | 64 ++- .../notenoughupdates/NotEnoughUpdates.java | 5 +- .../notenoughupdates/core/GuiElementBoolean.java | 2 +- .../notenoughupdates/core/config/Config.java | 4 + .../notenoughupdates/core/config/Position.java | 114 +++++ .../config/annotations/ConfigEditorButton.java | 15 + .../core/config/gui/GuiOptionEditorButton.java | 66 +++ .../core/config/gui/GuiOptionEditorDropdown.java | 16 +- .../core/config/gui/GuiPositionEditor.java | 109 ++++ .../core/config/struct/ConfigProcessor.java | 4 + .../notenoughupdates/cosmetics/CapeManager.java | 4 +- .../notenoughupdates/cosmetics/NEUCape.java | 14 +- .../notenoughupdates/dungeons/DungeonMap.java | 7 +- .../dungeons/GuiDungeonMapEditor.java | 111 ++--- .../miscfeatures/CommissionOverlay.java | 164 ++++++ .../miscfeatures/CrystalOverlay.java | 327 ++++++++++++ .../miscfeatures/CustomItemEffects.java | 29 +- .../miscfeatures/DwarvenMinesTextures.java | 90 ++++ .../notenoughupdates/miscfeatures/FairySouls.java | 2 + .../miscfeatures/ItemCooldowns.java | 135 +++++ .../notenoughupdates/miscfeatures/MiningStuff.java | 2 - .../miscgui/AccessoryBagOverlay.java | 36 +- .../mixins/MixinEffectRenderer.java | 39 +- .../notenoughupdates/mixins/MixinItemStack.java | 1 + .../mixins/MixinNetHandlerPlayClient.java | 2 + .../mixins/MixinPlayerControllerMP.java | 2 + .../notenoughupdates/mixins/MixinRenderItem.java | 55 +- .../notenoughupdates/options/NEUConfig.java | 167 ++++++- .../notenoughupdates/options/NEUConfigEditor.java | 2 +- .../profileviewer/ProfileViewer.java | 5 +- .../notenoughupdates/textoverlays/TextOverlay.java | 90 ++++ .../textoverlays/TextOverlayStyle.java | 10 + .../util/ReverseWorldRenderer.java | 552 +++++++++++++++++++++ .../moulberry/notenoughupdates/util/Utils.java | 11 +- .../assets/notenoughupdates/capes/furf.png | Bin 10380 -> 15699 bytes .../assets/notenoughupdates/capes/furf_preview.png | Bin 0 -> 11892 bytes 36 files changed, 2067 insertions(+), 189 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CommissionOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlayStyle.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java create mode 100644 src/main/resources/assets/notenoughupdates/capes/furf_preview.png diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index e0a487b6..59d71520 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -3,20 +3,20 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; +import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; -import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; -import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; -import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; +import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.textoverlays.TextOverlay; +import io.github.moulberry.notenoughupdates.textoverlays.TextOverlayStyle; +import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.RequestFocusListener; import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -58,8 +58,8 @@ import java.awt.datatransfer.StringSelection; import java.io.File; import java.io.IOException; import java.text.NumberFormat; -import java.util.*; import java.util.List; +import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -71,7 +71,7 @@ import static io.github.moulberry.notenoughupdates.util.GuiTextures.dungeon_ches public class NEUEventListener { - private NotEnoughUpdates neu; + private final NotEnoughUpdates neu; private boolean hoverInv = false; private boolean focusInv = false; @@ -135,16 +135,26 @@ public class NEUEventListener { private long notificationDisplayMillis = 0; private List notificationLines = null; - private static Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); + private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); + + public static Class dontRenderOverlay = null; + private final List textOverlays = new ArrayList<>(); + { + textOverlays.add(new CommissionOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> { + int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; + if(style >= 0 && style < TextOverlayStyle.values().length) { + return TextOverlayStyle.values()[style]; + } + return TextOverlayStyle.BACKGROUND; + })); + } /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. * 2)Adds unique items to the collection log */ - private HashMap newItemAddMap = new HashMap<>(); private long lastLongUpdate = 0; - private long lastVeryLongUpdate = 0; private long lastSkyblockScoreboard = 0; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { @@ -163,7 +173,12 @@ public class NEUEventListener { } DungeonWin.tick(); if(longUpdate) { + CrystalOverlay.tick(); + DwarvenMinesTextures.tick(); FairySouls.tick(); + for(TextOverlay overlay : textOverlays) { + overlay.tick(); + } if(TradeWindow.hypixelTradeWindowActive()) { for(int i=0; i<16; i++) { int x = i % 4; @@ -270,8 +285,8 @@ public class NEUEventListener { neu.manager.auctionManager.markNeedsUpdate(); } } - if(longUpdate && neu.hasSkyblockScoreboard()) { - /*if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { + /*if(longUpdate && neu.hasSkyblockScoreboard()) { + if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { ProfileViewer.Profile profile = NotEnoughUpdates.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), callback->{}); if(profile != null) { @@ -324,11 +339,11 @@ public class NEUEventListener { } } newItemAddMap.keySet().retainAll(newItem); - }*/ - } + } + }*/ } - private void processUniqueStack(ItemStack stack, HashSet newItem) { + /*private void processUniqueStack(ItemStack stack, HashSet newItem) { if(stack != null && stack.hasTagCompound()) { String internalname = neu.manager.getInternalNameForItem(stack); if(internalname != null) { @@ -344,13 +359,13 @@ public class NEUEventListener { } else { newItemAddMap.put(internalname, System.currentTimeMillis()); } - }*/ + } } } - } + }*/ @SubscribeEvent(priority= EventPriority.HIGHEST) - public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre event) { + public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre event) { if(Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) { if(((GuiProfileViewer)Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) { event.setCanceled(true); @@ -371,6 +386,13 @@ public class NEUEventListener { long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); if(event.type == RenderGameOverlayEvent.ElementType.ALL) { DungeonWin.render(event.partialTicks); + for(TextOverlay overlay : textOverlays) { + if(dontRenderOverlay != null && dontRenderOverlay.isAssignableFrom(overlay.getClass())) { + continue; + } + overlay.render(); + } + dontRenderOverlay = null; } if(event.type == RenderGameOverlayEvent.ElementType.ALL && timeRemaining > 0 && notificationLines != null && notificationLines.size() > 0) { @@ -393,7 +415,7 @@ public class NEUEventListener { Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2, midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8); - Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2+3, + Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2f+3, topY+3, 0xFF000000, false); Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj, @@ -542,7 +564,6 @@ public class NEUEventListener { } } }, 200, TimeUnit.MILLISECONDS); - return; } } } @@ -653,7 +674,6 @@ public class NEUEventListener { focusInv = true; } } catch(NullPointerException npe) { - npe.printStackTrace(); focusInv = !hoverPane; } } @@ -1609,7 +1629,7 @@ public class NEUEventListener { } } }*/ - if(!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)/* || /*!neu.config.hidden.dev*/) return; + if(!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || !neu.config.hidden.dev) return; if(event.toolTip.size()>0&&event.toolTip.get(event.toolTip.size()-1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) { event.toolTip.remove(event.toolTip.size()-1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 6b787964..ad42fcfd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -99,7 +99,7 @@ public class NotEnoughUpdates { //Stolen from Biscut and used for detecting whether in skyblock private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58"); - private GuiScreen openGui = null; + public GuiScreen openGui = null; SimpleCommand collectionLogCommand = new SimpleCommand("neucl", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { @@ -903,6 +903,9 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new SunTzu()); MinecraftForge.EVENT_BUS.register(new MiningStuff()); MinecraftForge.EVENT_BUS.register(new FairySouls()); + MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); + MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); ClientCommandHandler.instance.registerCommand(collectionLogCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java index 85f88a9f..bfd95612 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java @@ -103,7 +103,7 @@ public class GuiElementBoolean extends GuiElement { if(Mouse.getEventButton() == 0) { if(Mouse.getEventButtonState()) { previewValue = !value; - } else { + } else if(previewValue == !value) { value = !value; toggleCallback.accept(value); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java index 572c9af6..8be828bd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java @@ -1,4 +1,8 @@ package io.github.moulberry.notenoughupdates.core.config; public class Config { + + public void executeRunnable(int runnableId) { + } + } 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 new file mode 100644 index 00000000..b30aa680 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -0,0 +1,114 @@ +package io.github.moulberry.notenoughupdates.core.config; + +import com.google.gson.annotations.Expose; +import net.minecraft.client.gui.ScaledResolution; + +public class Position { + + @Expose + private int x; + @Expose + private int y; + + public Position(int x, int y) { + this.x = x; + this.y = y; + } + + public Position clone() { + return new Position(x, y); + } + + public int getRawX() { + return x; + } + + public int getRawY() { + return y; + } + + public int getAbsX(ScaledResolution scaledResolution) { + if(x < 0) { + return scaledResolution.getScaledWidth() + x; + } else { + return x; + } + } + + public int getAbsY(ScaledResolution scaledResolution) { + if(y < 0) { + return scaledResolution.getScaledHeight() + y; + } else { + return y; + } + } + + public int moveX(int deltaX, int objWidth, ScaledResolution scaledResolution) { + int screenWidth = scaledResolution.getScaledWidth(); + boolean wasPositiveX = this.x >= 0; + this.x += deltaX; + + if(wasPositiveX) { + if(this.x < 2) { + deltaX += 2-this.x; + this.x = 2; + } + if(this.x > screenWidth-2) { + deltaX += screenWidth-2-this.x; + this.x = screenWidth-2; + } + } else { + if(this.x+objWidth > -2) { + deltaX += -2-objWidth-this.x; + this.x = -2-objWidth; + } + if(this.x+screenWidth < 2) { + deltaX += 2-screenWidth-this.x; + this.x = 2-screenWidth; + } + } + + if(this.x >= 0 && this.x+objWidth/2 > screenWidth/2) { + this.x -= screenWidth; + } + if(this.x < 0 && this.x+objWidth/2 <= -screenWidth/2) { + this.x += screenWidth; + } + return deltaX; + } + + public int moveY(int deltaY, int objHeight, ScaledResolution scaledResolution) { + int screenHeight = scaledResolution.getScaledHeight(); + boolean wasPositiveY = this.y >= 0; + this.y += deltaY; + + if(wasPositiveY) { + if(this.y < 2) { + deltaY += 2-this.y; + this.y = 2; + } + if(this.y > screenHeight-2) { + deltaY += screenHeight-2-this.y; + this.y = screenHeight-2; + } + } else { + if(this.y+objHeight > -2) { + deltaY += -2-objHeight-this.y; + this.y = -2-objHeight; + } + if(this.y+screenHeight < 2) { + deltaY += 2-screenHeight-this.y; + this.y = 2-screenHeight; + } + } + + if(this.y >= 0 && this.y-objHeight/2 > screenHeight/2) { + this.y -= screenHeight; + } + if(this.y < 0 && this.y-objHeight/2 <= -screenHeight/2) { + this.y += screenHeight; + } + return deltaY; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java new file mode 100644 index 00000000..5fe7fcb4 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java @@ -0,0 +1,15 @@ +package io.github.moulberry.notenoughupdates.core.config.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ConfigEditorButton { + + int runnableId(); + String buttonText() default ""; + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java new file mode 100644 index 00000000..03a01ef2 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java @@ -0,0 +1,66 @@ +package io.github.moulberry.notenoughupdates.core.config.gui; + +import io.github.moulberry.notenoughupdates.core.ChromaColour; +import io.github.moulberry.notenoughupdates.core.config.Config; +import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.ClientCommandHandler; +import org.lwjgl.input.Mouse; + +import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex; +import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white; + +public class GuiOptionEditorButton extends GuiOptionEditor { + + private int runnableId; + private String buttonText; + private Config config; + + public GuiOptionEditorButton(ConfigProcessor.ProcessedOption option, int runnableId, String buttonText, Config config) { + super(option); + this.runnableId = runnableId; + this.config = config; + + this.buttonText = buttonText; + if(this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null; + } + + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + + int height = getHeight(); + + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); + RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16); + + if(buttonText != null) { + TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj, + x+width/6, y+height-7-6, + false, 44, 0xFF303030); + } + } + + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + if(Mouse.getEventButtonState()) { + int height = getHeight(); + if(mouseX > x+width/6-24 && mouseX < x+width/6+24 && + mouseY > y+height-7-14 && mouseY < y+height-7+2) { + config.executeRunnable(runnableId); + return true; + } + } + + return false; + } + + @Override + public boolean keyboardInput() { + return false; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java index 20779e01..a3e36919 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java @@ -41,11 +41,11 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { selectedString = values[selected]; } - RenderUtils.drawFloatingRectWithAlpha(left, top, dropdownWidth, 14, 0xff, false); - TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xff404040, 2); + RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); + TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2); TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false, - dropdownWidth-16, 0xff404040); + dropdownWidth-16, 0xffa0a0a0); //fr.drawString(selectedString, left+3, top+3, 0xff404040); } } @@ -67,8 +67,8 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { int dropdownHeight = 13 + 12*values.length; - int main = 0xffc0c0c0; - int blue = 0xff3365bd; + int main = 0xff202026; + int blue = 0xff2355ad; Gui.drawRect(left, top, left+1, top+dropdownHeight, blue); //Left Gui.drawRect(left+1, top, left+dropdownWidth, top+1, blue); //Top Gui.drawRect(left+dropdownWidth-1, top+1, left+dropdownWidth, top+dropdownHeight, blue); //Right @@ -82,15 +82,15 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { if(option.isEmpty()) { option = ""; } - TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xff404040); + TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0); dropdownY += 12; } - TextRenderUtils.drawStringScaled("\u25B2", fr, left+dropdownWidth-10, y+height-7-15, false, 0xff404040, 2); + TextRenderUtils.drawStringScaled("\u25B2", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2); TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false, - dropdownWidth-16, 0xff404040); + dropdownWidth-16, 0xffa0a0a0); } } 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 new file mode 100644 index 00000000..117a97bd --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -0,0 +1,109 @@ +package io.github.moulberry.notenoughupdates.core.config.gui; + +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; + +import java.io.IOException; + +public class GuiPositionEditor extends GuiScreen { + + private Position position; + private Position originalPosition; + private int elementWidth; + private int elementHeight; + private Runnable renderCallback; + private Runnable positionChangedCallback; + private Runnable closedCallback; + private boolean clicked = false; + private int grabbedX = 0; + private int grabbedY = 0; + + private int oldMouseX = 0; + private int oldMouseY = 0; + + public GuiPositionEditor(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; + } + + @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 = new ScaledResolution(Minecraft.getMinecraft()); + + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + + drawDefaultBackground(); + + if(clicked) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + } + + renderCallback.run(); + + int x = position.getAbsX(scaledResolution); + int y = position.getAbsY(scaledResolution); + + Gui.drawRect(x, y, x+elementWidth, y+elementHeight, 0x80404040); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + if(mouseButton == 0) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + int x = position.getAbsX(scaledResolution); + int y = position.getAbsY(scaledResolution); + + if(mouseX >= x && mouseY >= y && + mouseX <= x+elementWidth && mouseY <= y+elementHeight) { + clicked = true; + grabbedX = mouseX; + grabbedY = mouseY; + } + } + } + + @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); + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + if(clicked) { + oldMouseX = mouseX; + oldMouseY = mouseY; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java index f91b8410..513e32bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java @@ -101,6 +101,10 @@ public class ConfigProcessor { GuiOptionEditor editor = null; Class optionType = optionField.getType(); + if(optionField.isAnnotationPresent(ConfigEditorButton.class)) { + ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class); + editor = new GuiOptionEditorButton(option, configEditorAnnotation.runnableId(), configEditorAnnotation.buttonText(), config); + } if(optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorBoolean.class)) { editor = new GuiOptionEditorBoolean(option); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 777a91cc..da93b059 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -44,8 +44,8 @@ public class CapeManager { private HashSet availableCapes = new HashSet<>(); private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", - "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false }; + "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false, true }; public static CapeManager getInstance() { return INSTANCE; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index d93b8bb0..3af37cdd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -734,15 +734,23 @@ public class NEUCape { newPosition.y = node.lastPosition.y + (node.position.y - node.lastPosition.y) * partialRenderTick; newPosition.z = node.lastPosition.z + (node.position.z - node.lastPosition.z) * partialRenderTick; - if(node.oldRenderPosition[node.oldRenderPosition.length-1] == null) { + int length = node.oldRenderPosition.length; + int fps = Minecraft.getDebugFPS(); + if(fps < 50) { + length = 2; + } else if(fps < 100) { + length = 2+(int)((fps-50)/50f*3); + } + + if(node.oldRenderPosition[length-1] == null) { node.renderPosition = newPosition; } else { Vector3f accum = new Vector3f(); - for(int i=0; i 0.8/0.2 //0-1 accum.scale(blendFactor); 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 59cbfee5..be2b030a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.dungeons; import com.google.common.collect.Iterables; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; +import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.util.NEUResourceManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SpecialColour; @@ -1465,8 +1466,10 @@ public class DungeonMap { } } - renderMap((int)(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterX/100*Minecraft.getMinecraft().displayWidth/2), - (int)(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterY/100*Minecraft.getMinecraft().displayHeight/2), + Position pos = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition; + + int size = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); + renderMap(pos.getAbsX(event.resolution)+size/2, pos.getAbsY(event.resolution)+size/2, colourMap, decorations, roomSizeBlocks, actualPlayers, true, event.partialTicks); } } 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 5677bf9e..cd951830 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -1,5 +1,8 @@ package io.github.moulberry.notenoughupdates.dungeons; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiElementColour; @@ -43,16 +46,6 @@ public class GuiDungeonMapEditor extends GuiScreen { private List