diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-10-08 00:24:45 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-10-08 00:26:28 -0400 |
commit | 15c595a7bd257cfb7fd125cd8bb49bc772714479 (patch) | |
tree | 67b71b877e142feb240d8283d2aeb0a9ac0b95fa /src | |
parent | 33060f3867ce1cfc79b4969061a3fa8038a760c3 (diff) | |
download | SkytilsMod-15c595a7bd257cfb7fd125cd8bb49bc772714479.tar.gz SkytilsMod-15c595a7bd257cfb7fd125cd8bb49bc772714479.tar.bz2 SkytilsMod-15c595a7bd257cfb7fd125cd8bb49bc772714479.zip |
should be a set and should be lazy
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt | 41 | ||||
-rw-r--r-- | src/main/kotlin/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt | 8 |
2 files changed, 28 insertions, 21 deletions
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt index 9a561f83..f5704d7e 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt @@ -52,10 +52,10 @@ class GriffinBurrows { companion object { var lastManualRefresh = 0L - var burrows = arrayListOf<Burrow>() - var dugBurrows = arrayListOf<BlockPos>() + var burrows = HashSet<Burrow>() + var dugBurrows = HashSet<BlockPos>() var lastDugBurrow: BlockPos? = null - var particleBurrows = arrayListOf<ParticleBurrow>() + var particleBurrows = HashSet<ParticleBurrow>() var lastDugParticleBurrow: BlockPos? = null var burrowRefreshTimer = StopWatch() var shouldRefreshBurrows = false @@ -84,13 +84,13 @@ class GriffinBurrows { Burrow(it.x, it.y, it.z, it.type, it.tier, it.chain) } - dugBurrows.removeIf { dug: BlockPos -> + dugBurrows.removeAll { dug: BlockPos -> receivedBurrows.none { burrow: Burrow -> burrow.blockPos == dug } } - particleBurrows.removeIf { pb: ParticleBurrow? -> + particleBurrows.removeAll { pb: ParticleBurrow? -> receivedBurrows.any { rb: Burrow -> rb.blockPos == pb!!.blockPos } } - val removedDupes = receivedBurrows.removeIf { burrow: Burrow -> + val removedDupes = receivedBurrows.removeAll { burrow: Burrow -> dugBurrows.contains(burrow.blockPos) || particleBurrows.any { pb: ParticleBurrow -> pb.dug && pb.blockPos == burrow.blockPos } } burrows.clear() @@ -325,10 +325,10 @@ class GriffinBurrows { } } - class ParticleBurrow( - var x: Int, - var y: Int, - var z: Int, + data class ParticleBurrow( + val x: Int, + val y: Int, + val z: Int, var hasFootstep: Boolean, var hasEnchant: Boolean, var type: Int @@ -345,8 +345,10 @@ class GriffinBurrows { type ) - val blockPos: BlockPos - get() = BlockPos(x, y, z) + val blockPos by lazy { + BlockPos(x, y, z) + } + private val waypointText: String get() { var type = "Burrow" @@ -398,23 +400,24 @@ class GriffinBurrows { } - class Burrow( - var x: Int, var y: Int, var z: Int, + data class Burrow( + val x: Int, val y: Int, val z: Int, /** * This variable seems to hold whether or not the burrow is the start/empty, a mob, or treasure */ - var type: Int, + val type: Int, /** * This variable holds the Griffin used, -1 means no Griffin, 0 means Common, etc. */ - var tier: Int, + val tier: Int, /** * This variable appears to hold what order the burrow is in the chain */ - private var chain: Int + private val chain: Int ) { - val blockPos: BlockPos - get() = BlockPos(x, y, z) + val blockPos by lazy { + BlockPos(x, y, z) + } private val waypointText: String get() { var type = "Burrow" diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt index 8dfcfe66..41b5c083 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt @@ -560,9 +560,12 @@ class MiscFeatures { } class WorldAgeDisplay : GuiElement("World Age Display", FloatPair(50, 60)) { + + var usesBaldTimeChanger = false + override fun render() { if (toggled && Utils.inSkyblock && mc.theWorld != null) { - if (Loader.instance().activeModList.any { it.modId == "timechanger" && it.version == "1.0" }) { + if (usesBaldTimeChanger) { ScreenRenderer.fontRenderer.drawString( "Incompatible Time Changer detected.", 0f, @@ -586,7 +589,8 @@ class MiscFeatures { } override fun demoRender() { - if (Loader.instance().activeModList.any { it.modId == "timechanger" && it.version == "1.0" }) { + usesBaldTimeChanger = Loader.instance().activeModList.any { it.modId == "timechanger" && it.version == "1.0" } + if (usesBaldTimeChanger) { ScreenRenderer.fontRenderer.drawString( "Incompatible Time Changer detected.", 0f, |