Skip to content

Commit

Permalink
Backend: Remove Deprecated Color.withAlpha (#2916)
Browse files Browse the repository at this point in the history
Co-authored-by: Cal <cwolfson58@gmail.com>
  • Loading branch information
j10a1n15 and CalMWolfs authored Nov 12, 2024
1 parent 2049030 commit 00f7ff6
Show file tree
Hide file tree
Showing 27 changed files with 100 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
Expand Down Expand Up @@ -40,7 +40,7 @@ object MobHighlight {
if (config.corruptedMobHighlight && event.health == baseMaxHealth * 3) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.DARK_PURPLE.toColor().withAlpha(127)
LorenzColor.DARK_PURPLE.toColor().addAlpha(127),
) { config.corruptedMobHighlight }
}
}
Expand All @@ -54,14 +54,14 @@ object MobHighlight {
if (config.arachneKeeperHighlight && (maxHealth == 3_000 || maxHealth == 12_000) && entity is EntityCaveSpider) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.DARK_BLUE.toColor().withAlpha(127)
LorenzColor.DARK_BLUE.toColor().addAlpha(127),
) { config.arachneKeeperHighlight }
}

if (config.corleoneHighlighter && maxHealth == 1_000_000 && entity is EntityOtherPlayerMP && entity.name == "Team Treasurite") {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.DARK_PURPLE.toColor().withAlpha(127)
LorenzColor.DARK_PURPLE.toColor().addAlpha(127),
) { config.corleoneHighlighter }
}

Expand All @@ -73,17 +73,17 @@ object MobHighlight {
if (isZealot || isBruiser) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.DARK_AQUA.toColor().withAlpha(127)
LorenzColor.DARK_AQUA.toColor().addAlpha(127),
) { config.zealotBruiserHighlighter }
}
}

if (config.chestZealotHighlighter) {
val isHoldingChest = (entity as? EntityEnderman)?.getBlockInHand()?.block == Blocks.ender_chest
val isHoldingChest = entity.getBlockInHand()?.block == Blocks.ender_chest
if ((isZealot || isBruiser) && isHoldingChest) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.GREEN.toColor().withAlpha(127)
LorenzColor.GREEN.toColor().addAlpha(127),
) { config.chestZealotHighlighter }
}
}
Expand All @@ -92,7 +92,7 @@ object MobHighlight {
if (config.specialZealotHighlighter && maxHealth.ignoreDerpy() == 2_000) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.DARK_RED.toColor().withAlpha(50)
LorenzColor.DARK_RED.toColor().addAlpha(50),
) { config.specialZealotHighlighter }
}
}
Expand Down Expand Up @@ -147,14 +147,14 @@ object MobHighlight {
private fun markArachneMinis(entity: EntityLivingBase) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.GOLD.toColor().withAlpha(50)
LorenzColor.GOLD.toColor().addAlpha(50),
) { config.arachneBossHighlighter }
}

