blob: f668fc22ddd12fa1c31e27756a76bef2fdf07671 (
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
|
package at.hannibal2.skyhanni.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.DamageIndicatorFinalBossEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityGuardian
import net.minecraft.network.play.server.S1CPacketEntityMetadata
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DungeonCleanEnd {
private var bossDone = false
private var chestsSpawned = false
private var lastBossId: Int = -1
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (!LorenzUtils.inDungeons) return
if (!SkyHanniMod.feature.dungeon.cleanEnd) return
val message = event.message
if (message.matchRegex("([ ]*)§r§c(The|Master Mode) Catacombs §r§8- §r§eFloor (.*)")) {
chestsSpawned = true
}
}
private fun shouldBlock(): Boolean {
if (!LorenzUtils.inDungeons) return false
if (!SkyHanniMod.feature.dungeon.cleanEnd) return false
if (!bossDone) return false
return true
}
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
bossDone = false
chestsSpawned = false
lastBossId = -1
}
@SubscribeEvent
fun onBossDead(event: DamageIndicatorFinalBossEvent) {
if (!LorenzUtils.inDungeons) return
if (bossDone) return
if (lastBossId == -1) {
lastBossId = event.id
}
}
@SubscribeEvent
fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) {
if (!LorenzUtils.inDungeons) return
if (!SkyHanniMod.feature.dungeon.cleanEnd) return
if (bossDone) return
if (lastBossId == -1) return
val packet = event.packet
if (packet !is S1CPacketEntityMetadata) return
if (packet.entityId != lastBossId) return
for (watchableObject in packet.func_149376_c()) {
if (watchableObject.dataValueId == 6) {
val health = watchableObject.`object` as Float
if (health < 1) {
val dungeonFloor = DungeonData.dungeonFloor
LorenzUtils.chat("§eFloor $dungeonFloor done!")
bossDone = true
}
}
}
}
@SubscribeEvent
fun onCheckRender(event: CheckRenderEntityEvent<*>) {
if (!shouldBlock()) return
val entity = event.entity
if (entity == Minecraft.getMinecraft().thePlayer) return
if (SkyHanniMod.feature.dungeon.cleanEndF3IgnoreGuardians) {
if (DungeonData.isOneOf("F3", "M3")) {
if (entity is EntityGuardian) {
if (entity.entityId != lastBossId) {
if (Minecraft.getMinecraft().thePlayer.isSneaking) {
return
}
}
}
}
}
if (chestsSpawned) {
if (entity is EntityArmorStand) {
if (!entity.hasCustomName()) {
return
}
}
if (entity is EntityOtherPlayerMP) {
return
}
}
event.isCanceled = true
}
@SubscribeEvent
fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
if (!shouldBlock()) return
if (event.packet is S2APacketParticles) {
event.isCanceled = true
}
}
}
|