diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-06-23 08:19:22 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-23 08:19:22 +1000 |
commit | 649e7ecd4c601d05d51c1decab91675e77e99ef9 (patch) | |
tree | 600a2c6abf4298a602df747591f1064bdbe4029f /src/main | |
parent | 34e7fe2a360da747750b90c7f11a136e5513d1d8 (diff) | |
parent | 46968a541e2231caadd9a9fc471277054bd012cd (diff) | |
download | skyhanni-649e7ecd4c601d05d51c1decab91675e77e99ef9.tar.gz skyhanni-649e7ecd4c601d05d51c1decab91675e77e99ef9.tar.bz2 skyhanni-649e7ecd4c601d05d51c1decab91675e77e99ef9.zip |
Merge branch 'hannibal002:beta' into frozen_treasure_tracker
Diffstat (limited to 'src/main')
25 files changed, 366 insertions, 48 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index f79a02ba6..92b2e9f08 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -59,9 +59,7 @@ import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.mobs.MobHighlight import at.hannibal2.skyhanni.features.nether.ashfang.* import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper -import at.hannibal2.skyhanni.features.rift.HighlightRiftGuide -import at.hannibal2.skyhanni.features.rift.RiftAPI -import at.hannibal2.skyhanni.features.rift.RiftTimer +import at.hannibal2.skyhanni.features.rift.* import at.hannibal2.skyhanni.features.slayer.* import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper @@ -97,7 +95,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.18", + version = "0.19.Beta.1", ) class SkyHanniMod { @Mod.EventHandler @@ -307,6 +305,10 @@ class SkyHanniMod { loadModule(GhostCounter) loadModule(RiftTimer()) loadModule(HighlightRiftGuide()) + loadModule(CruxWarnings()) + loadModule(RiftLarva()) + loadModule(RiftOdonata()) + loadModule(RiftAgaricusCap()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index d61db3cfd..0058bc2a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -210,7 +210,8 @@ public class Inventory { "§bKuudra Key", "§bSkill Level", "§bCollection Level", - "§bRancher's Boots speed" + "§bRancher's Boots speed", + "§bLarva Hook" } ) public List<Integer> itemNumberAsStackSize = new ArrayList<>(Arrays.asList(3, 9, 11)); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 0477920a2..8cff848fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.core.config.Position; 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.ConfigEditorColour; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class RiftConfig { @@ -32,6 +33,57 @@ public class RiftConfig { @Expose public Position timerPosition = new Position(10, 10, false, true); + } + + @ConfigOption(name = "Crux Warnings", desc = "") + @Accordion + @Expose + public CruxWarnings crux = new CruxWarnings(); + + public static class CruxWarnings { + + @Expose + @ConfigOption(name = "Shy Warning", desc = "Shows a warning when a shy is going to steal your time. " + + "Useful if you play without volume.") + @ConfigEditorBoolean + public boolean shyWarning = true; + } + + @ConfigOption(name = "Larvas", desc = "") + @Accordion + @Expose + public LarvasConfig larvas = new LarvasConfig(); + + public static class LarvasConfig { + + @Expose + @ConfigOption(name = "Highlight", desc = "Highlight §cLarvas on trees §7while holding a §eLarva Hook §7in the hand.") + @ConfigEditorBoolean + public boolean highlight = true; + + @Expose + @ConfigOption(name = "Color", desc = "Color of the Larvas.") + @ConfigEditorColour + public String highlightColor = "0:120:13:49:255"; + + } + + @ConfigOption(name = "Odonatas", desc = "") + @Accordion + @Expose + public OdonataConfig odonata = new OdonataConfig(); + + public static class OdonataConfig { + + @Expose + @ConfigOption(name = "Highlight", desc = "Highlight the small §cOdonatas §7flying around the trees while holding a §eEmpty Odonata Bottle §7in the hand.") + @ConfigEditorBoolean + public boolean highlight = true; + + @Expose + @ConfigOption(name = "Color", desc = "Color of the Odonatas.") + @ConfigEditorColour + public String highlightColor = "0:120:13:49:255"; } @@ -39,4 +91,9 @@ public class RiftConfig { @ConfigOption(name = "Highlight Guide", desc = "Highlight things to do in the Rift Guide.") @ConfigEditorBoolean public boolean highlightGuide = true; + + @Expose + @ConfigOption(name = "Agaricus Cap", desc = "Counts down the time until §eAgaricus Cap (Mushroom) §7changes color from brown to red and is breakable.") + @ConfigEditorBoolean + public boolean agaricusCap = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index b3e27f011..4d0cce395 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -1,9 +1,6 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.HypixelJoinEvent -import at.hannibal2.skyhanni.events.IslandChangeEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -11,7 +8,6 @@ import at.hannibal2.skyhanni.utils.TabListData import net.minecraft.client.Minecraft import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent class HypixelData { @@ -34,7 +30,7 @@ class HypixelData { fun readSkyBlockArea(): String { return ScoreboardData.sidebarLinesFormatted - .firstOrNull { it.startsWith(" §7⏣ ") } + .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } ?.substring(5)?.removeColor() ?: "invalid" } @@ -73,14 +69,9 @@ class HypixelData { } } - var tick = 0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return - - tick++ - if (tick % 5 != 0) return + fun onTick(event: LorenzTickEvent) { + if (!event.isMod(5)) return if (!LorenzUtils.onHypixel) { checkHypixel() diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index f463391e3..20d6f4d5c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -1,13 +1,16 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec +import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S29PacketSoundEffect import net.minecraft.network.play.server.S2APacketParticles import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent class MinecraftData { @@ -49,4 +52,14 @@ class MinecraftData { event.isCanceled = true } } + + private var tick = 0 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + Minecraft.getMinecraft().thePlayer ?: return + tick++ + LorenzTickEvent(tick).postAndCatch() + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 08234bdf1..0b6178399 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -18,7 +18,6 @@ abstract class LorenzEvent : Event() { if (it is NoSuchMethodError) { LorenzUtils.chat("§c[SkyHanni] You need to use a newer version of NotEnoughUpdates (alpha-11 or newer)! If you need help downloading it, go to the skyhanni discord.") } else { - it.printStackTrace() CopyErrorCommand.logError(it, "Caught an ${it::class.simpleName ?: "error"} at ${eventName}: '${it.message}'") } }.getOrDefault(isCanceled) diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt new file mode 100644 index 000000000..ce9c57e97 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +class LorenzTickEvent(private val tick: Int) : LorenzEvent() { + fun isMod(i: Int) = tick % i == 0 +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt index 5e2321e24..e6f646ef1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt @@ -48,8 +48,13 @@ class BazaarDataHolder { fun getData(internalName: String) = bazaarData[internalName] ?: createNewData(internalName) - private fun createNewData(internalName: String): BazaarData { - val displayName = NEUItems.getItemStack(internalName).name!!.removeColor() + private fun createNewData(internalName: String): BazaarData? { + val stack = NEUItems.getItemStackOrNull(internalName) + if (stack == null) { + LorenzUtils.debug("Bazaar data is null: '$internalName'") + return null + } + val displayName = stack.name!!.removeColor() val sellPrice = NEUItems.getPrice(internalName, true) val buyPrice = NEUItems.getPrice(internalName, false) val npcPrice = npcPrices[internalName].let { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index 6682ffa81..7f6ee3670 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -100,6 +100,7 @@ class BurrowWarpHelper { // CRYPT("Crypt", LorenzVec(-190, 74, -88), 25), DA("Dark Auction", LorenzVec(91, 74, 173), 2), MUSEUM("Museum", LorenzVec(-75, 76, 81), 2), + WIZARD("Wizard", LorenzVec(42.5, 122.0, 69.0), 5), ; fun distance(other: LorenzVec): Double = other.distance(location) + extraBlocks diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 4ddfb0cf0..60680897b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.between @@ -159,6 +160,17 @@ class ItemDisplayOverlayFeatures { } } } + + if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(12)) { + if (item.getInternalName() == "LARVA_HOOK") { + for (line in item.getLore()) { + "§7§7You may harvest §6(?<amount>.)/.*".toPattern().matchMatcher(line) { + return group("amount") + } + } + } + } + return "" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt index 96d1bb74f..e64a56ed5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -6,13 +6,12 @@ import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor import at.hannibal2.skyhanni.utils.RenderUtils -import at.hannibal2.skyhanni.utils.SpecialColour import net.minecraft.client.Minecraft import net.minecraft.util.EnumParticleTypes import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color class FireVeilWandParticles { @@ -48,8 +47,7 @@ class FireVeilWandParticles { if (SkyHanniMod.feature.itemAbilities.fireVeilWandDisplay != 1) return if (System.currentTimeMillis() > lastClick + 5_500) return - val color = - Color(SpecialColour.specialToChromaRGB(SkyHanniMod.feature.itemAbilities.fireVeilWandDisplayColor), true) + val color = SkyHanniMod.feature.itemAbilities.fireVeilWandDisplayColor.toChromaColor() RenderUtils.drawCircle(Minecraft.getMinecraft().thePlayer, event.partialTicks, 3.5, color) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt index 721248658..8507deb6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PocketSackInASackDisplay { private val config get() = SkyHanniMod.feature.misc.pocketSackInASack - private val valPattern = "§5§o§7This sack is stitched with (?<number>.*)".toPattern() + private val valPattern = "§5§o§7This sack is stitched with (?<number>.*)§7.".toPattern() @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt index 3b6470660..b31a7f574 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt @@ -29,6 +29,7 @@ class EstimatedWardrobePrice { var index = 3 val toolTip = event.toolTip + if (toolTip.size < 4) return toolTip.add(index++, "") toolTip.add(index++, "§aEstimated Armor Value:") diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt new file mode 100644 index 000000000..39834a6bd --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt @@ -0,0 +1,32 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.TitleUtils +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.test.command.CopyErrorCommand +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class CruxWarnings { + private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!") + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (event.isMod(2)) { + checkForShy() + } + } + + private fun checkForShy() { + try { + if (!(RiftAPI.inRift() || !SkyHanniMod.feature.rift.crux.shyWarning)) return + val list = Minecraft.getMinecraft().theWorld?.getLoadedEntityList() ?: return + if (list.any { it.name in shyNames && it.distanceToPlayer() < 8 }) { + TitleUtils.sendTitle("§eLook away!", 250) + } + } catch (e: Throwable) { + CopyErrorCommand.logError(e, "Check for Shy failed") + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt index a8bf69fba..45b2daeb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt @@ -24,7 +24,7 @@ class HighlightRiftGuide { val inGuide = event.inventoryItems[40]?.getLore()?.let { if (it.size == 1) { - it[0] == "§7To Rift Guide" + it[0].startsWith("§7To Rift Guide") } else false } ?: false if (!inGuide) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt new file mode 100644 index 000000000..c4b452396 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt @@ -0,0 +1,70 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftAgaricusCap { + private val config get() = SkyHanniMod.feature.rift + private var startTime = 0L + private var location: LorenzVec? = null + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + val area = LorenzUtils.skyBlockArea + if (area != "West Village" && area != "Dreadfarm") return + + location = updateLocation() + } + + private fun updateLocation(): LorenzVec? { + if (InventoryUtils.getItemInHand()?.getInternalName() != "FARMING_WAND") return null + val currentLocation = BlockUtils.getBlockLookingAt() ?: return null + + when (currentLocation.getBlockStateAt().toString()) { + "minecraft:brown_mushroom" -> { + return if (location != currentLocation) { + startTime = System.currentTimeMillis() + currentLocation + } else { + if (startTime == -1L) { + startTime = System.currentTimeMillis() + } + location + } + } + + "minecraft:red_mushroom" -> { + if (location == currentLocation) { + startTime = -1L + return location + } + } + } + return null + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + + val location = location?.add(0.0, 0.6, 0.0) ?: return + + if (startTime == -1L) { + event.drawDynamicText(location, "§cClick!", 1.5) + return + } + + val countDown = System.currentTimeMillis() - startTime + val format = TimeUtils.formatDuration(countDown - 1000, showMilliSeconds = true) + event.drawDynamicText(location, "§b$format", 1.5) + } + + fun isEnabled() = RiftAPI.inRift() && config.agaricusCap +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLarva.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLarva.kt new file mode 100644 index 000000000..93df913c8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLarva.kt @@ -0,0 +1,51 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import net.minecraft.client.Minecraft +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftLarva { + private val config get() = SkyHanniMod.feature.rift.larvas + private var hasHookInHand = false + val larvaSkullTexture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTgzYjMwZTlkMTM1YjA1MTkwZWVhMmMzYWM2MWUyYWI1NWEyZDgxZTFhNThkYmIyNjk4M2ExNDA4MjY2NCJ9fX0=" + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + checkHand() + if (!hasHookInHand) return + + if (event.isMod(20)) { + findLarvas() + } + } + + private fun checkHand() { + hasHookInHand = InventoryUtils.getItemInHand()?.getInternalName() == "LARVA_HOOK" + } + + private fun findLarvas() { + + val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return + for (stand in list.filterIsInstance<EntityArmorStand>()) { + if (stand.hasSkullTexture(larvaSkullTexture)) { + RenderLivingEntityHelper.setEntityColor( + stand, + config.highlightColor.toChromaColor().withAlpha(1) + ) { isEnabled() && hasHookInHand } + } + } + } + + fun isEnabled() = RiftAPI.inRift() && config.highlight +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftOdonata.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftOdonata.kt new file mode 100644 index 000000000..7c3fae78b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftOdonata.kt @@ -0,0 +1,51 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import net.minecraft.client.Minecraft +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftOdonata { + private val config get() = SkyHanniMod.feature.rift.odonata + private var hasBottleInHand = false + val odonataSkullTexture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWZkODA2ZGVmZGZkZjU5YjFmMjYwOWM4ZWUzNjQ2NjZkZTY2MTI3YTYyMzQxNWI1NDMwYzkzNThjNjAxZWY3YyJ9fX0=" + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + checkHand() + if (!hasBottleInHand) return + + if (event.isMod(20)) { + findOdonatas() + } + } + + private fun checkHand() { + hasBottleInHand = InventoryUtils.getItemInHand()?.getInternalName() == "EMPTY_ODONATA_BOTTLE" + } + + private fun findOdonatas() { + + val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return + for (stand in list.filterIsInstance<EntityArmorStand>()) { + if (stand.hasSkullTexture(odonataSkullTexture)) { + RenderLivingEntityHelper.setEntityColor( + stand, + config.highlightColor.toChromaColor().withAlpha(1) + ) { isEnabled() && hasBottleInHand } + } + } + } + + fun isEnabled() = RiftAPI.inRift() && config.highlight +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt index 6fe16c981..3901d8370 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -21,6 +21,8 @@ class RiftTimer { @SubscribeEvent fun onJoinWorld(ignored: WorldEvent.Load) { display = emptyList() + maxTime = 0 + latestTime = 0 } @SubscribeEvent @@ -30,7 +32,7 @@ class RiftTimer { val message = event.message " §r§7You have §r§a(?<time>.*)ф §r§7left before the rift collapses!".toPattern().matchMatcher(message) { val time = group("time") - maxTime = formatTime(time) + maxTime = getTime(time) } } @@ -43,23 +45,27 @@ class RiftTimer { "§(?<color>[a7])(?<time>.*)ф Left.*".toPattern().matchMatcher(entry) { val color = group("color") if (color == "7") { - display = emptyList() + val currentTime = getTime(group("time")) + if (currentTime > maxTime) { + maxTime = currentTime + update(currentTime) + } return } - val time = group("time") - val currentTime = formatTime(time) - update(currentTime) + update(getTime(group("time"))) } } } - private fun formatTime(time: String) = TimeUtils.getMillis(time.replace("m", "m ")) + private fun getTime(time: String) = TimeUtils.getMillis(time.replace("m", "m ")) private fun update(currentTime: Long) { if (currentTime == latestTime) return val diff = (currentTime - latestTime) + 1000 latestTime = currentTime - addDiff(diff) + if (latestTime != maxTime) { + addDiff(diff) + } val currentFormat = TimeUtils.formatDuration(currentTime) val percentage = LorenzUtils.formatPercentage(currentTime.toDouble() / maxTime) diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt index ccaeee6ef..112768637 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -36,15 +36,17 @@ object CopyErrorCommand { } ?: "§c[SkyHanni] Error id not found!") } - fun logError(error: Throwable, message: String) { - Minecraft.getMinecraft().thePlayer ?: throw Error(message, error) + fun logError(throwable: Throwable, message: String) { + val error = Error(message, throwable) + Minecraft.getMinecraft().thePlayer ?: throw error + error.printStackTrace() - val pair = error.stackTrace[0].let { it.fileName to it.lineNumber } + val pair = throwable.stackTrace[0].let { it.fileName to it.lineNumber } if (cache.getIfPresent(pair) != null) return cache.put(pair, Unit) - val fullStackTrace = error.getExactStackTrace(true).joinToString("\n") - val stackTrace = error.getExactStackTrace(false).joinToString("\n").removeSpam() + val fullStackTrace = throwable.getExactStackTrace(true).joinToString("\n") + val stackTrace = throwable.getExactStackTrace(false).joinToString("\n").removeSpam() val randomId = UUID.randomUUID().toString() errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $message\n \n$stackTrace\n```" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt index e16df26e9..a35d0de06 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt @@ -39,4 +39,18 @@ object BlockUtils { return false } + + fun rayTrace(start: LorenzVec, direction: LorenzVec, distance: Double = 50.0): LorenzVec? { + val help = direction.normalize().multiply(distance) + val target = start.add(help) + val result = Minecraft.getMinecraft().theWorld.rayTraceBlocks(start.toVec3(), target.toVec3()) + + return result?.blockPos?.toLorenzVec() + } + + fun getBlockLookingAt(duration: Double = 10.0) = rayTrace( + LocationUtils.playerEyeLocation(), + Minecraft.getMinecraft().thePlayer.lookVec.toLorenzVec(), + duration + ) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt index efcc8e493..510f631b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity object LocationUtils { @@ -12,6 +13,8 @@ object LocationUtils { fun LorenzVec.distanceToPlayer() = distance(playerLocation()) + fun Entity.distanceToPlayer() = getLorenzVec().distance(playerLocation()) + fun playerEyeLocation(): LorenzVec { val player = Minecraft.getMinecraft().thePlayer val vec = player.getLorenzVec() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index bc50ea0e6..c1309d573 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -20,6 +20,7 @@ import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText import org.lwjgl.input.Keyboard +import java.awt.Color import java.text.DecimalFormat import java.text.NumberFormat import java.text.SimpleDateFormat @@ -381,4 +382,7 @@ object LorenzUtils { @Suppress("UNCHECKED_CAST") this[item] = d as N } + + /** transfer string colors from the config to java.awt.Color */ + fun String.toChromaColor() = Color(SpecialColour.specialToChromaRGB(this), true) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 5bce2d762..4b716964f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -64,6 +64,8 @@ data class LorenzVec( fun subtract(other: LorenzVec) = LorenzVec(x - other.x, y - other.y, z - other.z) + fun normalize() = length().let { LorenzVec(x / it, y / it, z / it) } + fun printWithAccuracy(accuracy: Int): String { val x = (round(x * accuracy) / accuracy) val y = (round(y * accuracy) / accuracy) @@ -89,6 +91,8 @@ data class LorenzVec( fun equalsIgnoreY(other: LorenzVec) = x == other.x && z == other.z + fun equals(other: LorenzVec) = x == other.x && y == other.y && z == other.z + fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals)) companion object { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 07e1c9318..dc98f3a0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -134,15 +134,11 @@ object NEUItems { .withKnownInternalName(internalName) .resolveToItemStack()?.copy() - fun getItemStack(internalName: String): ItemStack { - val stack = getItemStackOrNull(internalName) - if (stack == null) { - val error = "ItemResolutionQuery returns null for internalName '$internalName'" - LorenzUtils.error(error) - throw RuntimeException(error) - } - return stack - } + fun getItemStack(internalName: String): ItemStack = getItemStackOrNull(internalName) + ?: throw IllegalStateException( + "Could not find the Item '$internalName' in NEU Repo", + Error("ItemResolutionQuery returns null for internalName '$internalName'") + ) fun isVanillaItem(item: ItemStack) = manager.auctionManager.isVanillaItem(item.getInternalName()) |