aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-18 13:21:41 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-18 13:21:41 +0200
commit3e40f471b162a006ef40a8102bb7f496e9514518 (patch)
treea4b00873823a082473ef5f3086ee65fd12c73df4 /src/main/java/at/hannibal2
parent2f78bd32d9bebd216581d61dcdc53bd6adcea13a (diff)
downloadskyhanni-3e40f471b162a006ef40a8102bb7f496e9514518.tar.gz
skyhanni-3e40f471b162a006ef40a8102bb7f496e9514518.tar.bz2
skyhanni-3e40f471b162a006ef40a8102bb7f496e9514518.zip
adding ashfang gravity orbs 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/Abilities.java14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt61
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SpecialColour.java95
6 files changed, 199 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index c614cba01..506d82588 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.features.items.HideNotClickableItems;
import at.hannibal2.skyhanni.features.items.ItemDisplayOverlayFeatures;
import at.hannibal2.skyhanni.features.items.abilitycooldown.ItemAbilityCooldown;
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown;
+import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs;
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown;
import at.hannibal2.skyhanni.test.LorenzTest;
import com.google.gson.Gson;
@@ -94,6 +95,7 @@ public class SkyHanniMod {
registerEvent(new AshfangFreezeCooldown());
registerEvent(new AshfangNextResetCooldown());
registerEvent(new SummoningSoulsName());
+ registerEvent(new AshfangGravityOrbs());
Commands.init();
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 b723272c2..206d9e3e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.gui.core.config.Position;
import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean;
import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorButton;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorColour;
import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption;
import com.google.gson.annotations.Expose;
@@ -37,4 +38,17 @@ public class Abilities {
@ConfigOption(name = "Ashfang Reset Position", desc = "")
@ConfigEditorButton(runnableId = "ashfangResetCooldown", buttonText = "Edit")
public Position ashfangNextResetCooldownPos = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Ashfang Gravity Orbs", desc = "Showing the gravity Orbs more clearly")
+ @ConfigEditorBoolean
+ public boolean ashfangGravityOrbs = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Orbs Color",
+ desc = "Color of the Ashfang Gravity Orbs"
+ )
+ @ConfigEditorColour
+ public String ashfangGravityOrbsColor = "0:135:255:85:85";
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt
new file mode 100644
index 000000000..11a6f5f2a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt
@@ -0,0 +1,61 @@
+package at.hannibal2.skyhanni.features.nether.ashfang
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SpecialColour
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+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.TickEvent
+import java.awt.Color
+
+class AshfangGravityOrbs {
+
+ private val texture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV" +
+ "0L3RleHR1cmUvMWE2OWNjZjdhZDkwNGM5YTg1MmVhMmZmM2Y1YjRlMjNhZGViZjcyZWQxMmQ1ZjI0Yjc4Y2UyZDQ0YjRhMiJ9fX0="
+ private val orbs = mutableListOf<EntityArmorStand>()
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ Minecraft.getMinecraft().theWorld.loadedEntityList
+ .filter { it ->
+ it is EntityArmorStand && it !in orbs && it.inventory
+ .any { it != null && it.getSkullTexture() == texture }
+ }.forEach { orbs.add(it as EntityArmorStand) }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+
+ val special = SkyHanniMod.feature.abilities.ashfangGravityOrbsColor
+
+ val color = Color(SpecialColour.specialToChromaRGB(special), true)
+
+ val playerEyeLocation = LocationUtils.playerEyeLocation()
+ for (orb in orbs) {
+ if (orb.isDead) continue
+ val orbLocation = orb.getLorenzVec()
+ if (!LocationUtils.canSee(playerEyeLocation, orbLocation.add(0.0, 2.0, 0.0))) continue
+
+ event.drawWaypointFilled(orbLocation.add(-0.5, 1.25, -0.5), color)
+ }
+ }
+
+ @SubscribeEvent
+ fun renderOverlay(event: WorldEvent.Load) {
+ orbs.clear()
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.abilities.ashfangGravityOrbs
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt b/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt
index 8b77dc6e3..bfbb95302 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt
@@ -2,7 +2,12 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.client.event.RenderWorldLastEvent
+import java.awt.Color
object GriffinUtils {
@@ -11,6 +16,27 @@ object GriffinUtils {
GriffinJavaUtils.drawWaypoint(location, partialTicks, color.toColor(), beacon)
}
+ fun RenderWorldLastEvent.drawWaypointFilled(location: LorenzVec, color: Color, beacon: Boolean = false) {
+ val (viewerX, viewerY, viewerZ) = RenderUtils.getViewerPos(partialTicks)
+ val x = location.x - viewerX
+ val y = location.y - viewerY
+ val z = location.z - viewerZ
+ val distSq = x * x + y * y + z * z
+ GlStateManager.disableDepth()
+ GlStateManager.disableCull()
+ RenderUtils.drawFilledBoundingBox(
+ AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expandBlock(),
+ color,
+ (0.1f + 0.005f * distSq.toFloat()).coerceAtLeast(0.2f)
+ )
+ GlStateManager.disableTexture2D()
+ if (distSq > 5 * 5 && beacon) RenderUtils.renderBeaconBeam(x, y + 1, z, color.rgb, 1.0f, partialTicks)
+ GlStateManager.disableLighting()
+ GlStateManager.enableTexture2D()
+ GlStateManager.enableDepth()
+ GlStateManager.enableCull()
+ }
+
fun RenderWorldLastEvent.draw3DLine(
p1: LorenzVec,
p2: LorenzVec,
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 92febf7b6..49b5f74ef 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -73,7 +73,7 @@ object RenderUtils {
* @author Moulberry
* @author Mojang
*/
- private fun drawFilledBoundingBox(aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f) {
+ fun drawFilledBoundingBox(aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f) {
GlStateManager.enableBlend()
GlStateManager.disableLighting()
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SpecialColour.java b/src/main/java/at/hannibal2/skyhanni/utils/SpecialColour.java
new file mode 100644
index 000000000..6495873f4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SpecialColour.java
@@ -0,0 +1,95 @@
+package at.hannibal2.skyhanni.utils;
+
+import java.awt.*;
+
+/**
+ * Taken from NotEnoughUpdates
+ */
+public class SpecialColour {
+ public static String special(int chromaSpeed, int alpha, int rgb) {
+ return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF));
+ }
+
+ private static final int RADIX = 10;
+
+ public static String special(int chromaSpeed, int alpha, int r, int g, int b) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Integer.toString(chromaSpeed, RADIX)).append(":");
+ sb.append(Integer.toString(alpha, RADIX)).append(":");
+ sb.append(Integer.toString(r, RADIX)).append(":");
+ sb.append(Integer.toString(g, RADIX)).append(":");
+ sb.append(Integer.toString(b, RADIX));
+ return sb.toString();
+ }
+
+ private static int[] decompose(String csv) {
+ String[] split = csv.split(":");
+
+ int[] arr = new int[split.length];
+
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
+ }
+ return arr;
+ }
+
+ public static int specialToSimpleRGB(String special) {
+ int[] d = decompose(special);
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+ int a = d[3];
+ int chr = d[4];
+
+ return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
+ }
+
+ public static int getSpeed(String special) {
+ return decompose(special)[4];
+ }
+
+ public static float getSecondsForSpeed(int speed) {
+ return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
+ }
+
+ private static final int MIN_CHROMA_SECS = 1;
+ private static final int MAX_CHROMA_SECS = 60;
+
+ public static long startTime = -1;
+
+ public static int specialToChromaRGB(String special) {
+ if (startTime < 0) startTime = System.currentTimeMillis();
+
+ int[] d = decompose(special);
+ int chr = d[4];
+ int a = d[3];
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ if (chr > 0) {
+ float seconds = getSecondsForSpeed(chr);
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
+ hsv[0] %= 1;
+ if (hsv[0] < 0) hsv[0] += 1;
+ }
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
+
+ public static int rotateHue(int argb, int degrees) {
+ int a = (argb >> 24) & 0xFF;
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = (argb) & 0xFF;
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ hsv[0] += degrees / 360f;
+ hsv[0] %= 1;
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
+}