aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt82
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt27
4 files changed, 121 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 1d5281b60..a242ccbc8 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -234,6 +234,7 @@ public class SkyHanniMod {
loadModule(new GardenVisitorColorNames());
loadModule(new GardenTeleportPadCompactName());
loadModule(new AnitaMedalProfit());
+ loadModule(new ComposterDisplay());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index aba49896a..dd78c3095 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -602,7 +602,22 @@ public class Garden {
@Expose
public Position anitaMedalProfitPos = new Position(206, 158, false, true);
+ @Expose
+ @ConfigOption(name = "Composter", desc = "")
+ @ConfigEditorAccordion(id = 16)
+ public boolean composter = false;
+ @Expose
+ @ConfigOption(
+ name = "Compact Display",
+ desc = "Displays the compost data from the tab list in a compact form as gui element."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 16)
+ public boolean composterDisplayEnabled = true;
+
+ @Expose
+ public Position composterDisplayPos = new Position(-363, 13, false, true);
@Expose
@ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt
new file mode 100644
index 000000000..7c2b92ebd
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt
@@ -0,0 +1,82 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.TabListUpdateEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class ComposterDisplay {
+ private val config get() = SkyHanniMod.feature.garden
+ private var display = listOf<List<Any>>()
+
+ enum class DataType(val pattern: String, val icon: String) {
+ ORGANIC_MATTER(" Organic Matter: §r(.*)", "WHEAT"),
+ FUEL(" Fuel: §r(.*)", "OIL_BARREL"),
+ TIME_LEFT(" Time Left: §r(.*)", "WATCH"),
+ STORED_COMPOST(" Stored Compost: §r(.*)", "COMPOST"),
+ ;
+
+ val displayItem by lazy {
+ NEUItems.getItemStack(icon)
+ }
+
+ fun addToList(map: Map<DataType, String>): List<Any> {
+ return listOf(displayItem, map[this]!!)
+ }
+ }
+
+ @SubscribeEvent
+ fun onTabListUpdate(event: TabListUpdateEvent) {
+ if (!isEnabled()) return
+
+ var next = false
+ println(" ")
+ val data = mutableMapOf<DataType, String>()
+
+ for (line in event.tabList) {
+ if (line == "§b§lComposter:") {
+ next = true
+ continue
+ }
+ if (next) {
+ if (line == "") break
+ for (type in DataType.values()) {
+ val pattern = Pattern.compile(type.pattern)
+ val matcher = pattern.matcher(line)
+ if (matcher.matches()) {
+ data[type] = matcher.group(1)
+ }
+ }
+ println("'$line'")
+ }
+ }
+
+ val newList = mutableListOf<List<Any>>()
+ newList.addAsSingletonList("§bComposter")
+
+ newList.add(DataType.TIME_LEFT.addToList(data))
+
+ val list = mutableListOf<Any>()
+ list.addAll(DataType.ORGANIC_MATTER.addToList(data))
+ list.add(" ")
+ list.addAll(DataType.FUEL.addToList(data))
+ newList.add(list)
+
+ newList.add(DataType.STORED_COMPOST.addToList(data))
+
+ display = newList
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (isEnabled()) {
+ config.composterDisplayPos.renderStringsAndItems(display, posLabel = "Composter Display")
+ }
+ }
+
+ fun isEnabled() = config.composterDisplayEnabled && GardenAPI.inGarden()
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index c35d5cd01..9347cb488 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -1,10 +1,7 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.ConfigLoadEvent
-import at.hannibal2.skyhanni.events.GuiRenderEvent
-import at.hannibal2.skyhanni.events.InventoryCloseEvent
-import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -29,6 +26,27 @@ class GardenNextJacobContest {
private val contestDuration = 1_000 * 60 * 20
@SubscribeEvent
+ fun onTabListUpdate(event: TabListUpdateEvent) {
+ if (!isEnabled()) return
+
+ var next = false
+ val newList = mutableListOf<String>()
+ for (line in event.tabList) {
+ if (line == "§b§lComposter:") {
+ newList.add(line)
+ next = true
+ continue
+ }
+ if (next) {
+ if (line == "") break
+ newList.add(line)
+ }
+ }
+
+ display = newList
+ }
+
+ @SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!isEnabled()) return
if (tick++ % (40) != 0) return
@@ -137,6 +155,7 @@ class GardenNextJacobContest {
}
if (contests.isEmpty()) {
+
list.add("§cOpen calendar to read jacob contest times!")
return list
}