diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-09-20 17:13:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 23:13:19 +0200 |
commit | e026faba64c611d9b3cb6bde0337d59f02ffce63 (patch) | |
tree | e8ac547b17c56d59283a60cda6e789406198d8a4 /src/main/java/at/hannibal2/skyhanni/features/event | |
parent | 8a7be2963b08d8f5f2ca6217545a9043f4792598 (diff) | |
download | skyhanni-e026faba64c611d9b3cb6bde0337d59f02ffce63.tar.gz skyhanni-e026faba64c611d9b3cb6bde0337d59f02ffce63.tar.bz2 skyhanni-e026faba64c611d9b3cb6bde0337d59f02ffce63.zip |
Feature: Hoppity Collection Dye Recolor (#2522)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index 800ac5729..d513c3bec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils @@ -15,8 +16,10 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.consumeWhile import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.setLore import at.hannibal2.skyhanni.utils.KSerializable import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName @@ -29,9 +32,11 @@ import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMinecraftId import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -50,7 +55,7 @@ object HoppityCollectionStats { */ private val pagePattern by patternGroup.pattern( "page.current", - "(?:\\((?<page>\\d+)\\/(?<maxPage>\\d+)\\) )?Hoppity's Collection", + "(?:\\((?<page>\\d+)/(?<maxPage>\\d+)\\) )?Hoppity's Collection", ) private val duplicatesFoundPattern by patternGroup.pattern( "duplicates.found", @@ -183,6 +188,31 @@ object HoppityCollectionStats { ) @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (!config.rarityDyeRecolor || !pagePattern.matches(event.inventory.name)) return + val item = event.originalItem + // The "base" missing rabbits are Gray Dye (minecraft:dye with metadata 8) + if (item.getMinecraftId().toString() != "minecraft:dye" || item.metadata != 8) return + + val rarity = HoppityAPI.rarityByRabbit(item.displayName) + // Add NBT for the dye color itself + val newItemStack = ItemStack(Items.dye, 1, when (rarity) { + LorenzRarity.COMMON -> 7 // Light gray dye + LorenzRarity.UNCOMMON -> 10 // Lime dye + LorenzRarity.RARE -> 4 // Lapis lazuli + LorenzRarity.EPIC -> 5 // Purple dye + LorenzRarity.LEGENDARY -> 14 // Orange dye + LorenzRarity.MYTHIC -> 13 // Magenta dye + LorenzRarity.DIVINE -> 12 // Light blue dye + LorenzRarity.SPECIAL -> 1 // Rose Red - Covering bases for future (?) + else -> return + }) + newItemStack.setLore(item.getLore()) + newItemStack.setStackDisplayName(item.displayName) + event.replace(newItemStack) + } + + @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!(LorenzUtils.inSkyBlock)) return if (!pagePattern.matches(event.inventoryName)) { |