blob: 85bd64e9e32e3f070063f908c2b14653e7ad594f (
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
package at.hannibal2.skyhanni.features.slayer
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.EntityClickEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.playSound
import at.hannibal2.skyhanni.utils.toLorenzVec
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.event.entity.living.LivingDeathEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.milliseconds
object VampireSlayerFeatures {
private val config get() = SkyHanniMod.feature.slayer.vampire
private val configOwnBoss get() = config.ownBoss
private val configOtherBoss get() = config.othersBoss
private val configCoopBoss get() = config.coopBoss
private val configBloodIchor get() = config.bloodIchor
private val configKillerSpring get() = config.killerSpring
private val entityList = mutableListOf<EntityLivingBase>()
private val taggedEntityList = mutableListOf<Int>()
private var standList = mapOf<EntityArmorStand, EntityOtherPlayerMP>()
private val username get() = LorenzUtils.getPlayerName()
private val bloodIchorTexture =
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAzNDA5MjNhNmRlNDgyNWExNzY4MTNkMTMzNTAzZWZmMTg2ZGIwODk2ZTMyYjY3MDQ5MjhjMmEyYmY2ODQyMiJ9fX0="
private val killerSpringTexture =
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzdmN2E3YmM4YWM4NmYyM2NhN2JmOThhZmViNzY5NjAyMjdlMTgzMmZlMjA5YTMwMjZmNmNlYjhiZGU3NGY1NCJ9fX0="
private var nextClawSend = 0L
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
if (!event.isMod(5)) return
val start = LocationUtils.playerLocation()
if (configOwnBoss.highlight || configOtherBoss.highlight || configCoopBoss.highlight) {
EntityUtils.getEntities<EntityOtherPlayerMP>().forEach {
val vec = it.position.toLorenzVec()
val distance = start.distance(vec)
if (distance <= 15)
it.process()
}
}
if (configBloodIchor.highlight || configKillerSpring.highlight) {
EntityUtils.getEntities<EntityArmorStand>().forEach { stand ->
val vec = stand.position.toLorenzVec()
val distance = start.distance(vec)
val isIchor = stand.hasSkullTexture(bloodIchorTexture)
if (isIchor || stand.hasSkullTexture(killerSpringTexture)) {
val color = (if (isIchor) configBloodIchor.color else configKillerSpring.color)
.toChromaColor().withAlpha(config.withAlpha)
if (distance <= 15) {
RenderLivingEntityHelper.setEntityColor(
stand,
color
) { isEnabled() }
if (isIchor)
entityList.add(stand)
}
}
}
}
if (event.repeatSeconds(1)) {
entityList.editCopy { removeIf { it.isDead } }
}
}
private fun EntityOtherPlayerMP.process() {
if (name != "Bloodfiend ") return
if (configOwnBoss.twinClawsTitle || configOtherBoss.twinClawsTitle || configCoopBoss.twinClawsTitle) {
getAllNameTagsInRadiusWith("TWINCLAWS").forEach { stand ->
if (".*(?:§(?:\\d|\\w))+TWINCLAWS (?:§(?:\\w|\\d))+[0-9.,]+s.*".toRegex().matches(stand.name)) {
val coopList = configCoopBoss.coopMembers.split(",").toList()
val containUser = getAllNameTagsInRadiusWith("Spawned by").any {
it.name.contains(username)
}
val containCoop = getAllNameTagsInRadiusWith("Spawned by").any {
coopList.isNotEmpty() && configCoopBoss.highlight && coopList.any { it2 ->
var contain = false
if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) {
val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex()
.find(it.name)?.groupValues?.get(1)
contain = it2 == name
}
contain
}
}
val shouldSendTitle =
if (containUser && configOwnBoss.twinClawsTitle) true
else if (containCoop && configCoopBoss.twinClawsTitle) true
else taggedEntityList.contains(this.entityId) && configOtherBoss.twinClawsTitle
val shouldSendSound =
if (containUser && configOwnBoss.twinClawsSound) true
else if (containCoop && configCoopBoss.twinClawsSound) true
else taggedEntityList.contains(this.entityId) && configOtherBoss.twinClawsSound
if (shouldSendTitle || shouldSendSound) {
DelayedRun.runDelayed(config.twinclawsDelay.milliseconds) {
if (nextClawSend < System.currentTimeMillis()) {
if (shouldSendSound)
playTwinclawsSound()
if (shouldSendTitle) {
LorenzUtils.sendTitle(
"§6§lTWINCLAWS",
(1750 - config.twinclawsDelay).milliseconds,
2.6
)
}
nextClawSend = System.currentTimeMillis() + 5_000
}
}
}
}
}
}
getAllNameTagsInRadiusWith("Spawned by").forEach {
val coopList = configCoopBoss.coopMembers.split(",").toList()
val containUser = it.name.contains(username)
val containCoop = coopList.isNotEmpty() && coopList.any { it2 ->
var contain = false
if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) {
val name =
".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1)
contain = it2 == name
}
contain
}
val neededHealth = when (baseMaxHealth) {
625 -> 125f // t1
1100 -> 220f // t2
1800 -> 360f // t3
2400 -> 480f // t4
else -> 600f // t5
}
if (containUser && taggedEntityList.contains(this.entityId)) {
taggedEntityList.remove(this.entityId)
}
val canUseSteak = health <= neededHealth
val ownBoss = configOwnBoss.highlight && containUser && isNPC()
val otherBoss = configOtherBoss.highlight && taggedEntityList.contains(this.entityId) && isNPC()
val coopBoss = configCoopBoss.highlight &&<
|