From 86748a11b18638e06984f73905f73e7330a4cfb4 Mon Sep 17 00:00:00 2001 From: RobotHanzo <36107150+RobotHanzo@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:28:33 +0800 Subject: [PATCH 1/5] Feature: Ability to adjust opacity of players near shared & guessed egg waypoints --- .../features/event/HoppityEggsConfig.java | 6 +++ .../chocolatefactory/HoppityEggLocator.kt | 50 +++++++++++++++++++ 2 files changed, 56 insertions(+) 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 1333239262a4..416b8e795cbd 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.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; @@ -33,6 +34,11 @@ public class HoppityEggsConfig { @FeatureToggle public boolean sharedWaypoints = true; + @Expose + @ConfigOption(name = "Adjust player opacity", desc = "Adjust the opacity of players near shared & guessed egg waypoints.") + @ConfigEditorSlider(minValue = 0, maxValue = 255, minStep = 1) + public int playerOpacity = 100; + @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/chocolatefactory/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt index ff271b2b4082..476d81019749 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt @@ -6,9 +6,12 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -18,9 +21,13 @@ import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.SimpleTimeMark +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.GL11 import kotlin.time.Duration.Companion.seconds object HoppityEggLocator { @@ -40,6 +47,7 @@ object HoppityEggLocator { private var ticksSinceLastParticleFound = -1 private var lastGuessMade = SimpleTimeMark.farPast() private var eggLocationWeights = listOf() + private var armor = mapOf() var sharedEggLocation: LorenzVec? = null var currentEggType: HoppityEggType? = null @@ -62,6 +70,24 @@ object HoppityEggLocator { currentEggType = null } + private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) { + if (entity.distanceTo(location) < 4.0) { + GlStateManager.enableBlend() + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) + GlStateManager.color(1.0f, 1.0f, 1.0f, config.playerOpacity / 255f) + val armorInventory = entity.getArmorInventory() ?: return + + armor = buildMap { + for ((i, stack) in armorInventory.withIndex()) { + stack?.let { + this[i] = it.copy() + armorInventory[i] = null + } + } + } + } + } + @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return @@ -107,6 +133,30 @@ object HoppityEggLocator { } } + @SubscribeEvent + fun onPreRenderPlayer(event: SkyHanniRenderEntityEvent.Pre) { + if (!isEnabled()) return + if (config.playerOpacity == 255) return + if (event.entity !is EntityPlayer) return + if (event.entity.name == LorenzUtils.getPlayerName()) return + + sharedEggLocation?.let { sharedEggLocation -> hideNearbyPlayer(event.entity, sharedEggLocation) } + possibleEggLocations.forEach { hideNearbyPlayer(event.entity, it) } + } + + @SubscribeEvent + fun onPostRenderPlayer(event: SkyHanniRenderEntityEvent.Post) { + if (!isEnabled()) return + if (config.playerOpacity == 255) 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 + } + } + fun eggFound() { resetData() } From e91225262d26d276d819af3fc61255a6feaea87a Mon Sep 17 00:00:00 2001 From: RobotHanzo <36107150+RobotHanzo@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:39:43 +0800 Subject: [PATCH 2/5] Improvement: Changed player opacity unit to % --- .../skyhanni/config/features/event/HoppityEggsConfig.java | 6 +++--- .../features/event/chocolatefactory/HoppityEggLocator.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 416b8e795cbd..f0ff1e1d18e2 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 @@ -35,9 +35,9 @@ public class HoppityEggsConfig { public boolean sharedWaypoints = true; @Expose - @ConfigOption(name = "Adjust player opacity", desc = "Adjust the opacity of players near shared & guessed egg waypoints.") - @ConfigEditorSlider(minValue = 0, maxValue = 255, minStep = 1) - public int playerOpacity = 100; + @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") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt index 476d81019749..62b8c386a6bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt @@ -74,7 +74,7 @@ object HoppityEggLocator { if (entity.distanceTo(location) < 4.0) { GlStateManager.enableBlend() GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) - GlStateManager.color(1.0f, 1.0f, 1.0f, config.playerOpacity / 255f) + GlStateManager.color(1.0f, 1.0f, 1.0f, config.playerOpacity / 100f * 255f) val armorInventory = entity.getArmorInventory() ?: return armor = buildMap { @@ -136,7 +136,7 @@ object HoppityEggLocator { @SubscribeEvent fun onPreRenderPlayer(event: SkyHanniRenderEntityEvent.Pre) { if (!isEnabled()) return - if (config.playerOpacity == 255) return + if (config.playerOpacity == 100) return if (event.entity !is EntityPlayer) return if (event.entity.name == LorenzUtils.getPlayerName()) return @@ -147,7 +147,7 @@ object HoppityEggLocator { @SubscribeEvent fun onPostRenderPlayer(event: SkyHanniRenderEntityEvent.Post) { if (!isEnabled()) return - if (config.playerOpacity == 255) return + if (config.playerOpacity == 100) return GlStateManager.color(1f, 1f, 1f, 1f) GlStateManager.disableBlend() val armorInventory = event.entity.getArmorInventory() ?: return From 4309bd2cdfaba54f94a93a75487dcbf7f7e50a3f Mon Sep 17 00:00:00 2001 From: RobotHanzo <36107150+RobotHanzo@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:27:58 +0800 Subject: [PATCH 3/5] Improvement: Made the feature an independent singleton --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../chocolatefactory/HoppityEggLocator.kt | 53 +--------------- .../HoppityEggPlayerOpacityChanger.kt | 61 +++++++++++++++++++ 3 files changed, 64 insertions(+), 52 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggPlayerOpacityChanger.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a92e2fb1b3bf..87ec35e8c75f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -131,6 +131,7 @@ import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryInv import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryStats import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionStats import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator +import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggPlayerOpacityChanger import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsManager import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsShared import at.hannibal2.skyhanni.features.event.chocolatefactory.clicks.FactoryItemTooltipFeatures @@ -630,6 +631,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/features/event/chocolatefactory/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt index 62b8c386a6bd..7a4fc3b6c053 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggLocator.kt @@ -6,12 +6,9 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled -import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -21,17 +18,12 @@ import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.SimpleTimeMark -import net.minecraft.client.renderer.GlStateManager -import net.minecraft.entity.EntityLivingBase -import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.lwjgl.opengl.GL11 import kotlin.time.Duration.Companion.seconds object HoppityEggLocator { - private val config get() = ChocolateFactoryAPI.config.hoppityEggs private val locatorItem = "EGGLOCATOR".asInternalName() @@ -42,14 +34,13 @@ object HoppityEggLocator { private var drawLocations = false private var firstPos = LorenzVec() private var secondPos = LorenzVec() - private var possibleEggLocations = listOf() private var ticksSinceLastParticleFound = -1 private var lastGuessMade = SimpleTimeMark.farPast() private var eggLocationWeights = listOf() - private var armor = mapOf() var sharedEggLocation: LorenzVec? = null + var possibleEggLocations = listOf() var currentEggType: HoppityEggType? = null var eggLocations: Map> = mapOf() @@ -70,24 +61,6 @@ object HoppityEggLocator { currentEggType = null } - private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) { - if (entity.distanceTo(location) < 4.0) { - 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 * 255f) - val armorInventory = entity.getArmorInventory() ?: return - - armor = buildMap { - for ((i, stack) in armorInventory.withIndex()) { - stack?.let { - this[i] = it.copy() - armorInventory[i] = null - } - } - } - } - } - @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return @@ -133,30 +106,6 @@ object HoppityEggLocator { } } - @SubscribeEvent - fun onPreRenderPlayer(event: SkyHanniRenderEntityEvent.Pre) { - if (!isEnabled()) return - if (config.playerOpacity == 100) return - if (event.entity !is EntityPlayer) return - if (event.entity.name == LorenzUtils.getPlayerName()) return - - sharedEggLocation?.let { sharedEggLocation -> hideNearbyPlayer(event.entity, sharedEggLocation) } - possibleEggLocations.forEach { hideNearbyPlayer(event.entity, it) } - } - - @SubscribeEvent - fun onPostRenderPlayer(event: SkyHanniRenderEntityEvent.Post) { - if (!isEnabled()) return - if (config.playerOpacity == 100) 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 - } - } - fun eggFound() { resetData() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggPlayerOpacityChanger.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggPlayerOpacityChanger.kt new file mode 100644 index 000000000000..9f7525462544 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/HoppityEggPlayerOpacityChanger.kt @@ -0,0 +1,61 @@ +package at.hannibal2.skyhanni.features.event.chocolatefactory + +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +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() = ChocolateFactoryAPI.config.hoppityEggs + private var armor = mapOf() + + private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) { + if (entity.distanceTo(location) < 4.0) { + 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) { + if (!isEnabled()) return + if (event.entity !is EntityPlayer) return + if (event.entity.name == LorenzUtils.getPlayerName()) return + HoppityEggLocator.sharedEggLocation?.let { sharedEggLocation -> hideNearbyPlayer(event.entity, sharedEggLocation) } + HoppityEggLocator.possibleEggLocations.forEach { hideNearbyPlayer(event.entity, it) } + } + + @SubscribeEvent + fun onPostRenderPlayer(event: SkyHanniRenderEntityEvent.Post) { + 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 +} From 4fc1b275ee0c379708bf9492cb249fd1f0f7dd59 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 1 May 2024 12:19:12 +0200 Subject: [PATCH 4/5] fixed merge conflicts --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 11 +---------- .../event/hoppity/HoppityEggPlayerOpacityChanger.kt | 8 ++++---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index ec49c0147321..13acb142e521 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -126,16 +126,6 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonsRaceGuide import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite import at.hannibal2.skyhanni.features.dungeon.TerracottaPhase import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryBarnManager -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryInventory -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryStats -import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionStats -import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator -import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggPlayerOpacityChanger -import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsManager -import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsShared -import at.hannibal2.skyhanni.features.event.chocolatefactory.clicks.FactoryItemTooltipFeatures import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker @@ -148,6 +138,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 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 index 9f7525462544..35b12ac74983 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt @@ -1,6 +1,7 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory +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 @@ -13,7 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 object HoppityEggPlayerOpacityChanger { - private val config get() = ChocolateFactoryAPI.config.hoppityEggs + private val config get() = HoppityEggsManager.config private var armor = mapOf() private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) { @@ -34,13 +35,12 @@ object HoppityEggPlayerOpacityChanger { } } - @SubscribeEvent fun onPreRenderPlayer(event: SkyHanniRenderEntityEvent.Pre) { if (!isEnabled()) return if (event.entity !is EntityPlayer) return if (event.entity.name == LorenzUtils.getPlayerName()) return - HoppityEggLocator.sharedEggLocation?.let { sharedEggLocation -> hideNearbyPlayer(event.entity, sharedEggLocation) } + HoppityEggLocator.sharedEggLocation?.let { hideNearbyPlayer(event.entity, it) } HoppityEggLocator.possibleEggLocations.forEach { hideNearbyPlayer(event.entity, it) } } From 673e3af374e089536e12df1d7e08ea6c48f9d7e5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 3 May 2024 13:33:03 +0200 Subject: [PATCH 5/5] code cleanup --- .../hoppity/HoppityEggPlayerOpacityChanger.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) 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 index 35b12ac74983..68436438fe9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggPlayerOpacityChanger.kt @@ -18,18 +18,17 @@ object HoppityEggPlayerOpacityChanger { private var armor = mapOf() private fun hideNearbyPlayer(entity: EntityPlayer, location: LorenzVec) { - if (entity.distanceTo(location) < 4.0) { - 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 - } + 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 } } }