From 142a4c5dbe763b4e1906b59f76871ad156f9a608 Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:03:59 -0400 Subject: [PATCH] fix: stop injecting fake dungeon map in boss room also moves the feature to dungeons category --- .../gg/skytils/skytilsmod/core/Config.kt | 14 +++++------ .../features/impl/dungeons/DungeonFeatures.kt | 24 ++++++++++++++++++ .../features/impl/misc/MiscFeatures.kt | 25 ------------------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt index ad8ea38d9..fed3f8adc 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt @@ -180,6 +180,13 @@ object Config : Vigilant( ) var updateChannel = 2 + @Property( + type = PropertyType.SWITCH, name = "Inject Fake Dungeon Map", + description = "Injects a fake Magical Map into your hotbar to make old mods work again!\nP.S.: Use Cataclysmic Map!", + category = "Dungeons", subcategory = "Fixes" + ) + var injectFakeDungeonMap = false + @Property( type = PropertyType.SWITCH, name = "Dungeon Crypts Counter", description = "Shows the amount of crypts destroyed on your HUD.", @@ -1420,13 +1427,6 @@ object Config : Vigilant( ) var bossBarFix = false - @Property( - type = PropertyType.SWITCH, name = "Inject Fake Dungeon Map", - description = "Injects a fake Magical Map into your hotbar to make old mods work again!\nP.S.: Use Cataclysmic Map!", - category = "Miscellaneous", subcategory = "Fixes" - ) - var injectFakeDungeonMap = false - @Property( type = PropertyType.SWITCH, name = "Fix Falling Sand Rendering", description = "Adds a check to rendering in order to prevent crashes.", diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt index 109b665cf..adf7f5b04 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt @@ -28,10 +28,12 @@ import gg.skytils.skytilsmod.core.structure.GuiElement import gg.skytils.skytilsmod.events.impl.* import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent import gg.skytils.skytilsmod.events.impl.PacketEvent.ReceiveEvent +import gg.skytils.skytilsmod.features.impl.dungeons.cataclysmicmap.handlers.DungeonInfo import gg.skytils.skytilsmod.features.impl.handlers.MayorInfo import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorEnumDyeColor import gg.skytils.skytilsmod.utils.* +import gg.skytils.skytilsmod.utils.ItemUtil.setLore import gg.skytils.skytilsmod.utils.Utils.equalsOneOf import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment @@ -57,6 +59,7 @@ import net.minecraft.init.Items import net.minecraft.inventory.ContainerChest import net.minecraft.item.EnumDyeColor import net.minecraft.item.ItemSkull +import net.minecraft.item.ItemStack import net.minecraft.network.play.server.* import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB @@ -177,6 +180,8 @@ object DungeonFeatures { } } + private var fakeDungeonMap: ItemStack? = null + @SubscribeEvent fun onTick(event: ClientTickEvent) { if (event.phase != TickEvent.Phase.START || mc.thePlayer == null || mc.theWorld == null) return @@ -309,6 +314,24 @@ object DungeonFeatures { } } } + if (Skytils.config.injectFakeDungeonMap && DungeonTimer.bossEntryTime != -1L) { + (DungeonInfo.dungeonMap ?: DungeonInfo.guessMapData)?.let { + val itemInSlot = mc.thePlayer?.inventory?.getStackInSlot(8)?.item + if (itemInSlot != Items.filled_map && itemInSlot != Items.arrow) { + if (fakeDungeonMap == null) { + val guessMapId = it.mapName.substringAfter("map_").toIntOrNull() + if (guessMapId == null) { + mc.theWorld.setItemData("map_-1337", it) + } + fakeDungeonMap = ItemStack(Items.filled_map, 1337, guessMapId ?: -1337).also { + it.setStackDisplayName("§bMagical Map") + it.setLore(listOf("§7Shows the layout of the Dungeon as", "§7it is explored and completed.", "", "§cThis isn't the real map!", "§eSkytils injected this data in for you.")) + } + } + mc.thePlayer.inventory.setInventorySlotContents(8, fakeDungeonMap) + } + } + } } } @@ -740,6 +763,7 @@ object DungeonFeatures { blazes = 0 hasClearedText = false terracottaSpawns.clear() + fakeDungeonMap = null } class SpiritBearSpawnTimer : GuiElement("Spirit Bear Spawn Timer", x = 0.05f, y = 0.4f) { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt index 04e2f952b..f28624e36 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt @@ -31,13 +31,11 @@ import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.* import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent import gg.skytils.skytilsmod.events.impl.PacketEvent.ReceiveEvent -import gg.skytils.skytilsmod.features.impl.dungeons.cataclysmicmap.handlers.DungeonInfo import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorEntityArmorstand import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorWorldInfo import gg.skytils.skytilsmod.utils.* import gg.skytils.skytilsmod.utils.ItemUtil.getExtraAttributes import gg.skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID -import gg.skytils.skytilsmod.utils.ItemUtil.setLore import gg.skytils.skytilsmod.utils.NumberUtil.romanToDecimal import gg.skytils.skytilsmod.utils.NumberUtil.roundToPrecision import gg.skytils.skytilsmod.utils.RenderUtil.highlight @@ -453,8 +451,6 @@ object MiscFeatures { } } - private var fakeDungeonMap: ItemStack? = null - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!Utils.inSkyblock || event.phase != TickEvent.Phase.START || mc.thePlayer == null || mc.theWorld == null) return @@ -471,27 +467,6 @@ object MiscFeatures { } } } - (DungeonInfo.dungeonMap ?: DungeonInfo.guessMapData)?.let { - val itemInSlot = mc.thePlayer?.inventory?.getStackInSlot(8)?.item - if (Skytils.config.injectFakeDungeonMap && itemInSlot != Items.filled_map && itemInSlot != Items.arrow) { - if (fakeDungeonMap == null) { - val guessMapId = it.mapName.substringAfter("map_").toIntOrNull() - if (guessMapId == null) { - mc.theWorld.setItemData("map_-1337", it) - } - fakeDungeonMap = ItemStack(Items.filled_map, 1337, guessMapId ?: -1337).also { - it.setStackDisplayName("§bMagical Map") - it.setLore(listOf("§7Shows the layout of the Dungeon as", "§7it is explored and completed.", "", "§cThis isn't the real map! Skytils injected this data in for you.")) - } - } - mc.thePlayer.inventory.setInventorySlotContents(8, fakeDungeonMap) - } - } - } - - @SubscribeEvent - fun onWorldLoad(event: WorldEvent.Unload) { - fakeDungeonMap = null } @SubscribeEvent