aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt2
-rw-r--r--src/main/java/at/lorenz/mod/LorenzMod.java10
-rw-r--r--src/main/java/at/lorenz/mod/config/Features.java108
-rw-r--r--src/main/java/at/lorenz/mod/misc/CurrentPetDisplay.kt48
-rw-r--r--src/main/java/at/lorenz/mod/utils/GuiRender.kt30
5 files changed, 140 insertions, 58 deletions
diff --git a/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt b/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt
index d542541ac..4c71449d9 100644
--- a/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt
+++ b/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt
@@ -75,7 +75,7 @@ class ItemDisplayOverlayFeatures {
if (LorenzMod.feature.item.displayNewYearCakeNumber) {
if (name.startsWith("New Year Cake")) {
- return "§b" + name.split("(Year ", ")")[1]
+ return "§b" + name.between("(Year ", ")")
}
}
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java
index e1ceea004..b9f9d7ad6 100644
--- a/src/main/java/at/lorenz/mod/LorenzMod.java
+++ b/src/main/java/at/lorenz/mod/LorenzMod.java
@@ -8,6 +8,7 @@ import at.lorenz.mod.chat.PlayerChatFilter;
import at.lorenz.mod.config.Features;
import at.lorenz.mod.dungeon.DungeonChatFilter;
import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks;
+import at.lorenz.mod.misc.CurrentPetDisplay;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.thatgravyboat.skyblockhud_2.commands.Commands;
@@ -53,6 +54,7 @@ public class LorenzMod {
MinecraftForge.EVENT_BUS.register(new HideNotClickableItems());
MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks());
MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures());
+ MinecraftForge.EVENT_BUS.register(new CurrentPetDisplay());
Commands.init();
@@ -105,15 +107,7 @@ public class LorenzMod {
feature = new Features();
saveConfig();
}
- //
- // Textures.setTexture(config.misc.style);
- //
- // if (WarpHandler.load()) {
- // WarpHandler.save();
- // }
- //
Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig));
- // Runtime.getRuntime().addShutdownHook(new Thread(TrackerFileLoader::saveTrackerStatsFile));
}
public void saveConfig() {
diff --git a/src/main/java/at/lorenz/mod/config/Features.java b/src/main/java/at/lorenz/mod/config/Features.java
index f441a2db7..97f9be3d8 100644
--- a/src/main/java/at/lorenz/mod/config/Features.java
+++ b/src/main/java/at/lorenz/mod/config/Features.java
@@ -1,69 +1,45 @@
package at.lorenz.mod.config;
-import com.google.gson.annotations.Expose;
import at.lorenz.mod.LorenzMod;
+import com.google.gson.annotations.Expose;
import com.thatgravyboat.skyblockhud_2.config.SBHConfigEditor;
+import com.thatgravyboat.skyblockhud_2.core.GuiElement;
import com.thatgravyboat.skyblockhud_2.core.GuiScreenElementWrapper;
import com.thatgravyboat.skyblockhud_2.core.config.Position;
import com.thatgravyboat.skyblockhud_2.core.config.annotations.Category;
import com.thatgravyboat.skyblockhud_2.core.config.annotations.ConfigEditorBoolean;
+import com.thatgravyboat.skyblockhud_2.core.config.annotations.ConfigEditorButton;
import com.thatgravyboat.skyblockhud_2.core.config.annotations.ConfigOption;
import com.thatgravyboat.skyblockhud_2.core.config.gui.GuiPositionEditor;
import net.minecraft.client.Minecraft;
-public class Features {
+public class Features {
private void editOverlay(String activeConfig, int width, int height, Position position) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {}, () -> {}, () -> LorenzMod.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(LorenzMod.feature, activeConfig))));
+ Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {
+ }, () -> {
+ }, () -> LorenzMod.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(LorenzMod.feature, activeConfig))));
}
public void executeRunnable(String runnableId) {
- // String activeConfigCategory = null;
- // if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
- // GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen;
- // if (wrapper.element instanceof SBHConfigEditor) {
- // activeConfigCategory = ((SBHConfigEditor) wrapper.element).getSelectedCategoryName();
- // }
- // }
- //
- // switch (runnableId) {
- // case "rpg":
- // editOverlay(activeConfigCategory, 120, 47, rpg.rpgHudPosition);
- // return;
- // case "d1":
- // editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer1);
- // return;
- // case "d2":
- // editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer2);
- // return;
- // case "d3":
- // editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer3);
- // return;
- // case "d4":
- // editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer4);
- // return;
- // case "main":
- // editOverlay(activeConfigCategory, 1000, 34, main.mainHudPos);
- // return;
- // case "ultimate":
- // editOverlay(activeConfigCategory, 182, 5, dungeon.barPosition);
- // return;
- // case "map":
- // editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition);
- // return;
- // case "tracker":
- // editOverlay(activeConfigCategory, 130, 70, trackers.trackerPosition);
- // return;
- // case "drill":
- // editOverlay(activeConfigCategory, 136, 7, mining.drillBar);
- // return;
- // case "heat":
- // editOverlay(activeConfigCategory, 45, 7, mining.heatBar);
- // return;
- // case "dialogue":
- // editOverlay(activeConfigCategory, 182, 68, misc.dialoguePos);
- // return;
- // }
+ String activeConfigCategory = null;
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
+ GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen;
+ GuiElement element = wrapper.element;
+ if (element instanceof SBHConfigEditor) {
+ activeConfigCategory = ((SBHConfigEditor) element).getSelectedCategoryName();
+ }
+ }
+
+ if (runnableId.equals("petDisplay")) {
+ editOverlay(activeConfigCategory, 200, 16, misc.petDisplayPos);
+ return;
+ }
+
+ if (runnableId.equals("testPos")) {
+ editOverlay(activeConfigCategory, 200, 16, test.testPos);
+ return;
+ }
}
@Expose
@@ -82,6 +58,14 @@ public class Features {
@Category(name = "Bazaar", desc = "Bazaar settings.")
public Bazaar bazaar = new Bazaar();
+ @Expose
+ @Category(name = "Misc", desc = "Settings without a big category")
+ public Misc misc = new Misc();
+
+ @Expose
+ @Category(name = "Test", desc = "Test stuff")
+ public Test test = new Test();
+
public static class Chat {
@Expose
@@ -158,4 +142,30 @@ public class Features {
@ConfigEditorBoolean
public boolean orderHelper = false;
}
+
+ public static class Misc {
+
+ @Expose
+ @ConfigOption(name = "Pet Display", desc = "Shows the current active pet.")
+ @ConfigEditorBoolean
+ public boolean petDisplay = false;
+
+ @Expose
+ @ConfigOption(name = "Pet Display Position", desc = "")
+ @ConfigEditorButton(runnableId = "petDisplay", buttonText = "Edit")
+ public Position petDisplayPos = new Position(10, 10, false, true);
+ }
+
+ public static class Test {
+
+ @Expose
+ @ConfigOption(name = "Enable Test", desc = "Enable Test logic")
+ @ConfigEditorBoolean
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Test Location", desc = "testPos")
+ @ConfigEditorButton(runnableId = "testPos", buttonText = "Edit")
+ public Position testPos = new Position(10, 10, false, true);
+ }
}
diff --git a/src/main/java/at/lorenz/mod/misc/CurrentPetDisplay.kt b/src/main/java/at/lorenz/mod/misc/CurrentPetDisplay.kt
new file mode 100644
index 000000000..9159dc3cc
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/misc/CurrentPetDisplay.kt
@@ -0,0 +1,48 @@
+package at.lorenz.mod.misc
+
+import at.lorenz.mod.LorenzMod
+import at.lorenz.mod.events.LorenzChatEvent
+import at.lorenz.mod.utils.GuiRender.renderString
+import at.lorenz.mod.utils.LorenzUtils.between
+import at.lorenz.mod.utils.LorenzUtils.matchRegex
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class CurrentPetDisplay {
+
+ companion object {
+ var currentPet: String = ""
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ var blocked = false
+
+ val message = event.message
+ if (message.matchRegex("§aYou summoned your §r(.*)§r§a!")) {
+ currentPet = message.between("your §r", "§r§a")
+ blocked = true
+ }
+ if (message.matchRegex("§cAutopet §eequipped your §7(.*)§e! §a§lVIEW RULE")) {
+ currentPet = message.between("] ", "§e!")
+ blocked = true
+ }
+ if (message.matchRegex("§aYou despawned your §r(.*)§r§a!")) {
+ currentPet = ""
+ blocked = true
+ }
+
+ if (blocked && LorenzMod.feature.misc.petDisplay) {
+ event.blockedReason = "pets"
+ }
+ }
+
+
+ @SubscribeEvent
+ fun renderOverlay(event: RenderGameOverlayEvent.Post) {
+ if (!LorenzMod.feature.misc.petDisplay) return
+ if (currentPet == "") return
+
+ LorenzMod.feature.misc.petDisplayPos.renderString(currentPet)
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/utils/GuiRender.kt b/src/main/java/at/lorenz/mod/utils/GuiRender.kt
new file mode 100644
index 000000000..87c14df4a
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/utils/GuiRender.kt
@@ -0,0 +1,30 @@
+package at.lorenz.mod.utils
+
+import com.thatgravyboat.skyblockhud_2.core.config.Position
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.ScaledResolution
+import net.minecraft.client.renderer.GlStateManager
+
+object GuiRender {
+
+ fun Position.renderString(string: String) {
+
+ GlStateManager.pushMatrix()
+ val resolution = ScaledResolution(Minecraft.getMinecraft())
+
+ val renderer = Minecraft.getMinecraft().renderManager.fontRenderer
+
+ val offsetX = (200 - renderer.getStringWidth(string)) / 2
+
+ val x = getAbsX(resolution, 200) + offsetX
+ val y = getAbsY(resolution, 16)
+
+
+
+ GlStateManager.translate(x + 1.0, y + 1.0, 0.0)
+ renderer.drawStringWithShadow(string, 0f, 0f, 0)
+
+
+ GlStateManager.popMatrix()
+ }
+} \ No newline at end of file