aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftMotesOrb.kt101
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerBeacon.kt34
3 files changed, 119 insertions, 40 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt
index 120e77e4d..a450280f9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt
@@ -29,25 +29,11 @@ class LivingCaveDefenseBlocks {
private val config get() = RiftAPI.config.area.livingCaveConfig.defenseBlockConfig
private var movingBlocks = mapOf<DefenseBlock, Long>()
private var staticBlocks = emptyList<DefenseBlock>()
-// private var helpLocation = emptyList<LorenzVec>()
class DefenseBlock(val entity: EntityOtherPlayerMP, val location: LorenzVec, var hidden: Boolean = false)
@SubscribeEvent
fun onReceiveParticle(event: ReceiveParticleEvent) {
- val location = event.location.add(-0.5, 0.0, -0.5)
-
-// if (event.type == EnumParticleTypes.CRIT_MAGIC) {
-// helpLocation = helpLocation.editCopy { add(location) }
-// }
-
- // TODO remove
- Minecraft.getMinecraft().thePlayer?.let {
- if (it.isSneaking) {
- staticBlocks = emptyList()
-// helpLocation = emptyList()
- }
- }
if (!isEnabled()) return
movingBlocks = movingBlocks.editCopy {
@@ -55,6 +41,7 @@ class LivingCaveDefenseBlocks {
keys.removeIf { staticBlocks.any { others -> others.location.distance(it.location) < 1.5 } }
}
+ val location = event.location.add(-0.5, 0.0, -0.5)
// Ignore particles around blocks
if (staticBlocks.any { it.location.distance(location) < 3 }) {
@@ -148,11 +135,6 @@ class LivingCaveDefenseBlocks {
@SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
-// for (location in helpLocation) {
-// event.drawWaypointFilled(location, LorenzColor.GREEN.toColor())
-// event.drawDynamicText(location, "§aTest", 1.5)
-//
-// }
if (!isEnabled()) return
@@ -172,15 +154,15 @@ class LivingCaveDefenseBlocks {
}
for (block in staticBlocks) {
val location = block.location
+ event.drawDynamicText(location, "§bBreak!", 1.5, ignoreBlocks = false)
event.drawWaypointFilled(location, color)
- event.drawDynamicText(location, "§bBreak!", 1.5)
event.draw3DLine(
block.entity.getLorenzVec().add(0.0, 0.5, 0.0),
location.add(0.5, 0.5, 0.5),
color,
3,
- false
+ true,
)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftMotesOrb.kt
new file mode 100644
index 000000000..f83a9dfd6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftMotesOrb.kt
@@ -0,0 +1,101 @@
+package at.hannibal2.skyhanni.features.rift.everywhere
+
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.ReceiveParticleEvent
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import net.minecraft.client.Minecraft
+import net.minecraft.util.EnumParticleTypes
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class RiftMotesOrb {
+ private val config get() = RiftAPI.config.motesOrbsConfig
+ private var motesOrbs = emptyList<MotesOrb>()
+ private val pattern = "§5§lORB! §r§dPicked up §r§5+.* Motes§r§d.*".toPattern()
+
+ class MotesOrb(
+ var location: LorenzVec,
+ var counter: Int = 0,
+ var startTime: Long = System.currentTimeMillis(),
+ var lastTime: Long = System.currentTimeMillis(),
+ var isOrb: Boolean = false,
+ var pickedUp: Boolean = false,
+ )
+
+ @SubscribeEvent
+ fun onReceiveParticle(event: ReceiveParticleEvent) {
+ if (!isEnabled()) return
+ val location = event.location.add(-0.5, 0.0, -0.5)
+
+ if (event.type == EnumParticleTypes.SPELL_MOB) {
+ val orb =
+ motesOrbs.find { it.location.distance(location) < 3 } ?: MotesOrb(location).also {
+ motesOrbs = motesOrbs.editCopy { add(it) }
+ }
+
+ orb.location = location
+ orb.lastTime = System.currentTimeMillis()
+ orb.counter++
+ orb.pickedUp = false
+ if (config.hideParticles && orb.isOrb) {
+ event.isCanceled = true
+ }
+ }
+
+
+ // TODO remove
+ Minecraft.getMinecraft().thePlayer?.let {
+ if (it.isSneaking) {
+ motesOrbs = emptyList()
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ pattern.matchMatcher(event.message) {
+ motesOrbs.minByOrNull { it.location.distanceToPlayer() }?.let {
+ it.pickedUp = true
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+
+ motesOrbs = motesOrbs.editCopy { removeIf { System.currentTimeMillis() > it.lastTime + 2000 } }
+
+ for (orb in motesOrbs) {
+ val ageInSeconds = (System.currentTimeMillis() - orb.startTime).toDouble() / 1000
+ if (ageInSeconds < 0.5) continue
+
+ val particlesPerSecond = (orb.counter.toDouble() / ageInSeconds).round(1)
+ if (particlesPerSecond < 60 || particlesPerSecond > 90) continue
+ orb.isOrb = true
+
+ if (System.currentTimeMillis() > orb.lastTime + 300) {
+ orb.pickedUp = true
+ }
+
+ val location = orb.location
+
+ if (orb.pickedUp) {
+ event.drawDynamicText(location.add(0.0, 0.5, 0.0), "§7Motes Orb", 1.5, ignoreBlocks = false)
+ event.drawWaypointFilled(location, LorenzColor.GRAY.toColor())
+ } else {
+ event.drawDynamicText(location.add(0.0, 0.5, 0.0), "§dMotes Orb", 1.5, ignoreBlocks = false)
+ event.drawWaypointFilled(location, LorenzColor.LIGHT_PURPLE.toColor())
+ }
+ }
+ }
+
+ fun isEnabled() = RiftAPI.inRift() && config.enabled
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerBeacon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerBeacon.kt
index 970a7f1dc..12e66c313 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerBeacon.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerBeacon.kt
@@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.slayer
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
-import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
@@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.init.Blocks
-import net.minecraft.network.play.server.S23PacketBlockChange
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -81,25 +80,22 @@ class EndermanSlayerBeacon {
}
}
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onPacketReceive(event: PacketEvent.ReceiveEvent) {
+ @SubscribeEvent
+ fun onBlockChange(event: ServerBlockChangeEvent) {
if (!isEnabled()) return
- val packet = event.packet
- if (packet is S23PacketBlockChange) {
- val location = packet.blockPosition.toLorenzVec()
- if (packet.blockState?.block == Blocks.beacon) {
- val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 }
- if (armorStand != null) {
- flyingBeacons.remove(armorStand)
- sittingBeacon.add(location)
- logger.log("Replaced flying beacon with sitting beacon at $location")
- }
- } else {
- if (location in sittingBeacon) {
- logger.log("Removed sitting beacon $location")
- sittingBeacon.remove(location)
- }
+ val location = event.location
+ if (event.new == "beacon") {
+ val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 }
+ if (armorStand != null) {
+ flyingBeacons.remove(armorStand)
+ sittingBeacon.add(location)
+ logger.log("Replaced flying beacon with sitting beacon at $location")
+ }
+ } else {
+ if (location in sittingBeacon) {
+ logger.log("Removed sitting beacon $location")
+ sittingBeacon.remove(location)
}
}
}