blob: c4d5d311e3c1b2e11ec237535a8c6928cb9ef588 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
package at.hannibal2.skyhanni.features.nether.reputationhelper
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.HyPixelData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.DailyKuudraBossHelper
import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper
import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.TabListUtils
import com.google.gson.JsonObject
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.util.*
class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
val questHelper = DailyQuestHelper(this)
val miniBossHelper = DailyMiniBossHelper(this)
val kuudraBossHelper = DailyKuudraBossHelper(this)
var repoData: JsonObject = JsonObject()
var factionType = FactionType.NONE
private val display = mutableListOf<List<Any>>()
private var dirty = true
private var tick = 0
init {
skyHanniMod.loadModule(questHelper)
skyHanniMod.loadModule(miniBossHelper)
skyHanniMod.loadModule(kuudraBossHelper)
}
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
repoData = event.getConstant("CrimsonIsleReputation")!!
miniBossHelper.load()
kuudraBossHelper.load()
questHelper.load()
}
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return
if (dirty) {
dirty = false
updateRender()
}
tick++
if (tick % 60 == 0) {
TabListUtils.getTabList()
.filter { it.contains("Reputation:") }
.forEach {
factionType = if (it.contains("Mage")) {
FactionType.MAGE
} else if (it.contains("Barbarian")) {
FactionType.BARBARIAN
} else {
FactionType.NONE
}
}
}
}
private fun updateRender() {
display.clear()
//TODO test
if (factionType == FactionType.NONE) return
display.add(Collections.singletonList("Reputation Helper:"))
questHelper.render(display)
miniBossHelper.render(display)
if (factionType == FactionType.MAGE) {
kuudraBossHelper.render(display)
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
fun renderOverlay(event: RenderGameOverlayEvent.Post) {
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return
if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
SkyHanniMod.feature.misc.crimsonIsleReputationHelperPos.renderStringsAndItems(display)
}
fun update() {
dirty = true
questHelper.saveConfig()
miniBossHelper.saveConfig()
kuudraBossHelper.saveConfig()
}
fun reset() {
LorenzUtils.chat("§e[SkyHanni] Reset Reputation Helper.")
questHelper.reset()
miniBossHelper.reset()
kuudraBossHelper.reset()
update()
}
fun readLocationData(data: JsonObject): LorenzVec? {
val locationData = data["location"]?.asJsonArray ?: return null
if (locationData.size() == 0) return null
val x = locationData[0].asDouble - 1
val y = locationData[1].asDouble
val z = locationData[2].asDouble - 1
return LorenzVec(x, y, z)
}
}
|