aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-23 00:55:22 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-23 00:55:22 +0200
commit57b351f66232fd7323234ab3e407729667c40143 (patch)
tree6cc90af01b85578e1d91cd9230d8aae342f10d3c /src/main/java/at/hannibal2
parentcd4d86f9cae10700c2ca53ac55e8d8d08702574c (diff)
downloadskyhanni-57b351f66232fd7323234ab3e407729667c40143.tar.gz
skyhanni-57b351f66232fd7323234ab3e407729667c40143.tar.bz2
skyhanni-57b351f66232fd7323234ab3e407729667c40143.zip
added last minion display
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Minions.java35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt81
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt18
6 files changed, 141 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index cf4580ef0..e366c9e2c 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.features.items.HideNotClickableItems;
import at.hannibal2.skyhanni.features.items.ItemDisplayOverlayFeatures;
import at.hannibal2.skyhanni.features.items.ItemStars;
import at.hannibal2.skyhanni.features.items.abilitycooldown.ItemAbilityCooldown;
+import at.hannibal2.skyhanni.features.minion.MinionHelper;
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown;
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs;
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown;
@@ -95,6 +96,7 @@ public class SkyHanniMod {
registerEvent(new SummoningSoulsName());
registerEvent(new AshfangGravityOrbs());
registerEvent(new ItemStars());
+ registerEvent(new MinionHelper());
registerEvent(new RealTime());
Commands.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index dd6afbb44..916cb896b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -85,6 +85,10 @@ public class Features {
public Abilities abilities = new Abilities();
@Expose
+ @Category(name = "Minion", desc = "Stuff about minions")
+ public Minions minions = new Minions();
+
+ @Expose
@Category(name = "Bazaar", desc = "Bazaar settings.")
public Bazaar bazaar = new Bazaar();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
index 206d9e3e9..8c7c0074b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
@@ -50,5 +50,5 @@ public class Abilities {
desc = "Color of the Ashfang Gravity Orbs"
)
@ConfigEditorColour
- public String ashfangGravityOrbsColor = "0:135:255:85:85";
+ public String ashfangGravityOrbsColor = "0:245:255:85:85";
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java
new file mode 100644
index 000000000..d851c7436
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java
@@ -0,0 +1,35 @@
+package at.hannibal2.skyhanni.config.features;
+
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorColour;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorSlider;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption;
+import com.google.gson.annotations.Expose;
+
+public class Minions {
+
+ @Expose
+ @ConfigOption(name = "Last Minion Display", desc = "Show the last opened minion on your island")
+ @ConfigEditorBoolean
+ public boolean lastOpenedMinionDisplay = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Last Minion Color",
+ desc = "The colour in which the last minion should be displayed"
+ )
+ @ConfigEditorColour
+ public String lastOpenedMinionColor = "0:245:85:255:85";
+
+ @Expose
+ @ConfigOption(
+ name = "Last Minion Time",
+ desc = "Time in seconds how long the last minion should be displayed"
+ )
+ @ConfigEditorSlider(
+ minValue = 3,
+ maxValue = 120,
+ minStep = 1
+ )
+ public int lastOpenedMinionTime = 20;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt
new file mode 100644
index 000000000..7bf198f1a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt
@@ -0,0 +1,81 @@
+package at.hannibal2.skyhanni.features.minion
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.*
+import net.minecraft.client.Minecraft
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.InputEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import org.lwjgl.input.Mouse
+import java.awt.Color
+
+class MinionHelper {
+
+ var lastLocation: LorenzVec? = null
+ var lastMinion: LorenzVec? = null
+ var lastMinionOpened = 0L
+ var minionInventoryOpen = false
+
+ @SubscribeEvent
+ fun onClick(event: InputEvent.MouseInputEvent) {
+ if (!LorenzUtils.inSkyblock) return
+
+ val minecraft = Minecraft.getMinecraft()
+ val buttonState = Mouse.getEventButtonState()
+ val eventButton = Mouse.getEventButton()
+
+ if (buttonState) {
+ if (eventButton == 1) {
+ val entity = minecraft.pointedEntity
+ if (entity != null) {
+ lastLocation = entity.getLorenzVec().add(-0.5, 0.0, -0.5)
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!LorenzUtils.inSkyblock) return
+ if (!SkyHanniMod.feature.minions.lastOpenedMinionDisplay) return
+
+ val special = SkyHanniMod.feature.minions.lastOpenedMinionColor
+ val color = Color(SpecialColour.specialToChromaRGB(special), true)
+
+ val loc = lastMinion
+ if (loc != null) {
+ val time = SkyHanniMod.feature.minions.lastOpenedMinionTime * 1_000
+ if (lastMinionOpened + time > System.currentTimeMillis()) {
+ event.drawWaypointFilled(loc, color)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (InventoryUtils.currentlyOpenInventory().contains("Minion")) {
+ if (lastLocation != null) {
+ lastMinion = lastLocation
+ lastLocation = null
+ minionInventoryOpen = true
+ lastMinionOpened = 0
+ }
+ } else {
+ if (minionInventoryOpen) {
+ minionInventoryOpen = false
+ lastMinionOpened = System.currentTimeMillis()
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ lastLocation = null
+ lastMinion = null
+ lastMinionOpened = 0L
+ minionInventoryOpen = false
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
new file mode 100644
index 000000000..18a4ce635
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -0,0 +1,18 @@
+package at.hannibal2.skyhanni.utils
+
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.inventory.ContainerChest
+
+object InventoryUtils {
+
+ //TODO use this method more widely
+ fun currentlyOpenInventory(): String {
+ val screen = Minecraft.getMinecraft().currentScreen
+ if (screen !is GuiChest) return ""
+ val chest = screen.inventorySlots as ContainerChest
+
+ return chest.lowerChestInventory.displayName.unformattedText.trim()
+ }
+
+} \ No newline at end of file