Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Optimal Angles Overlay for Squeaky Mousemat #2999

Open
wants to merge 26 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd4f122
Add Optimal Angles Overlay for Squeaky Mousemat (like Rancher Boots O…
Nov 27, 2024
3e61b03
Merge branch 'beta' into feature_garden_angles
CalMWolfs Dec 4, 2024
5c8632a
Merge branch 'beta' into feature_garden_angles
CalMWolfs Dec 6, 2024
0a63ca0
fix events merge
CalMWolfs Dec 6, 2024
efcf5ac
Merge branch 'beta' into feature_garden_angles
CalMWolfs Dec 10, 2024
845ff5d
Add SignUtils and relocate suitable affected functions
nikijul007 Dec 12, 2024
da305b0
Merge branch 'beta' into feature_garden_angles
CalMWolfs Dec 14, 2024
8fe4ac6
Merge branch 'refs/heads/beta' into fork/nikijul007/feature_garden_an…
CalMWolfs Jan 1, 2025
ec0366b
fix merge
CalMWolfs Jan 1, 2025
43de886
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 8, 2025
c56cca4
Rename .java to .kt
CalMWolfs Jan 9, 2025
fed8b8d
make kotlin, dictionary
CalMWolfs Jan 9, 2025
8140fd1
Merge branch 'refs/heads/beta' into fork/nikijul007/feature_garden_an…
CalMWolfs Jan 9, 2025
29c913b
detekt
CalMWolfs Jan 9, 2025
49f2d62
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 10, 2025
d0c759e
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 12, 2025
1934772
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 16, 2025
df06c91
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 16, 2025
02ad94a
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 22, 2025
de1c1b9
Merge branch 'beta' into feature_garden_angles
CalMWolfs Jan 24, 2025
fe2799e
Merge branch 'refs/heads/beta' into fork/nikijul007/feature_garden_an…
hannibal002 Jan 25, 2025
c273058
Fixed merge conflicts
hannibal002 Jan 25, 2025
dc93775
Merge branch 'refs/heads/beta' into fork/nikijul007/feature_garden_an…
CalMWolfs Jan 25, 2025
6489b39
Merge branch 'beta' into feature_garden_angles
CalMWolfs Feb 9, 2025
651b165
Merge branch 'refs/heads/beta' into fork/nikijul007/feature_garden_an…
hannibal002 Feb 11, 2025
f0b0dda
code cleanup
hannibal002 Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/dictionaries/default_user.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import at.hannibal2.skyhanni.config.features.garden.composter.ComposterConfig;
import at.hannibal2.skyhanni.config.features.garden.cropmilestones.CropMilestonesConfig;
import at.hannibal2.skyhanni.config.features.garden.laneswitch.FarmingLaneConfig;
import at.hannibal2.skyhanni.config.features.garden.optimalAngles.OptimalAnglesConfig;
import at.hannibal2.skyhanni.config.features.garden.optimalspeed.OptimalSpeedConfig;
import at.hannibal2.skyhanni.config.features.garden.pests.PestsConfig;
import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig;
Expand Down Expand Up @@ -46,6 +47,10 @@ public class GardenConfig {
@Category(name = "Optimal Speed", desc = "Optimal Speed Settings")
public OptimalSpeedConfig optimalSpeeds = new OptimalSpeedConfig();

@Expose
@Category(name = "Optimal Angles", desc = "Optimal Angles Settings")
public OptimalAnglesConfig optimalAngles = new OptimalAnglesConfig();

@Expose
@ConfigOption(name = "Farming Lane", desc = "")
@Accordion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package at.hannibal2.skyhanni.config.features.garden.optimalAngles

import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
import io.github.notenoughupdates.moulconfig.observer.Property

class CustomAnglesConfig {

// Cactus
@Expose
@ConfigOption(name = "Cactus Yaw", desc = "Set Yaw for cactus farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var cactusYaw: Property<Float> = Property.of(-90f)

@Expose
@ConfigOption(name = "Cactus Pitch", desc = "Set Pitch for cactus farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var cactusPitch: Property<Float> = Property.of(0f)

// Carrot
@Expose
@ConfigOption(name = "Carrot Yaw", desc = "Set Yaw for carrot farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var carrotYaw: Property<Float> = Property.of(-90f)

@Expose
@ConfigOption(name = "Carrot Pitch", desc = "Set Pitch for carrot farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var carrotPitch: Property<Float> = Property.of(2.8f)

// Cocoa Beans
@Expose
@ConfigOption(name = "Cocoa Beans Yaw", desc = "Set Yaw for cocoa bean farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var cocoaBeansYaw: Property<Float> = Property.of(180f)

@Expose
@ConfigOption(name = "Cocoa Beans Pitch", desc = "Set Pitch for cocoa bean farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var cocoaBeansPitch: Property<Float> = Property.of(-45f)

// Melon
@Expose
@ConfigOption(name = "Melon Yaw", desc = "Set Yaw for melon farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var melonYaw: Property<Float> = Property.of(90f)

@Expose
@ConfigOption(name = "Melon Pitch", desc = "Set Pitch for melon farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var melonPitch: Property<Float> = Property.of(-58.5f)

// Mushroom
@Expose
@ConfigOption(name = "Mushroom Yaw", desc = "Set Yaw for mushroom farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var mushroomYaw: Property<Float> = Property.of(116.5f)

@Expose
@ConfigOption(name = "Mushroom Pitch", desc = "Set Pitch for mushroom farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var mushroomPitch: Property<Float> = Property.of(0f)

// Nether Wart
@Expose
@ConfigOption(name = "Nether Wart Yaw", desc = "Set Yaw for nether wart farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var netherWartYaw: Property<Float> = Property.of(90f)

@Expose
@ConfigOption(name = "Nether Wart Pitch", desc = "Set Pitch for nether wart farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var netherWartPitch: Property<Float> = Property.of(0f)

// Potato
@Expose
@ConfigOption(name = "Potato Yaw", desc = "Set Yaw for potato farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var potatoYaw: Property<Float> = Property.of(-90f)

@Expose
@ConfigOption(name = "Potato Pitch", desc = "Set Pitch for potato farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var potatoPitch: Property<Float> = Property.of(2.8f)

// Pumpkin
@Expose
@ConfigOption(name = "Pumpkin Yaw", desc = "Set Yaw for pumpkin farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var pumpkinYaw: Property<Float> = Property.of(90f)

@Expose
@ConfigOption(name = "Pumpkin Pitch", desc = "Set Pitch for pumpkin farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var pumpkinPitch: Property<Float> = Property.of(-58.5f)

// Sugar Cane
@Expose
@ConfigOption(name = "Sugar Cane Yaw", desc = "Set Yaw for sugar cane farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var sugarCaneYaw: Property<Float> = Property.of(-135f)

@Expose
@ConfigOption(name = "Sugar Cane Pitch", desc = "Set Pitch for sugar cane farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var sugarCanePitch: Property<Float> = Property.of(0f)

// Wheat
@Expose
@ConfigOption(name = "Wheat Yaw", desc = "Set Yaw for wheat farming.")
@ConfigEditorSlider(minValue = -180f, maxValue = 180f, minStep = 0.1f)
var wheatYaw: Property<Float> = Property.of(90f)

@Expose
@ConfigOption(name = "Wheat Pitch", desc = "Set Pitch for wheat farming.")
@ConfigEditorSlider(minValue = -90f, maxValue = 90f, minStep = 0.1f)
var wheatPitch: Property<Float> = Property.of(0f)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package at.hannibal2.skyhanni.config.features.garden.optimalAngles

import at.hannibal2.skyhanni.config.FeatureToggle
import at.hannibal2.skyhanni.config.core.config.Position
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.annotations.Accordion
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption

class OptimalAnglesConfig {
Copy link
Owner

@hannibal002 hannibal002 Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the squeaky mousemat options into a new class that is part of this class here

@Expose
@ConfigOption(
name = "Squeaky Mousemat",
desc = "Set the optimal angles (pitch & yaw) in the Squeaky Mousemat overlay by clicking on the presets."
)
@ConfigEditorBoolean
@FeatureToggle
var signEnabled: Boolean = true

@Expose
@ConfigOption(name = "Compact GUI", desc = "Compact the Squeaky Mousemat GUI only showing crop icons.")
@ConfigEditorBoolean
var compactMousematGui: Boolean = false

@Expose
@ConfigLink(owner = OptimalAnglesConfig::class, field = "signEnabled")
var signPosition: Position = Position(20, -195, false, true)

@Expose
@ConfigOption(name = "Custom Speed", desc = "Change the exact speed for every single crop.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the name/desc

@Accordion
var customAngles: CustomAnglesConfig = CustomAnglesConfig()
}
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import at.hannibal2.skyhanni.events.minecraft.SkyHanniTickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign
import at.hannibal2.skyhanni.utils.NeuItems
import at.hannibal2.skyhanni.utils.SignUtils.isGardenSign
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.TimeLimitedCache
Expand Down Expand Up @@ -52,7 +52,7 @@ object GuiEditManager {
if (isInNeuPv) return
guiScreen?.let {
if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return
if (it is GuiEditSign && !it.isRancherSign()) return
if (it is GuiEditSign && !it.isGardenSign()) return
}

if (lastHotkeyPressed.passedSince() < 500.milliseconds) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SignUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
Expand Down Expand Up @@ -170,7 +171,7 @@ object CityProjectFeatures {
"$name §ex${amount.addSeparators()}",
{
if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
LorenzUtils.setTextIntoSign("$amount")
SignUtils.setTextIntoSign("$amount")
} else {
BazaarApi.searchForBazaarItem(name, amount)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package at.hannibal2.skyhanni.features.garden

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SignUtils
import at.hannibal2.skyhanni.utils.SignUtils.isMousematSign
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.notenoughupdates.moulconfig.observer.Property
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object GardenOptimalAngles {

private val config get() = GardenApi.config.optimalAngles

private val configCustomAngles get() = config.customAngles
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is only used once it can be inlined


private var cropInHand: CropType? = null
private var lastCrop: CropType? = null
private var display = listOf<Renderable>()

@SubscribeEvent
fun onGuiOpen(event: GuiOpenEvent) {
if (!isSqueakyMousematEnabled()) return
val gui = event.gui as? GuiEditSign ?: return
if (!gui.isMousematSign()) return

val crops = CropType.entries.map { it to it.getAngles() }

display = if (config.compactMousematGui) {
crops.groupBy({ it.second }, { it.first }).map { (angles, crops) ->
val color = if (lastCrop in crops) LorenzColor.GOLD else LorenzColor.WHITE
val renderable = Renderable.horizontalContainer(
listOf(
Renderable.horizontalContainer(crops.map { Renderable.itemStack(it.icon) }),
Renderable.string("${color.getChatColor()} - ${angles.first}/${angles.second}"),
),
spacing = 2,
)
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { setAngles(angles) })
}
} else {
crops.map { (crop, angles) ->
val color = if (lastCrop == crop) LorenzColor.GOLD else LorenzColor.WHITE
val renderable = Renderable.horizontalContainer(
listOf(
Renderable.itemStack(crop.icon),
Renderable.string("${color.getChatColor()}${crop.cropName} - ${angles.first}/${angles.second}"),
),
spacing = 2,
)
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { setAngles(angles) })
}
}
}

@SubscribeEvent
fun onGuiRender(event: DrawScreenEvent.Post) {
if (!isSqueakyMousematEnabled()) return
val gui = event.gui as? GuiEditSign ?: return
if (!gui.isMousematSign()) return
config.signPosition.renderRenderables(
display,
posLabel = "Optimal Angles Mousemat Overlay",
)
}

@HandleEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
cropInHand = event.crop
event.crop?.let { lastCrop = it }
}

private fun setAngles(angles: Pair<Float, Float>) {
SignUtils.setTextIntoSign("${angles.first}", 0)
SignUtils.setTextIntoSign("${angles.second}", 3)
}

private fun CropType.getAngles() = getConfig().let { Pair(it.first.get(), it.second.get()) }

private fun CropType.getConfig(): Pair<Property<Float>, Property<Float>> = with(configCustomAngles) {
when (this@getConfig) {
CropType.CACTUS -> Pair(cactusYaw, cactusPitch)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of Pair(a, b) you can use a to b

CropType.WHEAT -> Pair(wheatYaw, wheatPitch)
CropType.CARROT -> Pair(carrotYaw, carrotPitch)
CropType.POTATO -> Pair(potatoYaw, potatoPitch)
CropType.NETHER_WART -> Pair(netherWartYaw, netherWartPitch)
CropType.PUMPKIN -> Pair(pumpkinYaw, pumpkinPitch)
CropType.MELON -> Pair(melonYaw, melonPitch)
CropType.COCOA_BEANS -> Pair(cocoaBeansYaw, cocoaBeansPitch)
CropType.SUGAR_CANE -> Pair(sugarCaneYaw, sugarCanePitch)
CropType.MUSHROOM -> Pair(mushroomYaw, mushroomPitch)
}
}

private fun isSqueakyMousematEnabled() = GardenApi.inGarden() && config.signEnabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign
import at.hannibal2.skyhanni.utils.NeuInternalName.Companion.toInternalName
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SignUtils
import at.hannibal2.skyhanni.utils.SignUtils.isRancherSign
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.notenoughupdates.moulconfig.observer.Property
Expand Down Expand Up @@ -94,7 +95,7 @@ object GardenOptimalSpeed {
),
spacing = 2,
)
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { LorenzUtils.setTextIntoSign("$speed") })
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { SignUtils.setTextIntoSign("$speed") })
}
} else {
crops.map { (crop, speed) ->
Expand All @@ -106,7 +107,7 @@ object GardenOptimalSpeed {
),
spacing = 2,
)
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { LorenzUtils.setTextIntoSign("$speed") })
Renderable.link(renderable, underlineColor = color.toColor(), onClick = { SignUtils.setTextIntoSign("$speed") })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import at.hannibal2.skyhanni.utils.PrimitiveIngredient.Companion.toPrimitiveItem
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SignUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils.format
Expand Down Expand Up @@ -224,7 +225,7 @@ object GardenVisitorFeatures {
onClick = {
if (!GardenApi.inGarden() || NeuItems.neuHasFocus()) return@clickAndHover
if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
LorenzUtils.setTextIntoSign("$amount")
SignUtils.setTextIntoSign("$amount")
} else {
internalName.buy(amount)
}
Expand Down Expand Up @@ -290,7 +291,7 @@ object GardenVisitorFeatures {
"§aCraftable!",
{
if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
LorenzUtils.setTextIntoSign("$leftToCraft")
SignUtils.setTextIntoSign("$leftToCraft")
} else {
HypixelCommands.viewRecipe(internalName.asString())
}
Expand Down
Loading
Loading