From 170c6504bdb949c5dd133514b3db91823169cbad Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 19 May 2023 05:37:40 -0500 Subject: organization into better files --- src/main/kotlin/dulkirmod/features/Croesus.kt | 84 -------- .../kotlin/dulkirmod/features/DragonFeatures.kt | 217 --------------------- src/main/kotlin/dulkirmod/features/DungeonLeap.kt | 54 ----- .../kotlin/dulkirmod/features/HideHealerFairy.kt | 36 ---- src/main/kotlin/dulkirmod/features/SecretSounds.kt | 93 --------- .../kotlin/dulkirmod/features/dungeons/Croesus.kt | 84 ++++++++ .../dulkirmod/features/dungeons/DragonFeatures.kt | 217 +++++++++++++++++++++ .../dulkirmod/features/dungeons/DungeonLeap.kt | 54 +++++ .../dulkirmod/features/dungeons/HideHealerFairy.kt | 36 ++++ .../dulkirmod/features/dungeons/SecretSounds.kt | 93 +++++++++ 10 files changed, 484 insertions(+), 484 deletions(-) delete mode 100644 src/main/kotlin/dulkirmod/features/Croesus.kt delete mode 100644 src/main/kotlin/dulkirmod/features/DragonFeatures.kt delete mode 100644 src/main/kotlin/dulkirmod/features/DungeonLeap.kt delete mode 100644 src/main/kotlin/dulkirmod/features/HideHealerFairy.kt delete mode 100644 src/main/kotlin/dulkirmod/features/SecretSounds.kt create mode 100644 src/main/kotlin/dulkirmod/features/dungeons/Croesus.kt create mode 100644 src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt create mode 100644 src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt create mode 100644 src/main/kotlin/dulkirmod/features/dungeons/HideHealerFairy.kt create mode 100644 src/main/kotlin/dulkirmod/features/dungeons/SecretSounds.kt diff --git a/src/main/kotlin/dulkirmod/features/Croesus.kt b/src/main/kotlin/dulkirmod/features/Croesus.kt deleted file mode 100644 index 9369140..0000000 --- a/src/main/kotlin/dulkirmod/features/Croesus.kt +++ /dev/null @@ -1,84 +0,0 @@ -package dulkirmod.features - -import dulkirmod.DulkirMod.Companion.mc -import dulkirmod.config.DulkirConfig -import dulkirmod.utils.ContainerNameUtil -import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.inventory.Slot -import net.minecraft.nbt.NBTTagList -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -object Croesus { - - var lastGuiOpenEvent: Long = 0 - var lastPageNumber = 1 - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - val lastInCroesus = inCroesusBool - var pageNumber = 1 - - if (!DulkirConfig.hideOpenedChests) return - if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { - inCroesusBool = false - return - } - inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") - - if (inCroesusBool) { - pageNumber = findPageNumber() - } - - // weird way of detecting page turn - if (lastPageNumber != pageNumber) - lastGuiOpenEvent = System.currentTimeMillis() - - if (inCroesusBool && !lastInCroesus) { - lastGuiOpenEvent = System.currentTimeMillis() - } - - if (inCroesusBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { - for (i in 9..44) { - boolArray[i - 9] = false - val slotIn = mc.thePlayer.openContainer.getSlot(i) - - if (slotIn.stack == null) continue - val stack = slotIn.stack - - val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue - for (j in 0 until tagList.tagCount()) { - if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true - } - } - } - } - - private fun findPageNumber(): Int { - val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber - - val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1 - - if (stackPrevLore.getStringTagAt(0).contains("1")) return 2 - - return 3 - } - - var inCroesusBool: Boolean = false - - var boolArray = BooleanArray(36) { false } - - @JvmStatic - fun inCroesus(): Boolean { - return inCroesusBool - } - - @JvmStatic - fun isChestOpened(slotIn: Slot): Boolean { - if (!inCroesusBool) return false - if (slotIn.inventory == mc.thePlayer.inventory) return false - val slotindex = slotIn.slotIndex - if (slotindex !in 9..44) return false - return boolArray[slotindex - 9] - } -} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/DragonFeatures.kt b/src/main/kotlin/dulkirmod/features/DragonFeatures.kt deleted file mode 100644 index 9a120fc..0000000 --- a/src/main/kotlin/dulkirmod/features/DragonFeatures.kt +++ /dev/null @@ -1,217 +0,0 @@ -package dulkirmod.features - -import dulkirmod.DulkirMod.Companion.mc -import dulkirmod.config.DulkirConfig -import dulkirmod.utils.ScoreBoardUtils -import dulkirmod.utils.WorldRenderUtils -import net.minecraft.util.BlockPos -import net.minecraft.util.Vec3 -import net.minecraft.world.World -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import kotlin.math.max - -object DragonFeatures { - data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) - data class Waypoint(val pos: Vec3, val color: String) - - private val dragons = arrayOf( - Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), - Dragon("red", Vec3(27.0, 18.0, 56.0), 0), - Dragon("green", Vec3(26.0, 18.0, 95.0), 0), - Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), - Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) - ) - - private val gyros = arrayOf( - Waypoint(Vec3(83.5,5.5,104.5), "blue"), // blue - Waypoint(Vec3(25.5, 5.5, 81.5), "green") // green - ) - private val decoys = arrayOf( - Waypoint(Vec3(37.5, 14.5, 44.5), "red"), // red - Waypoint(Vec3(56.5, 7.5, 124.5), "purple"), // purple - Waypoint(Vec3(90.5, 11.5, 100.5), "blue"), // blue - Waypoint(Vec3(21.5, 11.5, 88.5), "green") // green - ) - private val shoot = arrayOf( - Waypoint(Vec3(56.5, 20.5, 124.5), "purple"), // purple - Waypoint(Vec3(84.5, 20.5, 59.5), "orange"), // orange - Waypoint(Vec3(23.5,21.5, 54.5), "red"), // red - Waypoint(Vec3(27.5, 16.5, 94.5), "green"), // green - Waypoint(Vec3(85.5, 20.5, 98.5), "blue") // blue - ) - - private var greenAlive = true - private var blueAlive = true - private var redAlive = true - private var orangeAlive = true - private var purpleAlive = true - - /** - * Called from within the MixinWorld Class - */ - fun handleNewParticle(pID: Int, x: Double, y: Double, z: Double) { - if (!DulkirConfig.dragonTimer) return - if (!ScoreBoardUtils.isInM7) return - - if (pID != 26) return - - val particleVec = Vec3(x, y, z) - dragons.forEach { - if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach - it.spawnTime = System.currentTimeMillis() - } - } - - @SubscribeEvent - fun onRenderWorld(event: RenderWorldLastEvent) { - renderDragonBoxes() - - if (!DulkirConfig.dragonTimer) return - if (!ScoreBoardUtils.isInM7) return - - val curTime = System.currentTimeMillis() - dragons.forEach { - if (it.spawnTime + 5000 < curTime || !isAlive(it.color)) return@forEach - val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f - val color = when { - timeUntilSpawn <= 1 -> "§c" - timeUntilSpawn <= 3 -> "§e" - else -> "§a" - } - - val scale = max(1.0, mc.thePlayer.positionVector.distanceTo(it.pos) / 5.0).toFloat() - - WorldRenderUtils.renderString( - it.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", false, scale, true - ) - } - } - - - fun updateDragonDead() { - if (!(DulkirConfig.dragonKillBox || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints || DulkirConfig.gyroWaypoints)) return - if (!ScoreBoardUtils.isInM7) return - if (mc.theWorld == null) return - if (mc.thePlayer.positionVector.yCoord > 45) return - - val world: World = mc.theWorld - - orangeAlive = !world.isAirBlock(BlockPos(90, 21, 56)) - redAlive = !world.isAirBlock(BlockPos(22, 20 , 59)) - greenAlive = !world.isAirBlock(BlockPos(22, 21, 94)) - purpleAlive = !world.isAirBlock(BlockPos(56, 20, 130)) - blueAlive = !world.isAirBlock(BlockPos(89, 21, 94)) - } - - /** - * true = dead - */ - private fun isAlive(color: String): Boolean { - return when (color) { - "orange" -> orangeAlive - "red" -> redAlive - "green" -> greenAlive - "purple" -> purpleAlive - "blue" -> blueAlive - else -> false - } - } - - private fun inRangeOf(color: String, pos: Vec3): Boolean { - val x = pos.xCoord.toInt() - val y = pos.yCoord.toInt() - val z = pos.zCoord.toInt() - - return when (color) { - "orange" -> { - x in 82..88 && y in 15..22 && z in 53..59 - } - - "red" -> { - x in 24..30 && y in 15..22 && z in 56..62 - } - - "green" -> { - x in 23..29 && y in 15..22 && z in 91..97 - } - - "purple" -> { - x in 53..59 && y in 15..22 && z in 122..128 - } - - "blue" -> { - x in 82..88 && y in 15..22 && z in 91..97 - } - - else -> { - false - } - } - } - - private fun renderDragonBoxes() { - if (!DulkirConfig.dragonKillBox) return - if (!ScoreBoardUtils.isInM7) return - if (mc.thePlayer.positionVector.yCoord > 45) return - // Blue - if (isAlive("blue")) - WorldRenderUtils.drawCustomBox(71.5, 25.0, 16.0, 10.0, 82.5, 25.0, Color(0, 170, 170, 255), 3f, phase = false) - // Purple - if (isAlive("purple")) - WorldRenderUtils.drawCustomBox(45.5, 23.0, 13.0, 10.0, 113.5, 23.0, Color(170, 0, 170, 255), 3f, phase = false) - // Green - if (isAlive("green")) - WorldRenderUtils.drawCustomBox(7.0, 30.0, 8.0, 20.0, 80.0, 30.0, Color(85, 255, 85, 255), 3f, phase = false) - // Red - if (isAlive("red")) - WorldRenderUtils.drawCustomBox(14.5, 25.0, 13.0, 15.0, 45.5, 25.0, Color(255, 85, 85, 255), 3f, phase = false) - // Orange - if (isAlive("orange")) - WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 29.0, Color(255, 170, 0, 255), 3f, phase = false) - } - - @SubscribeEvent - fun updateM7Check(event: WorldEvent.Load) { - val executor = Executors.newSingleThreadScheduledExecutor() - executor.schedule({ - ScoreBoardUtils.inM7() - }, 10, TimeUnit.SECONDS) - } - - @SubscribeEvent - fun renderP5Waypoints(event: RenderWorldLastEvent) { - if (!(DulkirConfig.gyroWaypoints || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints)) return - if (!ScoreBoardUtils.isInM7) return - val playerVec = mc.thePlayer.positionVector - if (playerVec.yCoord > 45) return - if (DulkirConfig.gyroWaypoints) { - val color = "§6" - for (g in gyros) { - if (!isAlive(g.color)) continue - WorldRenderUtils.drawCustomBox(g.pos.xCoord - .5, 1.0, g.pos.yCoord -.5, 1.0, g.pos.zCoord -.5, 1.0, Color(125, 87, 10, 255), 3f, phase = true) - WorldRenderUtils.renderString(g.pos.add(Vec3(0.0, 1.0,0.0)), "${color}Gyro", false, max(1f, playerVec.distanceTo(g.pos).toFloat()/10f), false) - } - } - if (DulkirConfig.lbWaypoints) { - val color = "§a" - for (s in shoot) { - if (!isAlive(s.color)) continue - WorldRenderUtils.drawCustomBox(s.pos.xCoord - .5, 1.0, s.pos.yCoord -.5, 1.0, s.pos.zCoord -.5, 1.0, Color(27, 99, 18, 255), 3f, phase = true) - WorldRenderUtils.renderString(s.pos, "${color}Target", false, max(1f, playerVec.distanceTo(s.pos).toFloat()/10f), false) - } - } - if (DulkirConfig.decoyWaypoints) { - val color = "§3" - for (d in decoys) { - if (!isAlive(d.color)) continue - WorldRenderUtils.drawCustomBox(d.pos.xCoord - .5, 1.0, d.pos.yCoord -.5, 1.0, d.pos.zCoord -.5, 1.0, Color(33, 62, 209), 3f, phase = true) - WorldRenderUtils.renderString(d.pos, "${color}Decoy", false, max(1f, playerVec.distanceTo(d.pos).toFloat()/10f), false) - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt deleted file mode 100644 index 5185516..0000000 --- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt +++ /dev/null @@ -1,54 +0,0 @@ -package dulkirmod.features - -import dulkirmod.DulkirMod.Companion.mc -import dulkirmod.config.DulkirConfig -import dulkirmod.utils.ContainerNameUtil -import dulkirmod.utils.Utils -import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.inventory.Slot -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -object DungeonLeap { - var inLeapMenu = false - var leapPlayers = BooleanArray(5) { false } - - private var lastGuiOpenEvent = 0L - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - val lastInLeap = inLeapMenu - - if (!DulkirConfig.highlightLeap) return - if (mc.currentScreen == null || mc.currentScreen !is GuiChest) { - inLeapMenu = false - return - } - inLeapMenu = (ContainerNameUtil.currentGuiChestName == "Spirit Leap") - - if (inLeapMenu && !lastInLeap) { - lastGuiOpenEvent = System.currentTimeMillis() - } - - if (inLeapMenu && System.currentTimeMillis() - lastGuiOpenEvent < 300) { - for (i in 11..15) { - leapPlayers[i - 11] = false - val slotIn = mc.thePlayer.openContainer.getSlot(i) - - if (slotIn.stack == null) continue - val stack = slotIn.stack - if (Utils.stripColorCodes(stack.displayName).equals(DulkirConfig.highlightLeapName, true)) { - leapPlayers[i - 11] = true - } - } - } - } - - fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { - if (!inLeapMenu) return false - if (slotIn.inventory == mc.thePlayer.inventory) return false - val slotIndex = slotIn.slotIndex - if (slotIndex !in 11..15) return false - return leapPlayers[slotIndex - 11] - } -} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/HideHealerFairy.kt b/src/main/kotlin/dulkirmod/features/HideHealerFairy.kt deleted file mode 100644 index d77d0f7..0000000 --- a/src/main/kotlin/dulkirmod/features/HideHealerFairy.kt +++ /dev/null @@ -1,36 +0,0 @@ -package dulkirmod.features - - -import dulkirmod.DulkirMod.Companion.config -import dulkirmod.utils.TabListUtils -import net.minecraft.entity.Entity -import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.init.Items -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable - -object HideHealerFairy { - fun handle(entity: Entity, cir: CallbackInfoReturnable) { - if (!config.hideHealerFairy) return - if (TabListUtils.area != "Dungeon") return - if (entity is EntityArmorStand) { - if (entity.heldItem != null && entity.heldItem.item === Items.skull) { - val stack = entity.heldItem - if (stack.hasTagCompound() && stack.tagCompound.hasKey("SkullOwner")) { - val skullOwner = stack.tagCompound.getCompoundTag("SkullOwner") - if (skullOwner.hasKey("Properties")) { - val properties = skullOwner.getCompoundTag("Properties") - if (properties.hasKey("textures")) { - val healerFairyTexture = - "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" - if (healerFairyTexture == properties.getTagList("textures", 10).getCompoundTagAt(0) - .getString("Value") - ) { - cir.cancel() - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/SecretSounds.kt b/src/main/kotlin/dulkirmod/features/SecretSounds.kt deleted file mode 100644 index 993c44f..0000000 --- a/src/main/kotlin/dulkirmod/features/SecretSounds.kt +++ /dev/null @@ -1,93 +0,0 @@ -package dulkirmod.features - -import dulkirmod.DulkirMod.Companion.mc -import dulkirmod.config.DulkirConfig -import dulkirmod.events.EntityRemovedEvent -import dulkirmod.utils.TabListUtils -import net.minecraft.block.Block -import net.minecraft.client.audio.SoundCategory -import net.minecraft.entity.item.EntityItem -import net.minecraft.init.Blocks -import net.minecraft.item.ItemStack -import net.minecraft.tileentity.TileEntitySkull -import net.minecraftforge.event.entity.player.PlayerInteractEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object SecretSounds { - private var lastSound: Long = 0L - - enum class Secrets(val value: String) { - SPIRIT_LEAP("Spirit Leap"), - DECOY("Decoy"), - INFLATABLE_JERRY("Inflatable Jerry"), - TREASURE_TALISMAN("Treasure Talisman") - } - @SubscribeEvent - fun onInteract(event: PlayerInteractEvent) { - if (!DulkirConfig.secretClickSounds) return - if (TabListUtils.area != "Dungeon") return - if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return - - - val blockType: Block = mc.theWorld.getBlockState(event.pos).block ?: return // get the type of block - - if (blockType != Blocks.chest && blockType != Blocks.trapped_chest && blockType != Blocks.skull && blockType != Blocks.lever) { // check if it's a secret - return - } - - if (blockType == Blocks.skull) { // it may be a wither essence skull - var skullId: String? = null - - try { - skullId = (mc.theWorld.getTileEntity(event.pos) as TileEntitySkull).playerProfile.id.toString() - } catch (ignored: NullPointerException) {} // it doesn't have a playerID - - if (skullId == null || skullId != "26bb1a8d-7c66-31c6-82d5-a9c04c94fb02") { // check if it is a wither essence player head - return - } - } - playSound() - } - - // Inspiration: AtonAddons - https://github.com/FloppaCoding/AtonAddons/blob/main/src/main/kotlin/atonaddons/module/impl/dungeon/SecretChime.kt - private var drops = listOf( - "Health Potion VIII Splash Potion", //"§5Health Potion VIII Splash Potion" - "Healing Potion 8 Splash Potion", - "Healing Potion VIII Splash Potion", - "Decoy", //"§aDecoy" - "Inflatable Jerry", // "§fInflatable Jerry" - "Spirit Leap", // "§9Spirit Leap" - "Trap", // "§aTrap" - "Training Weights", // "§aTraining Weights" - "Defuse Kit", // "§aDefuse Kit" - "Dungeon Chest Key", // "§9Dungeon Chest Key" - "Treasure Talisman", // Name: "§9Treasure Talisman" - "Revive Stone", - ) - @SubscribeEvent - fun onRemoveEntity(event: EntityRemovedEvent) { - if (!DulkirConfig.secretClickSounds) return - if (TabListUtils.area != "Dungeon") return - if (event.entity !is EntityItem) return - if (mc.thePlayer.getDistanceToEntity(event.entity) > 6) return - val item: ItemStack = event.entity.entityItem - - var secretFlag = false - for (d in drops) { - if (item.displayName.contains(d)) - secretFlag = true - } - if (secretFlag) - playSound() - } - - fun playSound() { - if (System.currentTimeMillis() - lastSound > 50) { // don't kill ears - val prevNote = mc.gameSettings.getSoundLevel(SoundCategory.MASTER) - mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, 1f) - mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.secretSoundVolume, 1f) - lastSound = System.currentTimeMillis() - mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, prevNote) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/Croesus.kt b/src/main/kotlin/dulkirmod/features/dungeons/Croesus.kt new file mode 100644 index 0000000..91d710e --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/dungeons/Croesus.kt @@ -0,0 +1,84 @@ +package dulkirmod.features.dungeons + +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.DulkirConfig +import dulkirmod.utils.ContainerNameUtil +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.Slot +import net.minecraft.nbt.NBTTagList +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +object Croesus { + + var lastGuiOpenEvent: Long = 0 + var lastPageNumber = 1 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val lastInCroesus = inCroesusBool + var pageNumber = 1 + + if (!DulkirConfig.hideOpenedChests) return + if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { + inCroesusBool = false + return + } + inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") + + if (inCroesusBool) { + pageNumber = findPageNumber() + } + + // weird way of detecting page turn + if (lastPageNumber != pageNumber) + lastGuiOpenEvent = System.currentTimeMillis() + + if (inCroesusBool && !lastInCroesus) { + lastGuiOpenEvent = System.currentTimeMillis() + } + + if (inCroesusBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { + for (i in 9..44) { + boolArray[i - 9] = false + val slotIn = mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + + val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue + for (j in 0 until tagList.tagCount()) { + if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true + } + } + } + } + + private fun findPageNumber(): Int { + val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber + + val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1 + + if (stackPrevLore.getStringTagAt(0).contains("1")) return 2 + + return 3 + } + + var inCroesusBool: Boolean = false + + var boolArray = BooleanArray(36) { false } + + @JvmStatic + fun inCroesus(): Boolean { + return inCroesusBool + } + + @JvmStatic + fun isChestOpened(slotIn: Slot): Boolean { + if (!inCroesusBool) return false + if (slotIn.inventory == mc.thePlayer.inventory) return false + val slotindex = slotIn.slotIndex + if (slotindex !in 9..44) return false + return boolArray[slotindex - 9] + } +} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt b/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt new file mode 100644 index 0000000..8709497 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt @@ -0,0 +1,217 @@ +package dulkirmod.features.dungeons + +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.DulkirConfig +import dulkirmod.utils.ScoreBoardUtils +import dulkirmod.utils.WorldRenderUtils +import net.minecraft.util.BlockPos +import net.minecraft.util.Vec3 +import net.minecraft.world.World +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.math.max + +object DragonFeatures { + data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) + data class Waypoint(val pos: Vec3, val color: String) + + private val dragons = arrayOf( + Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), + Dragon("red", Vec3(27.0, 18.0, 56.0), 0), + Dragon("green", Vec3(26.0, 18.0, 95.0), 0), + Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), + Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) + ) + + private val gyros = arrayOf( + Waypoint(Vec3(83.5,5.5,104.5), "blue"), // blue + Waypoint(Vec3(25.5, 5.5, 81.5), "green") // green + ) + private val decoys = arrayOf( + Waypoint(Vec3(37.5, 14.5, 44.5), "red"), // red + Waypoint(Vec3(56.5, 7.5, 124.5), "purple"), // purple + Waypoint(Vec3(90.5, 11.5, 100.5), "blue"), // blue + Waypoint(Vec3(21.5, 11.5, 88.5), "green") // green + ) + private val shoot = arrayOf( + Waypoint(Vec3(56.5, 20.5, 124.5), "purple"), // purple + Waypoint(Vec3(84.5, 20.5, 59.5), "orange"), // orange + Waypoint(Vec3(23.5,21.5, 54.5), "red"), // red + Waypoint(Vec3(27.5, 16.5, 94.5), "green"), // green + Waypoint(Vec3(85.5, 20.5, 98.5), "blue") // blue + ) + + private var greenAlive = true + private var blueAlive = true + private var redAlive = true + private var orangeAlive = true + private var purpleAlive = true + + /** + * Called from within the MixinWorld Class + */ + fun handleNewParticle(pID: Int, x: Double, y: Double, z: Double) { + if (!DulkirConfig.dragonTimer) return + if (!ScoreBoardUtils.isInM7) return + + if (pID != 26) return + + val particleVec = Vec3(x, y, z) + dragons.forEach { + if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach + it.spawnTime = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + renderDragonBoxes() + + if (!DulkirConfig.dragonTimer) return + if (!ScoreBoardUtils.isInM7) return + + val curTime = System.currentTimeMillis() + dragons.forEach { + if (it.spawnTime + 5000 < curTime || !isAlive(it.color)) return@forEach + val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f + val color = when { + timeUntilSpawn <= 1 -> "§c" + timeUntilSpawn <= 3 -> "§e" + else -> "§a" + } + + val scale = max(1.0, mc.thePlayer.positionVector.distanceTo(it.pos) / 5.0).toFloat() + + WorldRenderUtils.renderString( + it.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", false, scale, true + ) + } + } + + + fun updateDragonDead() { + if (!(DulkirConfig.dragonKillBox || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints || DulkirConfig.gyroWaypoints)) return + if (!ScoreBoardUtils.isInM7) return + if (mc.theWorld == null) return + if (mc.thePlayer.positionVector.yCoord > 45) return + + val world: World = mc.theWorld + + orangeAlive = !world.isAirBlock(BlockPos(90, 21, 56)) + redAlive = !world.isAirBlock(BlockPos(22, 20 , 59)) + greenAlive = !world.isAirBlock(BlockPos(22, 21, 94)) + purpleAlive = !world.isAirBlock(BlockPos(56, 20, 130)) + blueAlive = !world.isAirBlock(BlockPos(89, 21, 94)) + } + + /** + * true = dead + */ + private fun isAlive(color: String): Boolean { + return when (color) { + "orange" -> orangeAlive + "red" -> redAlive + "green" -> greenAlive + "purple" -> purpleAlive + "blue" -> blueAlive + else -> false + } + } + + private fun inRangeOf(color: String, pos: Vec3): Boolean { + val x = pos.xCoord.toInt() + val y = pos.yCoord.toInt() + val z = pos.zCoord.toInt() + + return when (color) { + "orange" -> { + x in 82..88 && y in 15..22 && z in 53..59 + } + + "red" -> { + x in 24..30 && y in 15..22 && z in 56..62 + } + + "green" -> { + x in 23..29 && y in 15..22 && z in 91..97 + } + + "purple" -> { + x in 53..59 && y in 15..22 && z in 122..128 + } + + "blue" -> { + x in 82..88 && y in 15..22 && z in 91..97 + } + + else -> { + false + } + } + } + + private fun renderDragonBoxes() { + if (!DulkirConfig.dragonKillBox) return + if (!ScoreBoardUtils.isInM7) return + if (mc.thePlayer.positionVector.yCoord > 45) return + // Blue + if (isAlive("blue")) + WorldRenderUtils.drawCustomBox(71.5, 25.0, 16.0, 10.0, 82.5, 25.0, Color(0, 170, 170, 255), 3f, phase = false) + // Purple + if (isAlive("purple")) + WorldRenderUtils.drawCustomBox(45.5, 23.0, 13.0, 10.0, 113.5, 23.0, Color(170, 0, 170, 255), 3f, phase = false) + // Green + if (isAlive("green")) + WorldRenderUtils.drawCustomBox(7.0, 30.0, 8.0, 20.0, 80.0, 30.0, Color(85, 255, 85, 255), 3f, phase = false) + // Red + if (isAlive("red")) + WorldRenderUtils.drawCustomBox(14.5, 25.0, 13.0, 15.0, 45.5, 25.0, Color(255, 85, 85, 255), 3f, phase = false) + // Orange + if (isAlive("orange")) + WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 29.0, Color(255, 170, 0, 255), 3f, phase = false) + } + + @SubscribeEvent + fun updateM7Check(event: WorldEvent.Load) { + val executor = Executors.newSingleThreadScheduledExecutor() + executor.schedule({ + ScoreBoardUtils.inM7() + }, 10, TimeUnit.SECONDS) + } + + @SubscribeEvent + fun renderP5Waypoints(event: RenderWorldLastEvent) { + if (!(DulkirConfig.gyroWaypoints || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints)) return + if (!ScoreBoardUtils.isInM7) return + val playerVec = mc.thePlayer.positionVector + if (playerVec.yCoord > 45) return + if (DulkirConfig.gyroWaypoints) { + val color = "§6" + for (g in gyros) { + if (!isAlive(g.color)) continue + WorldRenderUtils.drawCustomBox(g.pos.xCoord - .5, 1.0, g.pos.yCoord -.5, 1.0, g.pos.zCoord -.5, 1.0, Color(125, 87, 10, 255), 3f, phase = true) + WorldRenderUtils.renderString(g.pos.add(Vec3(0.0, 1.0,0.0)), "${color}Gyro", false, max(1f, playerVec.distanceTo(g.pos).toFloat()/10f), false) + } + } + if (DulkirConfig.lbWaypoints) { + val color = "§a" + for (s in shoot) { + if (!isAlive(s.color)) continue + WorldRenderUtils.drawCustomBox(s.pos.xCoord - .5, 1.0, s.pos.yCoord -.5, 1.0, s.pos.zCoord -.5, 1.0, Color(27, 99, 18, 255), 3f, phase = true) + WorldRenderUtils.renderString(s.pos, "${color}Target", false, max(1f, playerVec.distanceTo(s.pos).toFloat()/10f), false) + } + } + if (DulkirConfig.decoyWaypoints) { + val color = "§3" + for (d in decoys) { + if (!isAlive(d.color)) continue + WorldRenderUtils.drawCustomBox(d.pos.xCoord - .5, 1.0, d.pos.yCoord -.5, 1.0, d.pos.zCoord -.5, 1.0, Color(33, 62, 209), 3f, phase = true) + WorldRenderUtils.renderString(d.pos, "${color}Decoy", false, max(1f, playerVec.distanceTo(d.pos).toFloat()/10f), false) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt new file mode 100644 index 0000000..e7fdc29 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/dungeons/DungeonLeap.kt @@ -0,0 +1,54 @@ +package dulkirmod.features.dungeons + +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.DulkirConfig +import dulkirmod.utils.ContainerNameUtil +import dulkirmod.utils.Utils +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.Slot +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +object DungeonLeap { + var inLeapMenu = false + var leapPlayers = BooleanArray(5) { false } + + private var lastGuiOpenEvent = 0L + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val lastInLeap = inLeapMenu + + if (!DulkirConfig.highlightLeap) return + if (mc.currentScreen == null || mc.currentScreen !is GuiChest) { + inLeapMenu = false + return + } + inLeapMenu = (ContainerNameUtil.currentGuiChestName == "Spirit Leap") + + if (inLeapMenu && !lastInLeap) { + lastGuiOpenEvent = System.currentTimeMillis() + } + + if (inLeapMenu && System.currentTimeMillis() - lastGuiOpenEvent < 300) { + for (i in 11..15) { + leapPlayers[i - 11] = false + val slotIn = mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + if (Utils.stripColorCodes(stack.displayName).equals(DulkirConfig.highlightLeapName, true)) { + leapPlayers[i - 11] = true + } + } + } + } + + fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { + if (!inLeapMenu) return false + if (slotIn.inventory == mc.thePlayer.inventory) return false + val slotIndex = slotIn.slotIndex + if (slotIndex !in 11..15) return false + return leapPlayers[slotIndex - 11] + } +} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/HideHealerFairy.kt b/src/main/kotlin/dulkirmod/features/dungeons/HideHealerFairy.kt new file mode 100644 index 0000000..ecfe27e --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/dungeons/HideHealerFairy.kt @@ -0,0 +1,36 @@ +package dulkirmod.features.dungeons + + +import dulkirmod.DulkirMod.Companion.config +import dulkirmod.utils.TabListUtils +import net.minecraft.entity.Entity +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.init.Items +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable + +object HideHealerFairy { + fun handle(entity: Entity, cir: CallbackInfoReturnable) { + if (!config.hideHealerFairy) return + if (TabListUtils.area != "Dungeon") return + if (entity is EntityArmorStand) { + if (entity.heldItem != null && entity.heldItem.item === Items.skull) { + val stack = entity.heldItem + if (stack.hasTagCompound() && stack.tagCompound.hasKey("SkullOwner")) { + val skullOwner = stack.tagCompound.getCompoundTag("SkullOwner") + if (skullOwner.hasKey("Properties")) { + val properties = skullOwner.getCompoundTag("Properties") + if (properties.hasKey("textures")) { + val healerFairyTexture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" + if (healerFairyTexture == properties.getTagList("textures", 10).getCompoundTagAt(0) + .getString("Value") + ) { + cir.cancel() + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/SecretSounds.kt b/src/main/kotlin/dulkirmod/features/dungeons/SecretSounds.kt new file mode 100644 index 0000000..f384658 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/dungeons/SecretSounds.kt @@ -0,0 +1,93 @@ +package dulkirmod.features.dungeons + +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.DulkirConfig +import dulkirmod.events.EntityRemovedEvent +import dulkirmod.utils.TabListUtils +import net.minecraft.block.Block +import net.minecraft.client.audio.SoundCategory +import net.minecraft.entity.item.EntityItem +import net.minecraft.init.Blocks +import net.minecraft.item.ItemStack +import net.minecraft.tileentity.TileEntitySkull +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object SecretSounds { + private var lastSound: Long = 0L + + enum class Secrets(val value: String) { + SPIRIT_LEAP("Spirit Leap"), + DECOY("Decoy"), + INFLATABLE_JERRY("Inflatable Jerry"), + TREASURE_TALISMAN("Treasure Talisman") + } + @SubscribeEvent + fun onInteract(event: PlayerInteractEvent) { + if (!DulkirConfig.secretClickSounds) return + if (TabListUtils.area != "Dungeon") return + if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return + + + val blockType: Block = mc.theWorld.getBlockState(event.pos).block ?: return // get the type of block + + if (blockType != Blocks.chest && blockType != Blocks.trapped_chest && blockType != Blocks.skull && blockType != Blocks.lever) { // check if it's a secret + return + } + + if (blockType == Blocks.skull) { // it may be a wither essence skull + var skullId: String? = null + + try { + skullId = (mc.theWorld.getTileEntity(event.pos) as TileEntitySkull).playerProfile.id.toString() + } catch (ignored: NullPointerException) {} // it doesn't have a playerID + + if (skullId == null || skullId != "26bb1a8d-7c66-31c6-82d5-a9c04c94fb02") { // check if it is a wither essence player head + return + } + } + playSound() + } + + // Inspiration: AtonAddons - https://github.com/FloppaCoding/AtonAddons/blob/main/src/main/kotlin/atonaddons/module/impl/dungeon/SecretChime.kt + private var drops = listOf( + "Health Potion VIII Splash Potion", //"§5Health Potion VIII Splash Potion" + "Healing Potion 8 Splash Potion", + "Healing Potion VIII Splash Potion", + "Decoy", //"§aDecoy" + "Inflatable Jerry", // "§fInflatable Jerry" + "Spirit Leap", // "§9Spirit Leap" + "Trap", // "§aTrap" + "Training Weights", // "§aTraining Weights" + "Defuse Kit", // "§aDefuse Kit" + "Dungeon Chest Key", // "§9Dungeon Chest Key" + "Treasure Talisman", // Name: "§9Treasure Talisman" + "Revive Stone", + ) + @SubscribeEvent + fun onRemoveEntity(event: EntityRemovedEvent) { + if (!DulkirConfig.secretClickSounds) return + if (TabListUtils.area != "Dungeon") return + if (event.entity !is EntityItem) return + if (mc.thePlayer.getDistanceToEntity(event.entity) > 6) return + val item: ItemStack = event.entity.entityItem + + var secretFlag = false + for (d in drops) { + if (item.displayName.contains(d)) + secretFlag = true + } + if (secretFlag) + playSound() + } + + fun playSound() { + if (System.currentTimeMillis() - lastSound > 50) { // don't kill ears + val prevNote = mc.gameSettings.getSoundLevel(SoundCategory.MASTER) + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, 1f) + mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.secretSoundVolume, 1f) + lastSound = System.currentTimeMillis() + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, prevNote) + } + } +} \ No newline at end of file -- cgit