Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into item-stack-size
Browse files Browse the repository at this point in the history
  • Loading branch information
RayDeeUx authored Dec 11, 2023
2 parents 75e6d7e + 9a5d44a commit 00f2ad4
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning
import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper
import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerFeatures
import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerHideParticles
import at.hannibal2.skyhanni.features.stranded.HighlightPlaceableNpcs
import at.hannibal2.skyhanni.features.summonings.SummoningMobManager
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
Expand Down Expand Up @@ -688,6 +689,7 @@ class SkyHanniMod {
loadModule(PestSpawnTimer)
loadModule(PestFinder())
loadModule(SprayFeatures())
loadModule(HighlightPlaceableNpcs())
loadModule(PresentWaypoints())
loadModule(JyrreTimer())

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/config/Features.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import at.hannibal2.skyhanni.config.features.dungeon.DungeonConfig;
import at.hannibal2.skyhanni.config.features.event.EventConfig;
import at.hannibal2.skyhanni.config.features.fishing.FishingConfig;
import at.hannibal2.skyhanni.config.features.gui.GUIConfig;
import at.hannibal2.skyhanni.config.features.garden.GardenConfig;
import at.hannibal2.skyhanni.config.features.gui.GUIConfig;
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig;
import at.hannibal2.skyhanni.config.features.itemability.ItemAbilityConfig;
import at.hannibal2.skyhanni.config.features.markedplayer.MarkedPlayerConfig;
Expand All @@ -22,6 +22,7 @@
import at.hannibal2.skyhanni.config.features.misc.MiscConfig;
import at.hannibal2.skyhanni.config.features.rift.RiftConfig;
import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig;
import at.hannibal2.skyhanni.config.features.stranded.StrandedConfig;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.Config;
import io.github.moulberry.moulconfig.Social;
Expand Down Expand Up @@ -137,6 +138,10 @@ public String getTitle() {
@Category(name = "Slayer", desc = "Slayer features.")
public SlayerConfig slayer = new SlayerConfig();

@Expose
@Category(name = "Stranded", desc = "Features for the Stranded game mode.")
public StrandedConfig stranded = new StrandedConfig();

@Expose
@Category(name = "The Rift", desc = "Features for The Rift dimension.")
public RiftConfig rift = new RiftConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package at.hannibal2.skyhanni.config.features.stranded;

import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigOption;

public class StrandedConfig {
@Expose
@ConfigOption(name = "Highlight Placeable NPCs", desc = "Highlight NPCs that can be placed, but aren't, in the NPC menu.")
@ConfigEditorBoolean
@FeatureToggle
public boolean highlightPlaceableNpcs = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class SharkFishCounter {
private var counter = 0
private var counter = mutableListOf(0, 0, 0, 0)
private var display = ""
private var hasWaterRodInHand = false

@SubscribeEvent
fun onSeaCreatureFish(event: SeaCreatureFishEvent) {
if (!SkyHanniMod.feature.fishing.sharkFishCounter) return

if (event.seaCreature.name.contains("Shark")) {
counter += if (event.doubleHook) 2 else 1
display = "§7Sharks caught: §e${counter.addSeparators()}"
}
val name = event.seaCreature.name
if (!name.contains("Shark")) return
counter[sharkIndex(name)] += if (event.doubleHook) 2 else 1
display = "§7Sharks caught: §e${
counter.sum().addSeparators()
} §7(§a${counter[0]} §9${counter[1]} §5${counter[2]} §6${counter[3]}§7)"
}

private fun sharkIndex(name: String): Int = when {
name.contains("Blue") -> 1
name.contains("Tiger") -> 2
name.contains("Great") -> 3
else -> 0
}

@SubscribeEvent
Expand All @@ -37,20 +46,29 @@ class SharkFishCounter {

@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (event.message == "§b§lFISHING FESTIVAL §r§eThe festival has concluded! Time to dry off and repair your rods!") {
val funnyComment = when {
counter == 0 -> return
counter < 50 -> "Well done!"
counter < 100 -> "Nice!"
counter < 150 -> "Really nice!"
counter < 200 -> "Super cool!"
counter < 250 -> "Mega cool!"
counter < 350 -> "Like a pro!"
else -> "How???"
}
LorenzUtils.chat("You caught ${counter.addSeparators()} sharks during this fishing contest. $funnyComment")
counter = 0
}
if (event.message != "§b§lFISHING FESTIVAL §r§eThe festival has concluded! Time to dry off and repair your rods!") return
val count = counter.sum()
if (count == 0) return

val n = counter[0] // Nurse
val b = counter[1] // Blue
val t = counter[2] // Tiger
val g = counter[3] // Great White
val total = count.addSeparators()
val funnyComment = funnyComment(count)
LorenzUtils.chat("You caught $total §f(§a$n §9$b §5$t §6$g§f) sharks during this fishing contest. $funnyComment")
counter = mutableListOf(0, 0, 0, 0)
display = ""
}

private fun funnyComment(count: Int): String = when {
count < 50 -> "Well done!"
count < 100 -> "Nice!"
count < 150 -> "Really nice!"
count < 200 -> "Super cool!"
count < 250 -> "Mega cool!"
count < 350 -> "Like a pro!"
else -> "How???"
}

private fun isWaterFishingRod() = FishingAPI.hasFishingRodInHand() && !FishingAPI.isLavaRod()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package at.hannibal2.skyhanni.features.stranded

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class HighlightPlaceableNpcs {
private val config get() = SkyHanniMod.feature.stranded.highlightPlaceableNpcs
private val locationPattern = "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]".toPattern()

private var inInventory = false
private var highlightedItems = emptyList<Int>()

@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
inInventory = false
if (!isEnabled()) return

if (event.inventoryName != "Island NPCs") return

val highlightedItems = mutableListOf<Int>()
for ((slot, stack) in event.inventoryItems) {
if (isPlaceableNpc(stack.getLore())) {
highlightedItems.add(slot)
}
}
inInventory = true
this.highlightedItems = highlightedItems
}

@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
inInventory = false
highlightedItems = emptyList()
}

@SubscribeEvent(priority = EventPriority.LOW)
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!isEnabled() || !inInventory) return
for (slot in InventoryUtils.getItemsInOpenChest()) {
if (slot.slotIndex in highlightedItems) {
slot highlight LorenzColor.GREEN
}
}
}

private fun isPlaceableNpc(lore: List<String>): Boolean {
// Checking if NPC & placeable
if (lore.isEmpty() || !(lore.last() == "§ethis NPC!" || lore.last() == "§eyour location!")) {
return false
}

// Checking if is already placed
for (line in lore) {
if (locationPattern.matcher(line).matches()) return false
}
return true
}

private fun isEnabled() = LorenzUtils.inSkyBlock && config
}

0 comments on commit 00f2ad4

Please sign in to comment.