Skip to content

Commit

Permalink
Merge branch 'beta' of https://github.com/hannibal002/SkyHanni into i…
Browse files Browse the repository at this point in the history
…tem-stack-size
  • Loading branch information
RayDeeUx committed Jan 17, 2024
2 parents eceab18 + a057900 commit a0d550d
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 46 deletions.
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ import at.hannibal2.skyhanni.features.misc.PartyMemberOutlines
import at.hannibal2.skyhanni.features.misc.PatcherSendCoordinates
import at.hannibal2.skyhanni.features.misc.PetCandyUsedDisplay
import at.hannibal2.skyhanni.features.misc.PetExpTooltip
import at.hannibal2.skyhanni.features.misc.PetItemDisplay
import at.hannibal2.skyhanni.features.misc.PlayerChatSymbols
import at.hannibal2.skyhanni.features.misc.PocketSackInASackDisplay
import at.hannibal2.skyhanni.features.misc.QuickModMenuSwitch
Expand Down Expand Up @@ -379,6 +380,7 @@ import org.apache.logging.log4j.Logger
version = "0.23.Beta.8",
)
class SkyHanniMod {

@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent?) {
checkIfNeuIsLoaded()
Expand Down Expand Up @@ -596,6 +598,7 @@ class SkyHanniMod {
loadModule(MinionCollectLogic())
loadModule(BetterSignEditing())
loadModule(PatcherSendCoordinates())
loadModule(PetItemDisplay())
loadModule(EstimatedItemValue)
loadModule(EstimatedWardrobePrice())
loadModule(ComposterInventoryNumbers())
Expand Down Expand Up @@ -775,6 +778,7 @@ class SkyHanniMod {
}

companion object {

const val MODID = "skyhanni"

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.Accordion;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PetConfig {
@Expose
Expand All @@ -28,4 +32,32 @@ public class PetConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean hideAutopet = false;

@Expose
@ConfigOption(name = "Show Pet Item", desc = "Specifies the pet items for which icons should be displayed next to pets.")
@ConfigEditorDraggableList
public List<PetItemsDisplay> petItemDisplay = new ArrayList<>(Arrays.asList(
PetItemsDisplay.XP_SHARE,
PetItemsDisplay.TIER_BOOST
));

public enum PetItemsDisplay {
XP_SHARE("§5⚘", "Exp Share", "PET_ITEM_EXP_SHARE"),
TIER_BOOST("§c●", "Tier Boost", "PET_ITEM_TIER_BOOST"),
;
private final String str;
public final String icon;
public final String item;

PetItemsDisplay(String icon, String name, String item) {
this.icon = icon;
this.item = item;
this.str = icon + " §ffor " + name;
}

@Override
public String toString() {
return str;
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class TitleManager {
private var display = ""
private var endTime = SimpleTimeMark.farPast()
private var heightModifier = 1.8
private var fontSizeModifier = 4.0
private var fontSizeModifier = 4f

fun sendTitle(text: String, duration: Duration, height: Double = 1.8, fontSize: Double = 4.0) {
fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) {
display = "§f$text"
endTime = SimpleTimeMark.now() + duration
heightModifier = height
Expand All @@ -36,7 +36,7 @@ class TitleManager {

val duration = args[0].toInt().seconds
val height = args[1].toDouble()
val fontSize = args[2].toDouble()
val fontSize = args[2].toFloat()
val title = "§6" + args.drop(3).joinToString(" ").replace("&", "§")

sendTitle(title, duration, height, fontSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiEditSign
Expand All @@ -35,8 +37,15 @@ class CityProjectFeatures {
private var inInventory = false
private var lastReminderSend = 0L

// TODO USE SH-REPO
private val contributeAgainPattern = "§7Contribute again: §e(?<time>.*)".toPattern()
private val patternGroup = RepoPattern.group("fame.projects")
private val contributeAgainPattern by patternGroup.pattern(
"contribute",
"§7Contribute again: §e(?<time>.*)"
)
private val completedPattern by patternGroup.pattern(
"completed",
"§aProject is (?:being built|released)!"
)

companion object {
private val config get() = SkyHanniMod.feature.event.cityProject
Expand Down Expand Up @@ -104,7 +113,8 @@ class CityProjectFeatures {
val itemName = item.name ?: continue

val lore = item.getLore()
if (lore.lastOrNull() == "§aProject is being built!") continue
val completed = lore.lastOrNull()?.let { completedPattern.matches(it) } ?: false
if (completed) continue
for (line in lore) {
contributeAgainPattern.matchMatcher(line) {
val rawTime = group("time")
Expand Down Expand Up @@ -163,7 +173,8 @@ class CityProjectFeatures {
private fun fetchMaterials(item: ItemStack, materials: MutableMap<String, Int>) {
var next = false
val lore = item.getLore()
if (lore.lastOrNull() == "§aProject is being built!") return
val completed = lore.lastOrNull()?.let { completedPattern.matches(it) } ?: false
if (completed) return
for (line in lore) {
if (line == "§7Cost") {
next = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent
Expand Down Expand Up @@ -59,7 +58,7 @@ class SeaCreatureFeatures {

if (config.alertOtherCatches && lastRareCatch.passedSince() > 1.seconds) {
val creature = SeaCreatureManager.allFishingMobs[creatureType.nametag]
TitleManager.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6, 7.0)
LorenzUtils.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6, 7f)
if (config.playSound) SoundUtils.playBeepSound()
}
}
Expand All @@ -71,7 +70,7 @@ class SeaCreatureFeatures {
if (!config.alertOwnCatches) return

if (event.seaCreature.rare) {
TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 2.8, 7.0)
LorenzUtils.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 2.8, 7f)
if (config.playSound) SoundUtils.playBeepSound()
lastRareCatch = SimpleTimeMark.now()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetItem
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class PetItemDisplay {

private val configList get() = SkyHanniMod.feature.misc.pets.petItemDisplay

@SubscribeEvent
fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) {
val stack = event.stack ?: return
if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return
if (configList.isEmpty()) return

val petItem = stack.getPetItem() ?: return
val icon = configList.firstOrNull { it.item == petItem }?.icon ?: return

val x = event.x + 17
val y = event.y - 1

event.drawSlotText(x, y, icon, .9f)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,47 @@ import java.util.Locale

object EstimatedItemValueCalculator {
private val config get() = SkyHanniMod.feature.misc.estimatedItemValues

fun calculate(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> {
var totalPrice = 0.0
val basePrice = addBaseItem(stack, list)
totalPrice += basePrice

totalPrice += addAttributeCost(stack, list)

totalPrice += addReforgeStone(stack, list)
private val additionalCostFunctions = listOf(
::addAttributeCost,
::addReforgeStone,

// once
totalPrice += addRecomb(stack, list)
totalPrice += addArtOfWar(stack, list)
totalPrice += addArtOfPeace(stack, list)
totalPrice += addEtherwarp(stack, list)
totalPrice += addPowerScrolls(stack, list)
totalPrice += addWoodSingularity(stack, list)
totalPrice += addJalapenoBook(stack, list)
totalPrice += addStatsBook(stack, list)
totalPrice += addEnrichment(stack, list)
::addRecomb,
::addArtOfWar,
::addArtOfPeace,
::addEtherwarp,
::addPowerScrolls,
::addWoodSingularity,
::addJalapenoBook,
::addStatsBook,
::addEnrichment,

// counted
totalPrice += addMasterStars(stack, list)
totalPrice += addHotPotatoBooks(stack, list)
totalPrice += addFarmingForDummies(stack, list)
totalPrice += addSilex(stack, list)
totalPrice += addTransmissionTuners(stack, list)
totalPrice += addManaDisintegrators(stack, list)
totalPrice += addPolarvoidBook(stack, list)
totalPrice += addBookwormBook(stack, list)
::addMasterStars,
::addHotPotatoBooks,
::addFarmingForDummies,
::addSilex,
::addTransmissionTuners,
::addManaDisintegrators,
::addPolarvoidBook,
::addBookwormBook,

// cosmetic
totalPrice += addHelmetSkin(stack, list)
totalPrice += addArmorDye(stack, list)
totalPrice += addRune(stack, list)
::addHelmetSkin,
::addArmorDye,
::addRune,

// dynamic
totalPrice += addAbilityScrolls(stack, list)
totalPrice += addDrillUpgrades(stack, list)
totalPrice += addGemstoneSlotUnlockCost(stack, list)
totalPrice += addGemstones(stack, list)
totalPrice += addEnchantments(stack, list)
::addAbilityScrolls,
::addDrillUpgrades,
::addGemstoneSlotUnlockCost,
::addGemstones,
::addEnchantments
)

fun calculate(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> {
val basePrice = addBaseItem(stack, list)
val totalPrice = additionalCostFunctions.fold(basePrice) { total, function -> total + function(stack, list) }
return Pair(totalPrice, basePrice)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ object LorenzUtils {
fun <T> T.conditionalTransform(condition: Boolean, ifTrue: T.() -> Any, ifFalse: T.() -> Any) =
if (condition) ifTrue(this) else ifFalse(this)

fun sendTitle(text: String, duration: Duration, height: Double = 1.8) {
TitleManager.sendTitle(text, duration, height)
fun sendTitle(text: String, duration: Duration, height: Double = 1.8, fontSize: Float = 4f) {
TitleManager.sendTitle(text, duration, height, fontSize)
}

@Deprecated("Dont use this approach at all. check with regex or equals instead.", ReplaceWith("Regex or equals"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ object SkyBlockItemModifierUtils {
return data.petCandies
}

// TODO use NeuInternalName here
fun ItemStack.getPetItem(): String? {
val data = cachedData
if (data.heldItem == "") {
Expand Down

0 comments on commit a0d550d

Please sign in to comment.