diff options
Diffstat (limited to 'src/main')
8 files changed, 109 insertions, 48 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 5fde02e86..52f696542 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -115,6 +115,7 @@ public class SkyHanniMod { loadModule(new SkillExperience()); loadModule(new InventoryData()); loadModule(new TabListData()); + loadModule(new RenderGuiData()); //features loadModule(new BazaarOrderHelper()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 42c64290d..59e14e60d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -142,13 +142,13 @@ public class Features extends Config { return; } - if (runnableId.equals("visitorHelper")) { - editOverlay(activeConfigCategory, 200, 16, garden.visitorHelperPos); + if (runnableId.equals("visitorNeeds")) { + editOverlay(activeConfigCategory, 200, 16, garden.visitorNeedsPos); return; } - if (runnableId.equals("visitorHelperTimer")) { - editOverlay(activeConfigCategory, 200, 16, garden.visitorHelperTimerPos); + if (runnableId.equals("visitorTimer")) { + editOverlay(activeConfigCategory, 200, 16, garden.visitorTimerPos); return; } } 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 45624e7f4..967c2487b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -24,67 +24,79 @@ public class Garden { public Position skyMartCopperPricePos = new Position(44, -108, false, true); @Expose - @ConfigOption(name = "Visitor Helper", desc = "") + @ConfigOption(name = "Visitor", desc = "") @ConfigEditorAccordion(id = 1) - public boolean visitorHelper = false; + public boolean visitor = false; @Expose @ConfigOption(name = "Visitor Timer", desc = "") @ConfigAccordionId(id = 1) @ConfigEditorAccordion(id = 2) - public boolean visitorHelperTimer = false; + public boolean visitorTimer = false; @Expose @ConfigOption(name = "Visitor Timer", desc = "Timer when the next visitor will appear," + "and a number how many visitors are already waiting.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) - public boolean visitorHelperTimerEnabled = true; + public boolean visitorTimerEnabled = true; @Expose @ConfigOption(name = "Visitor Timer Position", desc = "") - @ConfigEditorButton(runnableId = "visitorHelperTimer", buttonText = "Edit") + @ConfigEditorButton(runnableId = "visitorTimer", buttonText = "Edit") @ConfigAccordionId(id = 2) - public Position visitorHelperTimerPos = new Position(0, 0, false, true); + public Position visitorTimerPos = new Position(0, 0, false, true); @Expose - @ConfigOption(name = "Visitor Display", desc = "Show all items needed for the visitors.") - @ConfigEditorBoolean + @ConfigOption(name = "Visitor Items Needed", desc = "") @ConfigAccordionId(id = 1) - public boolean visitorHelperDisplay = true; + @ConfigEditorAccordion(id = 3) + public boolean visitorNeeds = false; @Expose - @ConfigOption(name = "Visitor Helper Position", desc = "") - @ConfigEditorButton(runnableId = "visitorHelper", buttonText = "Edit") - @ConfigAccordionId(id = 1) - public Position visitorHelperPos = new Position(0, 0, false, true); + @ConfigOption(name = "Items Needed", desc = "Show all items needed for the visitors.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean visitorNeedsDisplay = true; + + @Expose + @ConfigOption(name = "Items Needed Position", desc = "") + @ConfigEditorButton(runnableId = "visitorNeeds", buttonText = "Edit") + @ConfigAccordionId(id = 3) + public Position visitorNeedsPos = new Position(0, 0, false, true); + + @Expose + @ConfigOption(name = "Only when Close", desc = "Only show the needed items when close to the visitors.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean visitorNeedsOnlyWhenClose = false; @Expose @ConfigOption(name = "Highlight Ready", desc = "Highlight the visitor when the required items are in the inventory.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean visitorHelperHighlightReady = true; + public boolean visitorHighlightReady = true; @Expose @ConfigOption(name = "Show Price", desc = "Show the bazaar price of the items required for the visitors.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean visitorHelperShowPrice = true; + public boolean visitorShowPrice = true; @Expose @ConfigOption(name = "Numbers", desc = "") - @ConfigEditorAccordion(id = 3) + @ConfigEditorAccordion(id = 4) public boolean numbers = false; @Expose - @ConfigOption(name = "Crop Milestone", desc = "Show the number of the crop milestone in the inventory.") + @ConfigOption(name = "Crop Milestone", desc = "Show the number of crop milestones in the inventory.") @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean cropMilestoneNumber = true; + @ConfigAccordionId(id = 4) + public boolean numberCropMilestone = true; @Expose @ConfigOption(name = "Crop Upgrades", desc = "Show the number of upgrades in the crop upgrades inventory.") @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean cropUpgradesNumber = true; + @ConfigAccordionId(id = 4) + public boolean numberCropUpgrades = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt new file mode 100644 index 000000000..b9a217fbc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.GuiRenderEvent +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RenderGuiData { + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + GuiRenderEvent(GuiRenderEvent.RenderType.IN_WORLD).postAndCatch() + } + + @SubscribeEvent + fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { + GuiRenderEvent(GuiRenderEvent.RenderType.INVENTORY_BACKGROUND).postAndCatch() + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt new file mode 100644 index 000000000..9b7cebced --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderEvent.kt @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.events + +class GuiRenderEvent(val type: RenderType): LorenzEvent() { + + enum class RenderType { + INVENTORY_BACKGROUND, + IN_WORLD, + ; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt index 95b9b1e9e..3fe03fe3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt @@ -20,7 +20,7 @@ class GardenInventoryNumbers { if (!isEnabled()) return if (InventoryUtils.openInventoryName() == "Crop Milestones") { - if (!SkyHanniMod.feature.garden.cropMilestoneNumber) return + if (!SkyHanniMod.feature.garden.numberCropMilestone) return event.stack.getLore() .map { patternTierProgress.matcher(it) } @@ -30,7 +30,7 @@ class GardenInventoryNumbers { } if (InventoryUtils.openInventoryName() == "Crop Upgrades") { - if (!SkyHanniMod.feature.garden.cropUpgradesNumber) return + if (!SkyHanniMod.feature.garden.numberCropUpgrades) return event.stack.getLore() .map { patternUpgradeTier.matcher(it) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 5e3b0c3f0..06dbd10ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.withAlpha @@ -16,12 +17,10 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraft.network.play.server.S13PacketDestroyEntities -import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class GardenVisitorFeatures { @@ -33,8 +32,8 @@ class GardenVisitorFeatures { @SubscribeEvent fun onChatPacket(event: InventoryOpenEvent) { if (!isEnabled()) return - if (!SkyHanniMod.feature.garden.visitorHelperDisplay && - !SkyHanniMod.feature.garden.visitorHelperHighlightReady + if (!SkyHanniMod.feature.garden.visitorNeedsDisplay && + !SkyHanniMod.feature.garden.visitorHighlightReady ) return val npcItem = event.inventory.items[13] ?: return @@ -79,7 +78,7 @@ class GardenVisitorFeatures { } if (requiredItems.isEmpty()) return - display.add("Visitors need:") + display.add("Visitor Items Needed:") for ((name, amount) in requiredItems) { display.add(" -$name §8x$amount") } @@ -91,7 +90,7 @@ class GardenVisitorFeatures { fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return if (!nearby) return - if (!SkyHanniMod.feature.garden.visitorHelperShowPrice) return + if (!SkyHanniMod.feature.garden.visitorShowPrice) return val name = event.itemStack.name ?: return if (name != "§aAccept Offer") return @@ -104,8 +103,8 @@ class GardenVisitorFeatures { val line = l.substring(4) if (line == "") { if (amountDifferentItems > 1) { - val format = NumberUtil.format(totalPrice) - list[1] = list[1] + "$line §f(§6Total §6$format§f)" + val format = NumberUtil.format(totalPrice) + list[1] = list[1] + "$line §f(§6Total §6$format§f)" } break } @@ -130,15 +129,31 @@ class GardenVisitorFeatures { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!isEnabled()) return - if (!SkyHanniMod.feature.garden.visitorHelperDisplay && - !SkyHanniMod.feature.garden.visitorHelperHighlightReady && - !SkyHanniMod.feature.garden.visitorHelperShowPrice + if (!SkyHanniMod.feature.garden.visitorNeedsDisplay && + !SkyHanniMod.feature.garden.visitorHighlightReady && + !SkyHanniMod.feature.garden.visitorShowPrice ) return if (tick++ % 60 != 0) return - nearby = LocationUtils.playerLocation().distance(LorenzVec(8.4, 72.0, -14.1)) < 10 + val defaultVanillaSkin = LorenzVec(8.4, 72.0, -14.1) + val castleSkin = LorenzVec(-5, 75, 18) + val bambooSkin = LorenzVec(-12, 72, -25) + val hiveSkin = LorenzVec(-17, 71, -19) + val cubeSkin = LorenzVec(-17, 71, -19) - if (nearby && SkyHanniMod.feature.garden.visitorHelperHighlightReady) { + // TODO Only check current one, ignore others. + val list = mutableListOf<LorenzVec>() + list.add(defaultVanillaSkin) + list.add(castleSkin) + list.add(bambooSkin) + list.add(hiveSkin) + list.add(cubeSkin) + + val playerLocation = LocationUtils.playerLocation() + nearby = list.map { playerLocation.distance(it) < 15 }.any { it } + + + if (nearby && SkyHanniMod.feature.garden.visitorHighlightReady) { checkVisitorsReady() } } @@ -160,7 +175,7 @@ class GardenVisitorFeatures { if (entity is EntityLivingBase) { val color = LorenzColor.GREEN.toColor().withAlpha(120) RenderLivingEntityHelper.setEntityColor(entity, color) - { SkyHanniMod.feature.garden.visitorHelperHighlightReady } + { SkyHanniMod.feature.garden.visitorHighlightReady } } } } @@ -181,6 +196,7 @@ class GardenVisitorFeatures { } } + // TODO make event @SubscribeEvent fun onSendEvent(event: PacketEvent.SendEvent) { val packet = event.packet @@ -194,13 +210,15 @@ class GardenVisitorFeatures { } @SubscribeEvent - fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { - if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - if (!SkyHanniMod.feature.garden.visitorHelperDisplay) return - if (!nearby) return + if (!SkyHanniMod.feature.garden.visitorNeedsDisplay) return + + if (SkyHanniMod.feature.garden.visitorNeedsOnlyWhenClose) { + if (!nearby) return + } - SkyHanniMod.feature.garden.visitorHelperPos.renderStrings(display) + SkyHanniMod.feature.garden.visitorNeedsPos.renderStrings(display) } class Visitor(val entityId: Int, val items: MutableMap<String, Int> = mutableMapOf()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt index 3125cfc36..d8bbe2d6f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt @@ -54,11 +54,11 @@ class GardenVisitorTimer { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return - SkyHanniMod.feature.garden.visitorHelperTimerPos.renderString(render) + SkyHanniMod.feature.garden.visitorTimerPos.renderString(render) } private fun isEnabled() = LorenzUtils.inSkyBlock && - SkyHanniMod.feature.garden.visitorHelperTimerEnabled && + SkyHanniMod.feature.garden.visitorTimerEnabled && LorenzUtils.skyBlockIsland == IslandType.GARDEN }
\ No newline at end of file |