blob: e8e2acce7811a5b75a35fbfff0a2373c472a9e6f (
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.HyPixelData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper
import at.hannibal2.skyhanni.features.nether.reputationhelper.FactionType
import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.KuudraTier
import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.*
import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.util.*
class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) {
private val townBoardMage = LorenzVec(-138, 92, -754)
private val townBoardBarbarian = LorenzVec(-572, 100, -687)
private var tick = 0
private val loader = QuestLoader(this)
val quests = mutableListOf<Quest>()
private val sacksCache = mutableMapOf<String, Long>()
private var latestTrophyFishInInventory = 0
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return
tick++
if (tick % 20 == 0) {
loader.checkInventory()
checkInventoryForTrophyFish()
}
if (tick % 60 == 0) {
checkInventoryForFetchItem()
loader.loadFromTabList()
if (quests.size > 5) {
reputationHelper.reset()
}
}
}
private fun checkInventoryForTrophyFish() {
val fishQuest = getQuest<TrophyFishQuest>() ?: return
if (fishQuest.state != QuestState.ACCEPTED && fishQuest.state != QuestState.READY_TO_COLLECT) return
val fishName = fishQuest.fishName
val currentlyInInventory = InventoryUtils.countItemsInLowerInventory { it.name?.contains(fishName) ?: false }
val diff = currentlyInInventory - latestTrophyFishInInventory
if (diff < 1) return
latestTrophyFishInInventory = currentlyInInventory
updateProcessQuest(fishQuest, fishQuest.haveAmount + diff)
}
fun update() {
reputationHelper.update()
}
@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return
if (event.gui !is GuiChest) return
val chest = event.gui.inventorySlots as ContainerChest
val chestName = chest.getInventoryName()
if (chestName == "Challenges") {
if (LorenzUtils.skyBlockArea != "Dojo") return
val dojoQuest = getQuest<DojoQuest>() ?: return
if (dojoQuest.state != QuestState.ACCEPTED) return
for (slot in chest.inventorySlots) {
if (slot == null) continue
if (slot.slotNumber != slot.slotIndex) continue
val stack = slot.stack ?: continue
val itemName = stack.name ?: continue
if (itemName.contains(dojoQuest.dojoName)) {
slot highlight LorenzColor.AQUA
}
}
}
if (chestName == "Sack of Sacks") {
val fetchQuest = getQuest<FetchQuest>() ?: return
if (fetchQuest.state != QuestState.ACCEPTED) return
val fetchItem = fetchQuest.itemName
for (slot in chest.inventorySlots) {
if (slot == null) continue
if (slot.slotNumber != slot.slotIndex) continue
val stack = slot.stack ?: continue
if (stack.getLore().any { it.contains(fetchItem) }) {
slot highlight LorenzColor.AQUA
}
}
}
if (chestName.contains("Nether Sack")) {
val fetchQuest = getQuest<FetchQuest>() ?: return
if (fetchQuest.state != QuestState.ACCEPTED) return
val fetchItem = fetchQuest.itemName
for (slot in chest.inventorySlots) {
if (slot == null) continue
if (slot.slotNumber != slot.slotIndex) continue
val stack = slot.stack ?: continue
val itemName = stack.name ?: continue
if (itemName.contains(fetchItem)) {
slot highlight LorenzColor.AQUA
}
}
}
}
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return
val message = event.message
if (message == "§aYou completed your Dojo quest! Visit the Town Board to claim the rewards.") {
val dojoQuest = getQuest<DojoQuest>() ?: return
dojoQuest.state = QuestState.READY_TO_COLLECT
update()
}
if (message == "§aYou completed your rescue quest! Visit the Town Board to claim the rewards,") {
val rescueMissionQuest = getQuest<RescueMissionQuest>() ?: return
rescueMissionQuest.state = QuestState.READY_TO_COLLECT
update()
}
}
inline fun <reified T : Quest> getQuest() = quests.filterIsInstance<T>().firstOrNull()
private fun checkInventoryForFetchItem() {
val fetchQuest = getQuest<FetchQuest>() ?: return
if (fetchQuest.state != QuestState.ACCEPTED && fetchQuest.state != QuestState.READY_TO_COLLECT) return
val itemName = fetchQuest.itemName
val count = InventoryUtils.countItemsInLowerInventory { it.name?.contains(itemName) ?: false }
updateProcessQuest(fetchQuest, count)
}
private fun updateProcessQuest(quest: ProgressQuest, newAmount: Int) {
var count = newAmount
val needAmount = quest.needAmount
if (count > needAmount) {
count = needAmount
}
if (quest.haveAmount == count) return
LorenzUtils.chat("§e[SkyHanni] ${quest.displayName} progress: $count/$needAmount")
quest.haveAmount = count
quest.state = if (count == needAmount) QuestState.READY_TO_COLLECT else QuestState.ACCEPTED
update()
}
@SubscribeEvent
fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
val profileData = event.profileData
val sacks = profileData["sacks_counts"]?.asJsonObject ?: return
sacksCache.clear()
for ((name, v) in sacks.entrySet()) {
val amount = v.asLong
sacksCache
|