diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-04-27 18:03:01 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-04-27 18:03:01 -0400 |
commit | 3459a4ca7bd73f6f115882b614c63efc1a21f543 (patch) | |
tree | 226696cc2d904a577707cadd6b5e59ea9e0e0032 /src/main | |
parent | ce2f35df0efdca2f8909da3461b5c3c9e100e01f (diff) | |
download | SkytilsMod-3459a4ca7bd73f6f115882b614c63efc1a21f543.tar.gz SkytilsMod-3459a4ca7bd73f6f115882b614c63efc1a21f543.tar.bz2 SkytilsMod-3459a4ca7bd73f6f115882b614c63efc1a21f543.zip |
Resolve: Pet highlight on single-page Pets menu
Diffstat (limited to 'src/main')
4 files changed, 40 insertions, 4 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/AccessorGuiContainer.java b/src/main/java/skytils/skytilsmod/mixins/AccessorGuiContainer.java new file mode 100644 index 00000000..0ee7684e --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/AccessorGuiContainer.java @@ -0,0 +1,35 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins; + +import net.minecraft.client.gui.inventory.GuiContainer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(GuiContainer.class) +public interface AccessorGuiContainer { + @Accessor("xSize") + int getXSize(); + @Accessor("ySize") + int getYSize(); + @Accessor("guiLeft") + int getGuiLeft(); + @Accessor("guiTop") + int getGuiTop(); +} diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/FavoritePets.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/FavoritePets.kt index 20d92824..e00201a6 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/FavoritePets.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/FavoritePets.kt @@ -83,7 +83,7 @@ class FavoritePets : PersistentSave(File(Skytils.modDir, "favoritepets.json")) { if (event.gui is GuiChest) { val chest = event.gui as GuiChest val container = chest.inventorySlots as ContainerChest - if (container.lowerChestInventory.name.endsWith(") Pets")) { + if (container.lowerChestInventory.name.endsWith(") Pets") || container.lowerChestInventory.name == "Pets") { when { event is GuiScreenEvent.InitGuiEvent -> event.buttonList.add( GuiButton( @@ -108,7 +108,7 @@ class FavoritePets : PersistentSave(File(Skytils.modDir, "favoritepets.json")) { fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (!Utils.inSkyblock || !highlighting || event.container !is ContainerChest) return val chest = event.container - if (!chest.lowerChestInventory.name.endsWith(") Pets")) return + if (!chest.lowerChestInventory.name.endsWith(") Pets") && chest.lowerChestInventory.name != "Pets") return if (event.slot == null || event.slotId < 10 || event.slotId > 43 || !event.slot.hasStack) return val item = event.slot.stack!! val petId = getPetIdFromItem(item) @@ -121,7 +121,7 @@ class FavoritePets : PersistentSave(File(Skytils.modDir, "favoritepets.json")) { fun onSlotDraw(event: GuiContainerEvent.DrawSlotEvent.Pre) { if (!Utils.inSkyblock || !Skytils.config.highlightFavoritePets || event.container !is ContainerChest) return val chest = event.container - if (!chest.lowerChestInventory.name.endsWith(") Pets")) return + if (!chest.lowerChestInventory.name.endsWith(") Pets") && chest.lowerChestInventory.name != "Pets") return if (event.slot.slotNumber < 10 || event.slot.slotNumber > 43 || !event.slot.hasStack) return val item = event.slot.stack val petId = getPetIdFromItem(item) diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/PetFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/PetFeatures.kt index f8ab18c1..eb4b8fd8 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/PetFeatures.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/PetFeatures.kt @@ -90,7 +90,7 @@ class PetFeatures { @SubscribeEvent(priority = EventPriority.LOW) fun onDraw(event: GuiContainerEvent.DrawSlotEvent.Pre) { if (!Utils.inSkyblock || event.container !is ContainerChest) return - if (Skytils.config.highlightActivePet && SBInfo.instance.lastOpenContainerName?.endsWith(") Pets") == true && event.slot.hasStack && event.slot.slotNumber in 10..43) { + if (Skytils.config.highlightActivePet && (SBInfo.instance.lastOpenContainerName?.endsWith(") Pets") == true || SBInfo.instance.lastOpenContainerName == "Pets") && event.slot.hasStack && event.slot.slotNumber in 10..43) { val item = event.slot.stack for (line in getItemLore(item)) { if (line == "§7§cClick to despawn ") { diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json index b0eeeabe..f37ccd7e 100644 --- a/src/main/resources/mixins.skytils.json +++ b/src/main/resources/mixins.skytils.json @@ -4,6 +4,7 @@ "refmap": "mixins.skytils.refmap.json", "mixins": [ "AccessorCommandHandler", + "AccessorGuiContainer", "AccessorGuiEditSign", "AccessorGuiNewChat", "AccessorMinecraft", |