Skip to content

Commit 5408e55

Browse files
feat: add Inject Fake Dungeon Map
1 parent db235ba commit 5408e55

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,13 @@ object Config : Vigilant(
14211421
)
14221422
var bossBarFix = false
14231423

1424+
@Property(
1425+
type = PropertyType.SWITCH, name = "Inject Fake Dungeon Map",
1426+
description = "Injects a fake Magical Map into your hotbar to make old mods work again!\nP.S.: Use Cataclysmic Map!",
1427+
category = "Miscellaneous", subcategory = "Fixes"
1428+
)
1429+
var injectFakeDungeonMap = false
1430+
14241431
@Property(
14251432
type = PropertyType.SWITCH, name = "Fix Falling Sand Rendering",
14261433
description = "Adds a check to rendering in order to prevent crashes.",

src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import gg.skytils.skytilsmod.core.tickTimer
3131
import gg.skytils.skytilsmod.events.impl.*
3232
import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent
3333
import gg.skytils.skytilsmod.events.impl.PacketEvent.ReceiveEvent
34+
import gg.skytils.skytilsmod.features.impl.dungeons.cataclysmicmap.handlers.DungeonInfo
3435
import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorEntityArmorstand
3536
import gg.skytils.skytilsmod.mixins.transformers.accessors.AccessorWorldInfo
3637
import gg.skytils.skytilsmod.utils.*
3738
import gg.skytils.skytilsmod.utils.ItemUtil.getExtraAttributes
3839
import gg.skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID
40+
import gg.skytils.skytilsmod.utils.ItemUtil.setLore
3941
import gg.skytils.skytilsmod.utils.NumberUtil.romanToDecimal
4042
import gg.skytils.skytilsmod.utils.NumberUtil.roundToPrecision
4143
import gg.skytils.skytilsmod.utils.RenderUtil.highlight
@@ -78,6 +80,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent
7880
import net.minecraftforge.event.entity.EntityJoinWorldEvent
7981
import net.minecraftforge.event.entity.living.EnderTeleportEvent
8082
import net.minecraftforge.event.entity.player.ItemTooltipEvent
83+
import net.minecraftforge.event.world.WorldEvent
8184
import net.minecraftforge.fml.common.Loader
8285
import net.minecraftforge.fml.common.eventhandler.Event
8386
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -450,6 +453,8 @@ object MiscFeatures {
450453
}
451454
}
452455

456+
private var fakeDungeonMap: ItemStack? = null
457+
453458
@SubscribeEvent
454459
fun onTick(event: TickEvent.ClientTickEvent) {
455460
if (!Utils.inSkyblock || event.phase != TickEvent.Phase.START || mc.thePlayer == null || mc.theWorld == null) return
@@ -466,6 +471,27 @@ object MiscFeatures {
466471
}
467472
}
468473
}
474+
(DungeonInfo.dungeonMap ?: DungeonInfo.guessMapData)?.let {
475+
val itemInSlot = mc.thePlayer?.inventory?.getStackInSlot(8)?.item
476+
if (Skytils.config.injectFakeDungeonMap && itemInSlot != Items.filled_map && itemInSlot != Items.arrow) {
477+
if (fakeDungeonMap == null) {
478+
val guessMapId = it.mapName.substringAfter("map_").toIntOrNull()
479+
if (guessMapId == null) {
480+
mc.theWorld.setItemData("map_-1337", it)
481+
}
482+
fakeDungeonMap = ItemStack(Items.filled_map, 1337, guessMapId ?: -1337).also {
483+
it.setStackDisplayName("§bMagical Map")
484+
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."))
485+
}
486+
}
487+
mc.thePlayer.inventory.setInventorySlotContents(8, fakeDungeonMap)
488+
}
489+
}
490+
}
491+
492+
@SubscribeEvent
493+
fun onWorldLoad(event: WorldEvent.Unload) {
494+
fakeDungeonMap = null
469495
}
470496

471497
@SubscribeEvent

0 commit comments

Comments
 (0)