aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle3
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java37
-rw-r--r--src/main/kotlin/skytils/skytilsmod/Skytils.kt5
-rw-r--r--src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt19
-rw-r--r--src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt14
-rw-r--r--src/main/kotlin/skytils/skytilsmod/utils/Utils.kt4
-rw-r--r--src/main/resources/mixins.skytils.json1
7 files changed, 24 insertions, 59 deletions
diff --git a/build.gradle b/build.gradle
index 5e9aa9f0..6ff389ee 100644
--- a/build.gradle
+++ b/build.gradle
@@ -117,7 +117,10 @@ shadowJar {
exclude "org/lwjgl/**"
exclude "net/java/**"
+ exclude "META-INF/proguard/**"
+ exclude "META-INF/maven/**"
exclude "META-INF/versions/**"
+ exclude "META-INF/com.android.tools/**"
exclude "fabric.mod.json"
}
diff --git a/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java b/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java
deleted file mode 100644
index 6b3d89c0..00000000
--- a/src/main/java/skytils/skytilsmod/mixins/drm/MixinUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 afdcfae4..ddc3e909 100644
--- a/src/main/kotlin/skytils/skytilsmod/Skytils.kt
+++ b/src/main/kotlin/skytils/skytilsmod/Skytils.kt
@@ -235,6 +235,11 @@ class Skytils {
usingLabymod = Loader.isModLoaded("labymod")
usingNEU = Loader.isModLoaded("notenoughupdates")
+ if (usingDungeonRooms && Loader.instance().indexedModList["dungeonrooms"]!!.version.startsWith("2")) {
+ ScoreCalculation.drmRoomScanMethod =
+ Class.forName("io.github.quantizr.utils.Utils").getDeclaredMethod("roomList")
+ }
+
val cch = ClientCommandHandler.instance
if (cch is AccessorCommandHandler) {
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 6327dad7..54d49415 100644
--- a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt
+++ b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt
@@ -46,7 +46,10 @@ import skytils.skytilsmod.utils.graphics.ScreenRenderer
import skytils.skytilsmod.utils.graphics.SmartFontRenderer
import skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import skytils.skytilsmod.utils.graphics.colors.CommonColors
+import java.lang.reflect.Method
+import java.util.concurrent.ConcurrentHashMap
import java.util.regex.Pattern
+import kotlin.jvm.internal.Reflection
import kotlin.math.floor
import kotlin.math.pow
@@ -54,13 +57,15 @@ object ScoreCalculation {
val partyAssistSecretsPattern: Pattern =
Pattern.compile("^Party > .+: \\\$SKYTILS-DUNGEON-SCORE-ROOM\\$: \\[(?<name>.+)] \\((?<secrets>\\d+)\\)$")!!
- var rooms = HashMap<String, Int>()
+ var rooms = ConcurrentHashMap<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
+ var drmRoomScanMethod: Method? = null
+
fun roomScanCallback(list: List<String>) {
if (Skytils.config.scoreCalculationMethod != 1) return
Utils.checkThreadAndQueue {
@@ -118,14 +123,20 @@ object ScoreCalculation {
}
}
1 -> {
- if (lastRoomScanPos == null || ticks % 600 == 0 || mc.thePlayer.getDistanceSqToCenter(
+ if (drmRoomScanMethod != null && (lastRoomScanPos == null || ticks % 900 == 0 || mc.thePlayer.getDistanceSqToCenter(
lastRoomScanPos
) >= (mc.gameSettings.renderDistanceChunks.coerceAtMost(
- 8
+ 10
) * 16.0).pow(2)
+ )
) {
lastRoomScanPos = mc.thePlayer.position
- ClientCommandHandler.instance.executeCommand(mc.thePlayer, "/room scan")
+ Skytils.threadPool.submit {
+ @Suppress("UNCHECKED_CAST")
+ roomScanCallback(
+ drmRoomScanMethod!!.invoke(null) as List<String>
+ )
+ }
ticks = 0
}
}
diff --git a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt
index 3fee1771..b3ec43fc 100644
--- a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt
+++ b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt
@@ -18,9 +18,7 @@
package skytils.skytilsmod.tweaker
-import net.minecraftforge.common.ForgeVersion
import org.spongepowered.asm.lib.tree.ClassNode
-import org.spongepowered.asm.mixin.Mixins
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin
import org.spongepowered.asm.mixin.extensibility.IMixinInfo
@@ -38,18 +36,6 @@ class SkytilsMixinPlugin : IMixinConfigPlugin {
println("Mixin $mixinClassName for $targetClassName is foreign, disabling.")
return false
}
- if (targetClassName == "io.github.quantizr.utils.Utils") {
- val drmVersion = try {
- Class.forName("io.github.quantizr.DungeonRooms").getDeclaredField("VERSION").get(null) as String
- } catch (e: Exception) {
- e.printStackTrace()
- "1.0.0"
- }
- if (drmVersion.startsWith("1")) {
- println("Disabling DRM mixin due to old version.")
- return false
- }
- }
return true
}
diff --git a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
index 51595e66..697ed0d2 100644
--- a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
+++ b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
@@ -191,9 +191,7 @@ object Utils {
fun checkThreadAndQueue(run: () -> Unit) {
if (!mc.isCallingFromMinecraftThread) {
- mc.addScheduledTask {
- run()
- }
+ mc.addScheduledTask(run)
} else run()
}
diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json
index 5bfba6ab..161d0d60 100644
--- a/src/main/resources/mixins.skytils.json
+++ b/src/main/resources/mixins.skytils.json
@@ -15,7 +15,6 @@
"accessors.AccessorSettingsGui",
"audio.MixinSoundManager",
"crash.MixinCrashReport",
- "drm.MixinUtils",
"entity.MixinBossStatus",
"entity.MixinEntityBlaze",
"entity.MixinEntityLivingBase",