Skip to content

Commit

Permalink
fix: stop injecting fake dungeon map in boss room
Browse files Browse the repository at this point in the history
also moves the feature to dungeons category

fix inverted condition
  • Loading branch information
My-Name-Is-Jeff committed Mar 13, 2024
1 parent ec1122b commit fdb45e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
14 changes: 7 additions & 7 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
}
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fdb45e9

Please sign in to comment.