aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-07 22:41:10 +0200
committerGitHub <noreply@github.com>2024-05-07 22:41:10 +0200
commit912c8d8a8c9ad412b2f94827e09a9cf262e5b69a (patch)
tree39abdb48d61f5989210e6e73a1254b36992449f3 /src/main/java/at/hannibal2/skyhanni
parent50f3954a3c0e15eb18ae864bbd28e0b645aa9d1b (diff)
downloadskyhanni-912c8d8a8c9ad412b2f94827e09a9cf262e5b69a.tar.gz
skyhanni-912c8d8a8c9ad412b2f94827e09a9cf262e5b69a.tar.bz2
skyhanni-912c8d8a8c9ad412b2f94827e09a9cf262e5b69a.zip
Feature: Mining Commissions Blocks Color (#1701)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/CommissionsBlocksColorConfig.java27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt361
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt37
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt2
14 files changed, 490 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index c10131a3b..b615238db 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -296,6 +296,7 @@ import at.hannibal2.skyhanni.features.mining.DeepCavernsGuide
import at.hannibal2.skyhanni.features.mining.GoldenGoblinHighlight
import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs
import at.hannibal2.skyhanni.features.mining.KingTalismanHelper
+import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor
import at.hannibal2.skyhanni.features.mining.MiningNotifications
import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore
import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsWalls
@@ -814,6 +815,7 @@ class SkyHanniMod {
loadModule(ShowItemUuid())
loadModule(FrozenTreasureTracker)
loadModule(MiningEventDisplay)
+ loadModule(MiningCommissionsBlocksColor)
loadModule(SlayerRngMeterDisplay())
loadModule(GhostCounter)
loadModule(RiftTimer())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/CommissionsBlocksColorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CommissionsBlocksColorConfig.java
new file mode 100644
index 000000000..3afc3b11e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CommissionsBlocksColorConfig.java
@@ -0,0 +1,27 @@
+package at.hannibal2.skyhanni.config.features.mining;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.utils.LorenzColor;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import io.github.notenoughupdates.moulconfig.observer.Property;
+
+public class CommissionsBlocksColorConfig {
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Change the color of ores on mining island depending on your active commissions. Gray out irrelevant ores.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Sneak Toggle", desc = "Quickly disable or enable this feature via sneaking.")
+ @ConfigEditorBoolean
+ public Property<Boolean> sneakQuickToggle = Property.of(false);
+
+ @Expose
+ @ConfigOption(name = "Color", desc = "Change the highlight color.")
+ @ConfigEditorDropdown
+ public Property<LorenzColor> color = Property.of(LorenzColor.GREEN);
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
index 38f05a948..b529a7c91 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
@@ -48,6 +48,11 @@ public class MiningConfig {
public MiningNotificationsConfig notifications = new MiningNotificationsConfig();
@Expose
+ @ConfigOption(name = "Commissions Blocks Color", desc = "")
+ @Accordion
+ public CommissionsBlocksColorConfig commissionsBlocksColor = new CommissionsBlocksColorConfig();
+
+ @Expose
@ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
index 45a31fc37..1124e7946 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
@@ -19,7 +19,7 @@ import kotlin.time.Duration.Companion.seconds
object MiningAPI {
private val group = RepoPattern.group("data.miningapi")
- private val glaciteAreaPattern by group.pattern("area.glacite", "Glacite Tunnels")
+ private val glaciteAreaPattern by group.pattern("area.glacite", "Glacite Tunnels|Glacite Lake")
val coldReset by group.pattern(
"cold.reset",
"§6The warmth of the campfire reduced your §r§b❄ Cold §r§6to §r§a0§r§6!|§c ☠ §r§7You froze to death§r§7."
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
index 99aad9022..12228a7c9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
@@ -67,7 +67,7 @@ object GriffinBurrowParticleFinder {
if (particleType != null) {
val location = packet.toLorenzVec().toBlockPos().down().toLorenzVec()
- if (recentlyDugParticleBurrows.contains(location)) return
+ if (location in recentlyDugParticleBurrows) return
val burrow = burrows.getOrPut(location) { Burrow(location) }
when (particleType) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
index c5c73949d..07d96854b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt
@@ -23,8 +23,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class HighlightMiningCommissionMobs {
private val config get() = SkyHanniMod.feature.mining
+ // TODO Commissin API
private var active = listOf<MobType>()
+ // TODO Commissin API
enum class MobType(val commissionName: String, val isMob: (EntityLivingBase) -> Boolean) {
// Dwarven Mines
@@ -43,6 +45,8 @@ class HighlightMiningCommissionMobs {
it is EntitySlime && (it.hasMaxHealth(5_000) || it.hasMaxHealth(10_000) || it.hasMaxHealth(25_000))
}),
CH_GOBLIN_SLAYER("Goblin Slayer", { it.name == "Weakling " }),
+
+ // new commissions
;
}
@@ -67,6 +71,7 @@ class HighlightMiningCommissionMobs {
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!isEnabled()) return
+ // TODO Commissin API
MobType.entries.filter { type ->
event.tabList.findLast { line -> line.removeColor().trim().startsWith(type.commissionName) }
?.let { !it.endsWith("§aDONE") }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt
new file mode 100644
index 000000000..0c2cdba51
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt
@@ -0,0 +1,361 @@
+package at.hannibal2.skyhanni.features.mining
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.DebugDataCollectEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.TabListUpdateEvent
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
+import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.TimeLimitedSet
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.block.BlockCarpet
+import net.minecraft.block.state.IBlockState
+import net.minecraft.client.Minecraft
+import net.minecraft.init.Blocks
+import net.minecraft.item.EnumDyeColor
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+object MiningCommissionsBlocksColor {
+
+ private val config get() = SkyHanniMod.feature.mining.commissionsBlocksColor
+
+ var enabled = false
+ var active = false
+
+ private val patternGroup = RepoPattern.group("mining.commissions")
+
+ /**
+ * REGEX-TEST: §a§lCITRINE GEMSTONE COLLECTOR §r§eCommission Complete! Visit the King §r§eto claim your rewards!
+ */
+ private val commissionCompletePattern by patternGroup.pattern(
+ "complete",
+ "§a§l(?<name>.*) §r§eCommission Complete! Visit the King §r§eto claim your rewards!"
+ )
+
+ var color: EnumDyeColor = EnumDyeColor.RED
+
+ private fun glass() = { state: IBlockState, result: Boolean ->
+ if (result) {
+ state.withProperty(BlockCarpet.COLOR, color)
+ } else {
+ state.withProperty(BlockCarpet.COLOR, EnumDyeColor.GRAY)
+ }
+ }
+
+ private fun block() = { _: IBlockState, result: Boolean ->
+ val wool = Blocks.wool.defaultState
+ if (result) {
+ wool.withProperty(BlockCarpet.COLOR, color)
+ } else {
+ wool.withProperty(BlockCarpet.COLOR, EnumDyeColor.GRAY)
+ }
+ }
+
+ val aquamarine = Blocks.stained_glass
+ val aquamarine_2 = Blocks.stained_glass_pane
+
+ val citrine = Blocks.stained_glass
+ val citrine_2 = Blocks.stained_glass_pane
+
+ val glacite = Blocks.packed_ice
+
+ val onyx = Blocks.stained_glass
+ val onyx_2 = Blocks.stained_glass_pane
+
+ val umber = Blocks.hardened_clay
+ val umber_2 = Blocks.stained_hardened_clay
+ val umber_3 = Blocks.double_stone_slab2 // red sandstone
+
+ val peridot = Blocks.stained_glass
+ val peridot_2 = Blocks.stained_glass_pane
+
+ val tungston = Blocks.cobblestone
+ val tungston_2 = Blocks.stone_stairs
+ val tungston_3 = Blocks.clay
+
+ val mithril = Blocks.stained_hardened_clay
+ val mithril_2 = Blocks.wool
+ val mithril_3 = Blocks.prismarine
+
+ private var oldSneakState = false
+
+ private var dirty = false
+ private var forceDirty = false
+
+ private var inDwarvenMines = false
+ private var inCrystalHollows = false
+ private var inGlaciteArea = false
+
+ // TODO Commissin API
+ @SubscribeEvent
+ fun onTabListUpdate(event: TabListUpdateEvent) {
+ for (block in MiningBlock.entries) {
+ val tabList = " §r§f${block.displayName}: "
+ val newValue = event.tabList.any { it.startsWith(tabList) && !it.contains("DONE") }
+ if (block.highlight != newValue) {
+ if (newValue && block in ignoredTabListCommissions) continue
+ block.highlight = newValue
+ ChatUtils.debug("changed from tab list: ${block.displayName} -> $newValue")
+ dirty = true
+ }
+ }
+ }
+
+ private val ignoredTabListCommissions = TimeLimitedSet<MiningBlock>(5.seconds)
+
+ // TODO Commissin API
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!enabled) return
+ commissionCompletePattern.matchMatcher(event.message) {
+ val name = group("name")
+ val block = MiningBlock.entries.find { it.displayName.equals(name, ignoreCase = true) } ?: return
+ block.highlight = false
+ dirty = true
+ ignoredTabListCommissions.add(block)
+ ChatUtils.debug("finished from chat: $name")
+ }
+ }
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (LorenzUtils.lastWorldSwitch.passedSince() > 4.seconds) {
+ inGlaciteArea = MiningAPI.inGlaciteArea()
+ inDwarvenMines = IslandType.DWARVEN_MINES.isInIsland() && !(inGlaciteArea ||
+ HypixelData.skyBlockArea.equalsOneOf("Dwarven Base Camp", "Fossil Research Center")
+ )
+ inCrystalHollows = IslandType.CRYSTAL_HOLLOWS.isInIsland() && HypixelData.skyBlockArea != "Crystal Nucleus"
+ }
+
+ val newEnabled = (inDwarvenMines || inCrystalHollows || inGlaciteArea) && config.enabled
+ var reload = false
+ if (newEnabled != enabled) {
+ enabled = newEnabled
+ reload = true
+ if (enabled) {
+ active = true
+ }
+ }
+
+ if (enabled) {
+ if (config.sneakQuickToggle.get()) {
+ val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking
+ if (sneaking != oldSneakState) {
+ oldSneakState = sneaking
+ if (oldSneakState) {
+ active = !active
+ dirty = true
+ }
+ }
+ }
+ if (dirty) {
+ reload = true
+ }
+ }
+
+ if (reload) {
+ Minecraft.getMinecraft().renderGlobal.loadRenderers()
+ dirty = false
+ }
+ }
+
+ @SubscribeEvent
+ fun onConfigReload(event: ConfigLoadEvent) {
+ color = config.color.get().toDyeColor()
+ config.sneakQuickToggle.onToggle {
+ oldSneakState = false
+ if (!active) {
+ active = true
+ dirty = true
+ }
+ }
+ config.color.onToggle {
+ color = config.color.get().toDyeColor()
+ dirty = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ enabled = false
+ inDwarvenMines = false
+ inCrystalHollows = false
+ inGlaciteArea = false
+ }
+
+ @SubscribeEvent
+ fun onDebugDataCollect(event: DebugDataCollectEvent) {
+ event.title("Mining Commissions Blocks Color")
+ if (!enabled) {
+ event.addIrrelevant("not enabled")
+ return
+ }
+
+ event.addData {
+ add("inDwarvenMines: $inDwarvenMines")
+ add("inCrystalHollows: $inCrystalHollows")
+ add("inGlaciteArea: $inGlaciteArea")
+ add("active: $active")
+ }
+ }
+
+ enum class MiningBlock(
+ val displayName: String,
+ val onCheck: (IBlockState) -> Boolean,
+ val onColor: (IBlockState, Boolean) -> IBlockState,
+ var highlight: Boolean = false,
+ val checkIsland: () -> Boolean,
+ ) {
+ // Dwarven Mines
+ MITHRIL(
+ "Mithril Everywhere",
+ onCheck = { state ->
+ (state.block == mithril && state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.CYAN)) ||
+ (state.block == mithril_2 && (state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.GRAY) ||
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIGHT_BLUE))) ||
+ state.block == mithril_3
+ },
+ onColor = block(),
+ checkIsland = { true }
+ ),
+
+ // Crystal Hollows
+ AMBER(
+ "Amber Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.ORANGE)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ TOPAZ(
+ "Topaz Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.YELLOW)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ AMETHYST(
+ "Amethyst Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.PURPLE)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ RUBY(
+ "Ruby Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.RED)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ JADE(
+ "Jade Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIME)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ SAPPHIRE(
+ "Sapphire Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIGHT_BLUE)
+ },
+ onColor = glass(),
+ checkIsland = { !inDwarvenMines }
+ ),
+ HARD_STONE(
+ "Hardstone Miner",
+ onCheck = { state ->
+ state.block == glacite
+ },
+ onColor = block(),
+ checkIsland = { !inDwarvenMines }
+ ),
+
+ // Glacite Tunnels
+ GLACITE(
+ "Glacite Collector",
+ onCheck = { state ->
+ state.block == glacite
+ },
+ onColor = block(),
+ checkIsland = { inGlaciteArea }
+ ),
+ UMBER(
+ "Umber Collector",
+ onCheck = { state ->
+ (state.block == umber || state.block == umber_3) ||
+ (state.block == umber_2 && state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BROWN))
+ },
+ onColor = block(),
+ checkIsland = { inGlaciteArea }
+ ),
+ TUNGSTON(
+ "Tungsten Collector",
+ onCheck = { state ->
+ state.block == tungston || state.block == tungston_2 || state.block == tungston_3
+ },
+ onColor = block(),
+ checkIsland = { inGlaciteArea }
+ ),
+ PERIDOT(
+ "Peridot Gemstone Collector",
+ onCheck = { state ->
+ (state.block == peridot || state.block == peridot_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.GREEN)
+ },
+ onColor = glass(),
+ checkIsland = { inGlaciteArea }
+ ),
+ AQUAMARINE(
+ "Aquamarine Gemstone Collector",
+ onCheck = { state ->
+ (state.block == aquamarine || state.block == aquamarine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BLUE)
+ },
+ onColor = glass(),
+ checkIsland = { inGlaciteArea }
+ ),
+ CITRINE(
+ "Citrine Gemstone Collector",
+ onCheck = { state ->
+ (state.block == citrine || state.block == citrine_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BROWN)
+ },
+ onColor = glass(),
+ checkIsland = { inGlaciteArea }
+ ),
+ ONYX(
+ "Onyx Gemstone Collector",
+ onCheck = { state ->
+ (state.block == onyx || state.block == onyx_2) &&
+ state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BLACK)
+ },
+ onColor = glass(),
+ checkIsland = { inGlaciteArea }
+ ),
+ ;
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt
index f3d2e1a39..534f8bc02 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt
@@ -37,7 +37,7 @@ class VerminHighlighter {
for (entity in EntityUtils.getEntities<EntityLivingBase>()) {
val id = entity.entityId
- if (checkedEntites.contains(id)) continue
+ if (id in checkedEntites) continue
checkedEntites.add(id)
if (!isVermin(entity)) continue
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt
new file mode 100644
index 000000000..5903136fa
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt
@@ -0,0 +1,35 @@
+package at.hannibal2.skyhanni.mixins.hooks
+
+import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.block.state.IBlockState
+import net.minecraft.client.renderer.BlockRendererDispatcher
+import net.minecraft.client.resources.model.IBakedModel
+import net.minecraft.util.BlockPos
+import net.minecraft.world.IBlockAccess
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
+
+fun modifyGetModelFromBlockState(
+ blockRendererDispatcher: BlockRendererDispatcher,
+ state: IBlockState?,
+ worldIn: IBlockAccess,
+ pos: BlockPos?,
+ cir: CallbackInfoReturnable<IBakedModel>,
+) {
+ if (state == null || pos == null) return
+ var returnState: IBlockState = state
+
+ if (!LorenzUtils.inSkyBlock) return
+
+ if (MiningCommissionsBlocksColor.enabled && MiningCommissionsBlocksColor.active) {
+ for (block in MiningCommissionsBlocksColor.MiningBlock.entries) {
+ if (block.checkIsland() && block.onCheck(state)) {
+ returnState = block.onColor(state, block.highlight)
+ }
+ }
+ }
+
+ if (returnState !== state) {
+ cir.returnValue = blockRendererDispatcher.blockModelShapes.getModelForState(returnState)
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java
new file mode 100644
index 000000000..6269e17f9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java
@@ -0,0 +1,21 @@
+package at.hannibal2.skyhanni.mixins.transformers.renderer;
+
+import at.hannibal2.skyhanni.mixins.hooks.BlockRendererDispatcherHookKt;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.renderer.BlockRendererDispatcher;
+import net.minecraft.client.resources.IResourceManagerReloadListener;
+import net.minecraft.client.resources.model.IBakedModel;
+import net.minecraft.util.BlockPos;
+import net.minecraft.world.IBlockAccess;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(BlockRendererDispatcher.class)
+public abstract class MixinBlockRendererDispatcher implements IResourceManagerReloadListener {
+ @Inject(method = "getModelFromBlockState", at = @At("RETURN"), cancellable = true)
+ private void modifyGetModelFromBlockState(IBlockState state, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<IBakedModel> cir) {
+ BlockRendererDispatcherHookKt.modifyGetModelFromBlockState((BlockRendererDispatcher) (Object) this, state, worldIn, pos, cir);
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
index 622aaeba1..95507c2b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
@@ -118,7 +118,7 @@ object ErrorManager {
val pair = if (throwable.stackTrace.isNotEmpty()) {
throwable.stackTrace[0].let { (it.fileName ?: "<unknown>") to it.lineNumber }
} else message to 0
- if (cache.contains(pair)) return
+ if (pair in cache) return
cache.add(pair)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
index 2da2fbda2..53ae224d9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
@@ -49,7 +49,7 @@ object CollectionUtils {
// Taken and modified from Skytils
@JvmStatic
- fun <T> T.equalsOneOf(vararg other: T): Boolean {
+ fun <T> T?.equalsOneOf(vararg other: T): Boolean {
for (obj in other) {
if (this == obj) return true
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
index e577ba28f..16fe8cd6e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
@@ -1,6 +1,5 @@
package at.hannibal2.skyhanni.utils
-import at.hannibal2.skyhanni.test.command.ErrorManager
import net.minecraft.item.EnumDyeColor
import java.awt.Color
@@ -40,11 +39,33 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
fun toConfigColour(): String = "0:255:${color.red}:${color.green}:${color.blue}"
+ fun toDyeColor(): EnumDyeColor = when (this) {
+ WHITE -> EnumDyeColor.WHITE
+ GOLD -> EnumDyeColor.ORANGE
+ AQUA -> EnumDyeColor.MAGENTA
+ BLUE -> EnumDyeColor.LIGHT_BLUE
+ YELLOW -> EnumDyeColor.YELLOW
+ GREEN -> EnumDyeColor.LIME
+ LIGHT_PURPLE -> EnumDyeColor.PINK
+ DARK_GRAY -> EnumDyeColor.GRAY
+ GRAY -> EnumDyeColor.SILVER
+ DARK_AQUA -> EnumDyeColor.CYAN
+ DARK_PURPLE -> EnumDyeColor.PURPLE
+ DARK_BLUE -> EnumDyeColor.BLUE
+// GOLD -> EnumDyeColor.BROWN
+ DARK_GREEN -> EnumDyeColor.GREEN
+ DARK_RED -> EnumDyeColor.RED
+ BLACK -> EnumDyeColor.BLACK
+ RED -> EnumDyeColor.RED
+
+ CHROMA -> EnumDyeColor.WHITE
+ }
+
companion object {
fun EnumDyeColor.toLorenzColor() = when (this) {
EnumDyeColor.WHITE -> WHITE
- EnumDyeColor.MAGENTA -> LIGHT_PURPLE
+ EnumDyeColor.MAGENTA -> AQUA
EnumDyeColor.PINK -> LIGHT_PURPLE
EnumDyeColor.RED -> RED
EnumDyeColor.SILVER -> GRAY
@@ -54,13 +75,11 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
EnumDyeColor.BLUE -> BLUE
EnumDyeColor.PURPLE -> DARK_PURPLE
EnumDyeColor.YELLOW -> YELLOW
- else -> {
- ErrorManager.logErrorWithData(
- Exception("Unknown dye color: $this"),
- "Unknown dye color: $this"
- )
- null
- }
+ EnumDyeColor.ORANGE -> GOLD
+ EnumDyeColor.LIGHT_BLUE -> BLUE
+ EnumDyeColor.CYAN -> DARK_AQUA
+ EnumDyeColor.BROWN -> GOLD
+ EnumDyeColor.BLACK -> BLACK
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
index e64c55213..39dac5247 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
@@ -8,7 +8,7 @@ class TimeLimitedSet<T>(expireAfterWrite: Duration) {
fun add(element: T) = cache.put(element, Unit)
- fun contains(element: T): Boolean = cache.containsKey(element)
+ operator fun contains(element: T): Boolean = cache.containsKey(element)
fun clear() = cache.clear()