aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorHiZe <superhize@hotmail.com>2024-01-22 19:28:55 +0100
committerGitHub <noreply@github.com>2024-01-22 19:28:55 +0100
commit9653e0d13514ed528df486741828267a8b5227f8 (patch)
tree50905d84b51e88368736cf14a89e005111ae7410 /src/main/java/at/hannibal2/skyhanni
parent09045cb73ba548ca156224d1f5b3bf076f184bc0 (diff)
downloadskyhanni-9653e0d13514ed528df486741828267a8b5227f8.tar.gz
skyhanni-9653e0d13514ed528df486741828267a8b5227f8.tar.bz2
skyhanni-9653e0d13514ed528df486741828267a8b5227f8.zip
Add: Draw box around Sulphur Block (#810)
Added Sulphur Skitter Box in Crimson Isle #810
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java55
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt114
6 files changed, 185 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index f769868a5..45c305c4b 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -279,6 +279,7 @@ import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords
import at.hannibal2.skyhanni.features.nether.PabloHelper
import at.hannibal2.skyhanni.features.nether.QuestItemHelper
+import at.hannibal2.skyhanni.features.nether.SulphurSkitterBox
import at.hannibal2.skyhanni.features.nether.VolcanoExplosivityDisplay
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazes
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazingSouls
@@ -714,6 +715,7 @@ class SkyHanniMod {
loadModule(PresentWaypoints())
loadModule(JyrreTimer())
loadModule(NewYearCakeReminder())
+ loadModule(SulphurSkitterBox())
loadModule(HighlightInquisitors())
loadModule(VerminTracker)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
index c6760ed94..465816d5c 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
@@ -20,6 +20,11 @@ public class CrimsonIsleConfig {
@Expose
public ReputationHelperConfig reputationHelper = new ReputationHelperConfig();
+ @ConfigOption(name = "Sulphur Skitter Box", desc = "")
+ @Accordion
+ @Expose
+ public SulphurSkitterBoxConfig sulphurSkitterBoxConfig = new SulphurSkitterBoxConfig();
+
@Expose
@ConfigOption(name = "Quest Item Helper", desc = "When you open the fetch item quest in the town board, " +
"it shows a clickable chat message that will grab the items needed from the sacks.")
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java
new file mode 100644
index 000000000..9577a9146
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/SulphurSkitterBoxConfig.java
@@ -0,0 +1,55 @@
+package at.hannibal2.skyhanni.config.features.crimsonisle;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.HasLegacyId;
+import at.hannibal2.skyhanni.features.nether.SulphurSkitterBox;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorColour;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import io.github.moulberry.moulconfig.observer.Property;
+
+public class SulphurSkitterBoxConfig {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Render a box around the closest sulphur block.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Box Type", desc = "Choose the look of the box.")
+ @ConfigEditorDropdown
+ public BoxType boxType = BoxType.WIREFRAME;
+
+ public enum BoxType {
+ FULL("Full"),
+ WIREFRAME("Wireframe"),
+
+ ;
+ private final String str;
+
+ BoxType(String str) {
+ this.str = str;
+ }
+
+ @Override
+ public String toString() {
+ return str;
+ }
+
+ }
+
+ @Expose
+ @ConfigOption(name = "Box Color", desc = "Choose the color of the box.")
+ @ConfigEditorColour
+ public String boxColor = "0:102:255:216:0";
+
+ @Expose
+ @ConfigOption(name = "Only With Rods", desc = "Render the box only when holding a lava fishing rod.")
+ @ConfigEditorBoolean
+ public boolean onlyWithRods = true;
+
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java
index c6bfc90f3..ad1aeb2e3 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java
@@ -1,9 +1,11 @@
package at.hannibal2.skyhanni.data.jsonobjects.repo;
+import at.hannibal2.skyhanni.utils.NEUInternalName;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Map;
+import java.util.Set;
public class ItemsJson {
@Expose
@@ -11,4 +13,10 @@ public class ItemsJson {
@Expose
public Map<String, Integer> crimson_tiers;
+
+ @Expose
+ public List<NEUInternalName> lava_fishing_rods;
+
+ @Expose
+ public List<NEUInternalName> water_fishing_rods;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
index 6edc1be10..abcf3a234 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -28,7 +28,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
object FishingAPI {
- private val lavaBlocks = listOf(Blocks.lava, Blocks.flowing_lava)
+ val lavaBlocks = listOf(Blocks.lava, Blocks.flowing_lava)
private val waterBlocks = listOf(Blocks.water, Blocks.flowing_water)
var lastCastTime = SimpleTimeMark.farPast()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt
new file mode 100644
index 000000000..3d4beaae2
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt
@@ -0,0 +1,114 @@
+package at.hannibal2.skyhanni.features.nether
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.features.crimsonisle.SulphurSkitterBoxConfig
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.features.fishing.FishingAPI
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import at.hannibal2.skyhanni.utils.RenderUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
+import at.hannibal2.skyhanni.utils.SpecialColour
+import at.hannibal2.skyhanni.utils.toLorenzVec
+import net.minecraft.init.Blocks
+import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.awt.Color
+
+class SulphurSkitterBox {
+
+ private val config get() = SkyHanniMod.feature.crimsonIsle.sulphurSkitterBoxConfig
+ private var rods = listOf<NEUInternalName>()
+ private var spongeBlocks = listOf<BlockPos>()
+ private var closestBlock: BlockPos? = null
+ private val radius = 8
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (event.isMod(5)) {
+ closestBlock = getClosestBlockToPlayer()
+ }
+ if (event.repeatSeconds(1)) {
+ val location = LocationUtils.playerLocation()
+ val from = location.add(-20, -20, -20).toBlockPos()
+ val to = location.add(20, 20, 20).toBlockPos()
+
+ spongeBlocks = BlockPos.getAllInBox(from, to).filter {
+ val b = it.toLorenzVec().getBlockAt()
+ b == Blocks.sponge && it.toLorenzVec().distanceToPlayer() <= 15
+ }.filter {
+ val pos1 = it.add(-radius, -radius, -radius)
+ val pos2 = it.add(radius, radius, radius)
+ BlockPos.getAllInBox(pos1, pos2).any { pos ->
+ pos.toLorenzVec().getBlockAt() in FishingAPI.lavaBlocks
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ spongeBlocks = emptyList()
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!isEnabled()) return
+ closestBlock?.let {
+ if (it.toLorenzVec().distanceToPlayer() >= 50) return
+ val pos1 = it.add(-radius, -radius, -radius)
+ val pos2 = it.add(radius, radius, radius)
+ val axis = AxisAlignedBB(pos1, pos2).expandBlock()
+
+ drawBox(axis, event.partialTicks)
+ }
+ }
+
+ private fun getClosestBlockToPlayer(): BlockPos? {
+ return spongeBlocks.minByOrNull { it.toLorenzVec().distanceToPlayer() }
+ }
+
+ private fun drawBox(axis: AxisAlignedBB, partialTicks: Float) {
+ val color = Color(SpecialColour.specialToChromaRGB(config.boxColor), true)
+ when (config.boxType) {
+ SulphurSkitterBoxConfig.BoxType.FULL -> {
+ RenderUtils.drawFilledBoundingBox_nea(axis,
+ color,
+ partialTicks = partialTicks,
+ renderRelativeToCamera = false)
+ }
+
+ SulphurSkitterBoxConfig.BoxType.WIREFRAME -> {
+ RenderUtils.drawWireframeBoundingBox_nea(axis, color, partialTicks)
+ }
+
+ else -> {
+ RenderUtils.drawWireframeBoundingBox_nea(axis, color, partialTicks)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ val data = event.getConstant<ItemsJson>("Items")
+ rods = data.lava_fishing_rods ?: emptyList()
+
+ if (rods.isEmpty()) {
+ error("§cConstants Items is missing data, please use /shupdaterepo")
+ }
+ }
+
+ fun isEnabled() =
+ IslandType.CRIMSON_ISLE.isInIsland() && config.enabled && (!config.onlyWithRods || InventoryUtils.itemInHandId in rods)
+}