aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorClicks <58398364+CuzImClicks@users.noreply.github.com>2024-10-11 19:11:57 +0200
committerGitHub <noreply@github.com>2024-10-11 19:11:57 +0200
commit46824035c67b50320e1d12f16d0692d3ef261ece (patch)
treedd763c29396b2706a41f31386d46485596ab0e27 /src/main/java/at/hannibal2
parent9a2286ac3070e1ba0023445dc8243e618989e86e (diff)
downloadskyhanni-46824035c67b50320e1d12f16d0692d3ef261ece.tar.gz
skyhanni-46824035c67b50320e1d12f16d0692d3ef261ece.tar.bz2
skyhanni-46824035c67b50320e1d12f16d0692d3ef261ece.zip
Feature: Precision Mining Hightlighter (#2614)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/PrecisionMiningHighlight.kt69
2 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
index 08c8ec894..2c460bd2f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
@@ -96,4 +96,10 @@ public class MiningConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean highlightYourGoldenGoblin = true;
+
+ @Expose
+ @ConfigOption(name = "Precision Mining Helper", desc = "Draws a box over the Precision Mining particles.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlightPrecisionMiningParticles = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/PrecisionMiningHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/PrecisionMiningHighlight.kt
new file mode 100644
index 000000000..462a96348
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/PrecisionMiningHighlight.kt
@@ -0,0 +1,69 @@
+package at.hannibal2.skyhanni.features.mining
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.ReceiveParticleEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
+import at.hannibal2.skyhanni.utils.TimeUtils.ticks
+import at.hannibal2.skyhanni.utils.toLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.EnumParticleTypes
+import net.minecraft.util.MovingObjectPosition
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.awt.Color
+
+@SkyHanniModule
+object PrecisionMiningHighlight {
+
+ private val config get() = SkyHanniMod.feature.mining.highlightPrecisionMiningParticles
+
+ private var lastParticle: AxisAlignedBB? = null
+ private var lookingAtParticle: Boolean = false
+ private var deleteTime: SimpleTimeMark? = null
+
+ @SubscribeEvent
+ fun onParticle(event: ReceiveParticleEvent) {
+ if (!isEnabled()) return
+ if (!(event.type == EnumParticleTypes.CRIT || event.type == EnumParticleTypes.VILLAGER_HAPPY) ||
+ !Minecraft.getMinecraft().gameSettings.keyBindAttack.isKeyDown) return
+
+ val mouseOverObject = Minecraft.getMinecraft().objectMouseOver
+ if (mouseOverObject.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return
+
+ val particleBoundingBox = event.location.add(-0.12, -0.12, -0.12)
+ .axisAlignedTo(event.location.clone().add(0.12, 0.12, 0.12))
+
+ val blockBoundingBox = mouseOverObject.blockPos.toLorenzVec()
+ .axisAlignedTo(mouseOverObject.blockPos.add(1, 1, 1).toLorenzVec())
+ if (!blockBoundingBox.intersectsWith(particleBoundingBox)) return
+
+ lookingAtParticle = event.type == EnumParticleTypes.VILLAGER_HAPPY
+ lastParticle = particleBoundingBox
+ deleteTime = 5.ticks.fromNow()
+ }
+
+ @SubscribeEvent
+ fun onRender(event: LorenzRenderWorldEvent) {
+ val particleBoundingBox = lastParticle ?: return
+
+ event.drawFilledBoundingBox_nea(particleBoundingBox, if (lookingAtParticle) Color.GREEN else Color.CYAN)
+ }
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ lastParticle ?: return
+ val deletionTime = deleteTime ?: return
+ if (deletionTime.isInPast()) {
+ deleteTime = null
+ lastParticle = null
+ }
+ }
+
+ fun isEnabled() = MiningAPI.inCustomMiningIsland() && config
+}