private fun markArachne(entity: EntityLivingBase) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.RED.toColor().withAlpha(50)
LorenzColor.RED.toColor().addAlpha(50),
) { config.arachneBossHighlighter }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LorenzColor
Expand Down Expand Up @@ -181,7 +181,7 @@ object DungeonHideItems {
movingSkeletonSkulls[entity] = System.currentTimeMillis()
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.GOLD.toColor().withAlpha(60)
LorenzColor.GOLD.toColor().addAlpha(60),
) { shouldColorMovingSkull(entity) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent
import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
import at.hannibal2.skyhanni.utils.InventoryUtils
Expand All @@ -38,11 +38,11 @@ object UniqueGiftingOpportunitiesFeatures {
private val patternGroup = RepoPattern.group("event.winter.uniquegifts")
private val giftedPattern by patternGroup.pattern(
"gifted",
"§6\\+1 Unique Gift given! To ([^§]+)§r§6!"
"§6\\+1 Unique Gift given! To ([^§]+)§r§6!",
)
private val giftNamePattern by patternGroup.pattern(
"giftname",
"(?:WHITE|RED|GREEN)_GIFT\$"
"(?:WHITE|RED|GREEN)_GIFT\$",
)

private var holdingGift = false
Expand Down Expand Up @@ -90,7 +90,7 @@ object UniqueGiftingOpportunitiesFeatures {

RenderLivingEntityHelper.setEntityColor(
entity,
LorenzColor.DARK_GREEN.toColor().withAlpha(127)
LorenzColor.DARK_GREEN.toColor().addAlpha(127),
) { isEnabled() && !hasGiftedPlayer(entity) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.entity.passive.EntityVillager
Expand All @@ -24,7 +24,7 @@ object HighlightJerries {
LorenzColor.BLUE,
LorenzColor.DARK_PURPLE,
LorenzColor.GOLD,
LorenzColor.LIGHT_PURPLE
LorenzColor.LIGHT_PURPLE,
)

@SubscribeEvent
Expand All @@ -36,7 +36,7 @@ object HighlightJerries {
val maxHealth = event.maxHealth

if (entity is EntityVillager && maxHealth in 3..6) {
val color = listOfLorenzColors[maxHealth].toColor().withAlpha(20)
val color = listOfLorenzColors[maxHealth].toColor().addAlpha(20)
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, color) { config.highlightJerries }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.features.fishing.FishingAPI.isLavaRod
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils
Expand Down Expand Up @@ -130,7 +130,7 @@ object GoldenFishTimer {
val entity = confirmedGoldenFishEntity ?: return
if (config.highlight) RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.GREEN.toColor().withAlpha(100)
LorenzColor.GREEN.toColor().addAlpha(100),
) { true }
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,16 @@ object GardenVisitorFeatures {
entity is EntityLivingBase
) {
val color = visitor.status.color
if (color != -1) {
if (color != null) {
RenderLivingEntityHelper.setEntityColor(
entity,
color,
) { config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH }
}
// Haven't gotten either of the known effected visitors (Vex and Leo) so can't test for sure
if (color == -1 || !GardenAPI.inGarden()) RenderLivingEntityHelper.removeEntityColor(entity)
if (color == null || !GardenAPI.inGarden()) {
// Haven't gotten either of the known effected visitors (Vex and Leo) so can't test for sure
RenderLivingEntityHelper.removeEntityColor(entity)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture
import at.hannibal2.skyhanni.utils.LorenzColor
Expand All @@ -38,7 +38,7 @@ object HighlightVisitorsOutsideOfGarden {
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
visitorJson = event.getConstant<GardenJson>(
"Garden", GardenJson::class.java
"Garden", GardenJson::class.java,
).visitors.values.groupBy {
it.mode
}
Expand Down Expand Up @@ -70,7 +70,7 @@ object HighlightVisitorsOutsideOfGarden {
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!config.highlightVisitors) return
val color = LorenzColor.DARK_RED.toColor().withAlpha(50)
val color = LorenzColor.DARK_RED.toColor().addAlpha(50)
EntityUtils.getEntities<EntityLivingBase>()
.filter { it !is EntityArmorStand && isVisitor(it) }
.forEach {
Expand Down Expand Up @@ -102,7 +102,7 @@ object HighlightVisitorsOutsideOfGarden {
if (packet.action == C02PacketUseEntity.Action.INTERACT) {
ChatUtils.chatAndOpenConfig(
"Blocked you from interacting with a visitor. Sneak to bypass or click here to change settings.",
GardenAPI.config.visitors::blockInteracting
GardenAPI.config.visitors::blockInteracting,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzLogger
Expand All @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.isInt
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import java.awt.Color

@SkyHanniModule
object VisitorAPI {
Expand All @@ -35,11 +36,11 @@ object VisitorAPI {
val patternGroup = RepoPattern.group("garden.visitor.api")
val visitorCountPattern by patternGroup.pattern(
"visitor.count",
"§b§lVisitors: §r§f\\((?<info>.*)\\)"
"§b§lVisitors: §r§f\\((?<info>.*)\\)",
)
private val visitorNamePattern by patternGroup.pattern(
"visitor.name",
" (?:§.)+(?<name>§.[^§]+).*"
" (?:§.)+(?<name>§.[^§]+).*",
)

fun getVisitorsMap() = visitors
Expand Down Expand Up @@ -156,12 +157,12 @@ object VisitorAPI {
}
}

enum class VisitorStatus(val displayName: String, val color: Int) {
NEW("§eNew", LorenzColor.YELLOW.toColor().withAlpha(100)),
WAITING("Waiting", -1),
READY("§aItems Ready", LorenzColor.GREEN.toColor().withAlpha(80)),
ACCEPTED("§7Accepted", LorenzColor.DARK_GRAY.toColor().withAlpha(80)),
REFUSED("§cRefused", LorenzColor.RED.toColor().withAlpha(60)),
enum class VisitorStatus(val displayName: String, val color: Color?) {
NEW("§eNew", LorenzColor.YELLOW.toColor().addAlpha(100)),
WAITING("Waiting", null),
READY("§aItems Ready", LorenzColor.GREEN.toColor().addAlpha(80)),
ACCEPTED("§7Accepted", LorenzColor.DARK_GRAY.toColor().addAlpha(80)),
REFUSED("§cRefused", LorenzColor.RED.toColor().addAlpha(60)),
}

fun visitorsInTabList(tabList: List<String>): List<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
Expand Down Expand Up @@ -72,7 +71,7 @@ object GuardianReminder {
GlStateManager.translate(0f, -150f, 500f)
Renderable.drawInsideRoundedRect(
Renderable.string("§cWrong Pet equipped!", 1.5),
Color(Color.DARK_GRAY.withAlpha(0), true),
Color.DARK_GRAY,
horizontalAlign = RenderUtils.HorizontalAlignment.CENTER,
verticalAlign = RenderUtils.VerticalAlignment.CENTER,
).renderXYAligned(0, 125, width, height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.features.inventory.experimentationtable.Experimenta
import at.hannibal2.skyhanni.features.inventory.experimentationtable.ExperimentationTableAPI.ultraRarePattern
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
Expand Down Expand Up @@ -54,7 +53,7 @@ object UltraRareBookAlert {

Renderable.drawInsideRoundedRect(
Renderable.string("§d§kXX§5 ULTRA-RARE BOOK! §d§kXX", 1.5),
Color(Color.DARK_GRAY.withAlpha(0), true),
Color.DARK_GRAY,
horizontalAlign = RenderUtils.HorizontalAlignment.CENTER,
verticalAlign = RenderUtils.VerticalAlignment.CENTER,
).renderXYAligned(0, 125, gui.width, gui.height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.darker
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf
import at.hannibal2.skyhanni.utils.ConfigUtils.jumpToEditor
Expand Down Expand Up @@ -276,7 +275,7 @@ object CustomWardrobe {

val playerColor = if (!slot.isInCurrentPage()) {
scale *= 0.9
Color.GRAY.withAlpha(100)
Color.GRAY.addAlpha(100)
} else null

return Renderable.fakePlayer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth
import at.hannibal2.skyhanni.utils.LorenzColor
Expand Down Expand Up @@ -65,7 +65,7 @@ object HighlightMiningCommissionMobs {
if (type.isMob(entity)) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.YELLOW.toColor().withAlpha(127)
LorenzColor.YELLOW.toColor().addAlpha(127),
) { isEnabled() && type in active }
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ object HighlightMiningCommissionMobs {
if (type.isMob(entity)) {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
entity,
LorenzColor.YELLOW.toColor().withAlpha(127)
LorenzColor.YELLOW.toColor().addAlpha(127),
) { isEnabled() && type in active }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
Expand Down Expand Up @@ -71,8 +71,8 @@ object MarkedPlayerManager {
private fun EntityOtherPlayerMP.setColor() {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
this,
config.entityColor.get().toColor().withAlpha(127),
::isEnabled
config.entityColor.get().toColor().addAlpha(127),
::isEnabled,
)
}

Expand Down
Loading

0 comments on commit 00f7ff6

Please sign in to comment.