aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorRobotHanzo <36107150+RobotHanzo@users.noreply.github.com>2024-05-03 19:33:47 +0800
committerGitHub <noreply@github.com>2024-05-03 13:33:47 +0200
commit23a5bc7eaf0e6ddc189b54d88d49d86c87174440 (patch)
tree959f46539aba9f846ebe6b426d943ba312ba6bd2 /src/main/java
parent3b47c1b7223796b5a6dfed62730d3dd11871bad2 (diff)
downloadskyhanni-23a5bc7eaf0e6ddc189b54d88d49d86c87174440.tar.gz
skyhanni-23a5bc7eaf0e6ddc189b54d88d49d86c87174440.tar.bz2
skyhanni-23a5bc7eaf0e6ddc189b54d88d49d86c87174440.zip
Feature: Ability to adjust opacity of players near shared & guessed egg waypoints (#1582)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt60
4 files changed, 69 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index a68ae1cce..96d6c4af1 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -140,6 +140,7 @@ import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker
import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow
import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggLocator
+import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggPlayerOpacityChanger
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsShared
import at.hannibal2.skyhanni.features.event.hoppity.HoppityNpc
@@ -655,6 +656,7 @@ class SkyHanniMod {
loadModule(HoppityEggsManager)
loadModule(HoppityEggLocator)
loadModule(HoppityEggsShared)
+ loadModule(HoppityEggPlayerOpacityChanger)
loadModule(HoppityCollectionStats)
loadModule(SpawnTimers())
loadModule(MarkedPlayerManager())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
index e56633f42..d824826bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
@@ -34,6 +35,11 @@ public class HoppityEggsConfig {
public boolean sharedWaypoints = true;
@Expose
+ @ConfigOption(name = "Adjust player opacity", desc = "Adjust the opacity of players near shared & guessed egg waypoints. (in %)")
+ @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1)
+ public int playerOpacity = 40;
+
+ @Expose
@ConfigLink(owner = HoppityEggsConfig.class, field = "showClaimedEggs")
public Position position = new Position(33, 72, false, true);
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
index 371dbf9e8..1319cc3af 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
@@ -25,7 +25,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
object HoppityEggLocator {
-
private val config get() = HoppityEggsManager.config
private val locatorItem = "EGGLOCATOR".asInternalName()
@@ -36,13 +35,13 @@ object HoppityEggLocator {
private var drawLocations = false
private var firstPos = LorenzVec()
private var secondPos = LorenzVec()
- private var possibleEggLocations = listOf<LorenzVec>()
private var ticksSinceLastParticleFound = -1
private var lastGuessMade = SimpleTimeMark.farPast()
private var eggLocationWeights = listOf<Double>()
var sharedEggLocation: LorenzVec? = null
+ var possibleEggLocations = listOf<LorenzVec>()
var currentEggType: HoppityEggType? = null
var eggLocations: Map<IslandType, List<LorenzVec>> = mapOf()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt
new file mode 100644
index 000000000..68436438f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt
@@ -0,0 +1,60 @@
+package at.hannibal2.skyhanni.features.event.hoppity
+
+import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
+import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
+import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.lwjgl.opengl.GL11
+
+object HoppityEggPlayerOpacityChanger {
+ private val config get() = HoppityEggsManager.config
+ private var armor = mapOf<Int, ItemStack>()
+
+ private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) {
+ if (entity.distanceTo(location) >= 4.0) return
+ GlStateManager.enableBlend()
+ GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
+ GlStateManager.color(1.0f, 1.0f, 1.0f, config.playerOpacity / 100f)
+ val armorInventory = entity.getArmorInventory() ?: return
+
+ armor = buildMap {
+ for ((i, stack) in armorInventory.withIndex()) {
+ stack?.let {
+ this[i] = it.copy()
+ armorInventory[i] = null
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onPreRenderPlayer(event: SkyHanniRenderEntityEvent.Pre<EntityLivingBase>) {
+ if (!isEnabled()) return
+ if (event.entity !is EntityPlayer) return
+ if (event.entity.name == LorenzUtils.getPlayerName()) return
+ HoppityEggLocator.sharedEggLocation?.let { hideNearbyPlayer(event.entity, it) }
+ HoppityEggLocator.possibleEggLocations.forEach { hideNearbyPlayer(event.entity, it) }
+ }
+
+ @SubscribeEvent
+ fun onPostRenderPlayer(event: SkyHanniRenderEntityEvent.Post<EntityLivingBase>) {
+ if (!isEnabled()) return
+ GlStateManager.color(1f, 1f, 1f, 1f)
+ GlStateManager.disableBlend()
+ val armorInventory = event.entity.getArmorInventory() ?: return
+
+ for ((index, stack) in armor) { // restore armor after players leave the area
+ armorInventory[index] = stack
+ }
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.waypoints
+ && ChocolateFactoryAPI.isHoppityEvent() && config.playerOpacity != 100
+}