Skip to content

Commit

Permalink
Merge branch 'beta' of https://github.com/hannibal002/SkyHanni into c…
Browse files Browse the repository at this point in the history
…opy-entire-inventory
  • Loading branch information
RayDeeUx committed Jan 17, 2024
2 parents 05f596a + a057900 commit ad589ef
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 8 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 @@ -248,6 +248,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 @@ -371,6 +372,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 @@ -580,6 +582,7 @@ class SkyHanniMod {
loadModule(MinionCollectLogic())
loadModule(BetterSignEditing())
loadModule(PatcherSendCoordinates())
loadModule(PetItemDisplay())
loadModule(EstimatedItemValue)
loadModule(EstimatedWardrobePrice())
loadModule(ComposterInventoryNumbers())
Expand Down Expand Up @@ -759,6 +762,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 @@ -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)
}
}
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 @@ -639,8 +639,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 ad589ef

Please sign in to comment.