diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-06-05 21:08:22 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-06-05 21:08:22 -0400 |
commit | a20fcff3a1e051add420db677071eec2452e4bef (patch) | |
tree | dd91974cceed4ce65dfd3ab21731e8fb751dae4d /src/main | |
parent | 1af14234ffdea3af32b71401e13aee685d8768c8 (diff) | |
download | SkytilsMod-a20fcff3a1e051add420db677071eec2452e4bef.tar.gz SkytilsMod-a20fcff3a1e051add420db677071eec2452e4bef.tar.bz2 SkytilsMod-a20fcff3a1e051add420db677071eec2452e4bef.zip |
Debug stuff for slayer + Dungeon Rooms "scan" function
Diffstat (limited to 'src/main')
8 files changed, 149 insertions, 26 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java b/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java new file mode 100644 index 00000000..6b3d89c0 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java @@ -0,0 +1,37 @@ +/* + * 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.drm; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import skytils.skytilsmod.features.impl.dungeons.ScoreCalculation; + +import java.util.List; + +@Pseudo +@Mixin(targets = "io.github.quantizr.utils.Utils", remap = false) +public class MixinUtils { + @Inject(method = "roomList", at = @At("RETURN")) + private static void onRoomList(CallbackInfoReturnable<List<String>> cir) { + ScoreCalculation.INSTANCE.roomScanCallback(cir.getReturnValue()); + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/Skytils.kt b/src/main/kotlin/skytils/skytilsmod/Skytils.kt index b0d50dda..afdcfae4 100644 --- a/src/main/kotlin/skytils/skytilsmod/Skytils.kt +++ b/src/main/kotlin/skytils/skytilsmod/Skytils.kt @@ -211,7 +211,7 @@ class Skytils { MinecraftForge.EVENT_BUS.register(ProtectItems()) MinecraftForge.EVENT_BUS.register(RainTimer()) MinecraftForge.EVENT_BUS.register(RelicWaypoints()) - MinecraftForge.EVENT_BUS.register(ScoreCalculation()) + MinecraftForge.EVENT_BUS.register(ScoreCalculation) MinecraftForge.EVENT_BUS.register(SelectAllColorSolver()) MinecraftForge.EVENT_BUS.register(ShootTheTargetSolver()) MinecraftForge.EVENT_BUS.register(SimonSaysSolver()) diff --git a/src/main/kotlin/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/skytils/skytilsmod/core/Config.kt index 0785c5ba..5e968210 100644 --- a/src/main/kotlin/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/skytils/skytilsmod/core/Config.kt @@ -88,6 +88,15 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting @Property( type = PropertyType.SWITCH, + name = "Debug Mode", + description = "Will do weird things to your game. You probably don't want this on.", + category = "General", + subcategory = "Other" + ) + var debugMode = false + + @Property( + type = PropertyType.SWITCH, name = "Reopen Options Menu", description = "Sets the menu to the Skytils options menu instead of exiting when on a Skytils config menu.", category = "General", @@ -206,6 +215,16 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting var showScoreCalculation = false @Property( + type = PropertyType.SELECTOR, + name = "Score Calculation Method", + description = "New method requires Dungeon Rooms Mod version 2.", + category = "Dungeons", + subcategory = "Score Calculation", + options = arrayOf("Old", "New") + ) + var scoreCalculationMethod = 0 + + @Property( type = PropertyType.SWITCH, name = "Score Calculation Party Assist", description = "Helps your party determine the amount of secrets in the dungeon by sending room info in party chat.\n§cThis feature is use at your own risk.", diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt index c3c56ca3..6327dad7 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt @@ -23,6 +23,7 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.ScaledResolution import net.minecraft.entity.monster.EntityZombie import net.minecraft.network.play.server.S29PacketSoundEffect +import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText import net.minecraft.world.World import net.minecraftforge.client.ClientCommandHandler @@ -47,11 +48,37 @@ import skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment import skytils.skytilsmod.utils.graphics.colors.CommonColors import java.util.regex.Pattern import kotlin.math.floor +import kotlin.math.pow + +object ScoreCalculation { + + val partyAssistSecretsPattern: Pattern = + Pattern.compile("^Party > .+: \\\$SKYTILS-DUNGEON-SCORE-ROOM\\$: \\[(?<name>.+)] \\((?<secrets>\\d+)\\)$")!! + var rooms = HashMap<String, Int>() + var mimicKilled = false + private val mc = Minecraft.getMinecraft() + private var ticks = 0 + private val JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}") + private var lastRoomScanPos: BlockPos? = null + + fun roomScanCallback(list: List<String>) { + if (Skytils.config.scoreCalculationMethod != 1) return + Utils.checkThreadAndQueue { + for (room in list) { + if (!rooms.containsKey(room)) { + val secrets = room.substringAfterLast("-").toIntOrNull() ?: 0 + rooms[room] = secrets + if (Skytils.config.scoreCalculationAssist) { + Skytils.sendMessageQueue.add("/pc \$SKYTILS-DUNGEON-SCORE-ROOM$: [$room] ($secrets)") + } + } + } + } + } -class ScoreCalculation { @SubscribeEvent fun onAddChatMessage(event: AddChatMessageEvent) { - if (!Utils.inDungeons) return + if (!Utils.inDungeons || Skytils.config.scoreCalculationMethod != 0) return try { val unformatted = event.message.unformattedText.stripControlCodes() if (unformatted == "null" || unformatted.startsWith("Dungeon Rooms: Use this command in dungeons")) { @@ -82,13 +109,27 @@ class ScoreCalculation { @SubscribeEvent fun onTick(event: ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return - if (ticks % 30 == 0) { - if (Utils.inDungeons && mc.thePlayer != null && mc.theWorld != null) { - if (!DungeonFeatures.hasBossSpawned && Skytils.usingDungeonRooms && (Skytils.config.showScoreCalculation || Skytils.config.scoreCalculationAssist)) { - ClientCommandHandler.instance.executeCommand(mc.thePlayer, "/room json") + if (Utils.inDungeons && Skytils.usingDungeonRooms && mc.thePlayer != null && mc.theWorld != null && (Skytils.config.showScoreCalculation || Skytils.config.scoreCalculationAssist)) { + when (Skytils.config.scoreCalculationMethod) { + 0 -> { + if (ticks % 30 == 0) { + ClientCommandHandler.instance.executeCommand(mc.thePlayer, "/room json") + ticks = 0 + } + } + 1 -> { + if (lastRoomScanPos == null || ticks % 600 == 0 || mc.thePlayer.getDistanceSqToCenter( + lastRoomScanPos + ) >= (mc.gameSettings.renderDistanceChunks.coerceAtMost( + 8 + ) * 16.0).pow(2) + ) { + lastRoomScanPos = mc.thePlayer.position + ClientCommandHandler.instance.executeCommand(mc.thePlayer, "/room scan") + ticks = 0 + } } } - ticks = 0 } ticks++ } @@ -165,7 +206,7 @@ class ScoreCalculation { @SubscribeEvent fun onSendChat(event: SendChatMessageEvent) { - if (event.message == "/debugscorecalcrooms") { + if (Skytils.config.debugMode && event.message == "/debugscorecalcrooms") { mc.thePlayer.addChatMessage(ChatComponentText(rooms.toString())) event.isCanceled = true } @@ -174,21 +215,12 @@ class ScoreCalculation { @SubscribeEvent fun onWorldChange(event: WorldEvent.Load?) { mimicKilled = false + lastRoomScanPos = null rooms.clear() } - companion object { - val partyAssistSecretsPattern: Pattern = - Pattern.compile("^Party > .+: \\\$SKYTILS-DUNGEON-SCORE-ROOM\\$: \\[(?<name>.+)] \\((?<secrets>\\d+)\\)$")!! - var rooms = HashMap<String, Int>() - var mimicKilled = false - private val mc = Minecraft.getMinecraft() - private var ticks = 0 - private val JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}") - - init { - ScoreCalculationElement() - } + init { + ScoreCalculationElement() } class ScoreCalculationElement : GuiElement("Dungeon Score Estimate", FloatPair(200, 100)) { diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/ShootTheTargetSolver.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/ShootTheTargetSolver.kt index 5ba378b8..6493b8c5 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/ShootTheTargetSolver.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/ShootTheTargetSolver.kt @@ -53,7 +53,7 @@ class ShootTheTargetSolver { if (old.block == Blocks.emerald_block && state.block == Blocks.stained_hardened_clay) { shot.add(pos) } - } else if (pos == plate && state.block == Blocks.light_weighted_pressure_plate) { + } else if (pos == plate && state.block is BlockPressurePlateWeighted) { if (state.getValue(BlockPressurePlateWeighted.POWER) == 0 || old.getValue(BlockPressurePlateWeighted.POWER) == 0) { shot.clear() } diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt index c2a46096..48d9b4be 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt @@ -58,6 +58,7 @@ import skytils.skytilsmod.utils.RenderUtil.drawOutlinedBoundingBox import skytils.skytilsmod.utils.ScoreboardUtil.cleanSB import skytils.skytilsmod.utils.ScoreboardUtil.sidebarLines import skytils.skytilsmod.utils.Utils +import skytils.skytilsmod.utils.Utils.printDebugMessage import skytils.skytilsmod.utils.baseMaxHealth import skytils.skytilsmod.utils.graphics.ScreenRenderer import skytils.skytilsmod.utils.graphics.SmartFontRenderer @@ -288,7 +289,12 @@ class SlayerFeatures { @SubscribeEvent fun onEntityJoinWorld(event: EntityJoinWorldEvent) { if (!sidebarLines.any { cleanSB(it) == "Slay the boss!" }) return - if (slayerEntity != null) return + if (slayerEntity != null) { + printDebugMessage( + "boss not null" + ) + return + } val entity = event.entity if (entity is EntityZombie) { TickTask(5) { @@ -370,15 +376,24 @@ class SlayerFeatures { val currentTier = sidebarLines.map { cleanSB(it) }.find { it.startsWith(name) }?.substringAfter(name)?.drop(1) ?: "" + printDebugMessage( + "expected tier $currentTier - spawned hp ${floor(entity.baseMaxHealth).toInt()}" + ) if (BossHealths[name.substringBefore(" ")]?.get(currentTier)?.asInt == floor(entity.baseMaxHealth).toInt() ) { + printDebugMessage( + "hp matched" + ) slayerNameEntity = nearby as EntityArmorStand isSlayer++ } continue } if (nearby.displayName.formattedText == timer) { + printDebugMessage( + "timer matched" + ) slayerTimerEntity = nearby as EntityArmorStand isSlayer++ continue @@ -414,6 +429,10 @@ class SlayerFeatures { if (Utils.inSkyblock) { if (slayerTimerEntity != null) { if (slayerTimerEntity!!.isDead) { + printDebugMessage( + "timer died" + + ) slayerTimerEntity = null } else if (toggled) { ScreenRenderer.fontRenderer.drawString( @@ -428,6 +447,10 @@ class SlayerFeatures { } if (slayerNameEntity != null) { if (slayerNameEntity!!.isDead) { + printDebugMessage( + "name died" + + ) slayerNameEntity = null } else if (toggled) { ScreenRenderer.fontRenderer.drawString( @@ -442,6 +465,10 @@ class SlayerFeatures { } if (slayerEntity != null) { if (slayerEntity!!.isDead) { + printDebugMessage( + "slayer died" + + ) slayerEntity = null } } diff --git a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt index 35541900..51595e66 100644 --- a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt +++ b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt @@ -27,9 +27,7 @@ import net.minecraft.entity.player.EntityPlayer import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraft.network.play.server.S02PacketChat -import net.minecraft.util.AxisAlignedBB -import net.minecraft.util.BlockPos -import net.minecraft.util.Vec3 +import net.minecraft.util.* import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.ObfuscationReflectionHelper @@ -255,6 +253,15 @@ object Utils { return bossName.endsWith(correctBoss) } + fun printDebugMessage(component: IChatComponent) { + if (Skytils.config.debugMode) mc.ingameGUI.chatGUI.printChatMessage(component) + } + + fun printDebugMessage(string: String) { + if (Skytils.config.debugMode) mc.ingameGUI.chatGUI.printChatMessage(ChatComponentText(string)) + } + + } typealias ConcurrentHashSet<T> = ConcurrentSet<T> diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json index 161d0d60..5bfba6ab 100644 --- a/src/main/resources/mixins.skytils.json +++ b/src/main/resources/mixins.skytils.json @@ -15,6 +15,7 @@ "accessors.AccessorSettingsGui", "audio.MixinSoundManager", "crash.MixinCrashReport", + "drm.MixinUtils", "entity.MixinBossStatus", "entity.MixinEntityBlaze", "entity.MixinEntityLivingBase", |