aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-21 00:24:33 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-21 00:24:53 +0200
commit43575ec3781bc617975f853df85294575875cfab (patch)
treed48742b9f8ffc883a79c26789763483293a94f0d /src/main
parent5ecf7f0e14f148f5c14952d98969f4033060bb88 (diff)
downloadskyhanni-43575ec3781bc617975f853df85294575875cfab.tar.gz
skyhanni-43575ec3781bc617975f853df85294575875cfab.tar.bz2
skyhanni-43575ec3781bc617975f853df85294575875cfab.zip
Control + click in composter overlay opens bazaar search and copies required amount to clipboard.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt14
6 files changed, 28 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
index 3dead0a26..86e4f790f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize
+import at.hannibal2.skyhanni.utils.LorenzUtils
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
@@ -156,8 +157,7 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde
val position = positions[clickedPos]
if (position.clicked) return
- val shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
- val dist = if (shiftHeld) 10 else 1
+ val dist = if (LorenzUtils.isShiftKeyDown()) 10 else 1
val elementWidth = position.getDummySize(true).x
val elementHeight = position.getDummySize(true).y
if (keyCode == Keyboard.KEY_DOWN) {
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 a75060476..6682ffa81 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
@@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
import at.hannibal2.skyhanni.utils.LorenzVec
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent
import org.lwjgl.input.Keyboard
@@ -29,8 +28,7 @@ class BurrowWarpHelper {
currentWarp?.let {
if (System.currentTimeMillis() > lastWarpTime + 5_000) {
lastWarpTime = System.currentTimeMillis()
- val thePlayer = Minecraft.getMinecraft().thePlayer
- thePlayer.sendChatMessage("/warp " + currentWarp?.name)
+ LorenzUtils.sendCommandToServer("warp " + currentWarp?.name)
lastWarp = currentWarp
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index adbe90245..dc88c14df 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -5,18 +5,15 @@ import at.hannibal2.skyhanni.data.model.ComposterUpgrade
import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
-import at.hannibal2.skyhanni.utils.NEUItems
-import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.notenoughupdates.NotEnoughUpdates
@@ -368,9 +365,15 @@ class ComposterOverlay {
val format = NumberUtil.format(totalPrice)
val selected =
if (internalName == currentOrganicMatterItem || internalName == currentFuelItem) "§n" else ""
- val name = itemName.substring(0, 2) + selected + itemName.removeColor()
+ val rawItemName = itemName.removeColor()
+ val name = itemName.substring(0, 2) + selected + rawItemName
list.add(Renderable.link("$name§r §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") {
onClick(internalName)
+ if (LorenzUtils.isControlKeyDown()) {
+ inInventory = false
+ LorenzUtils.sendCommandToServer("bz $rawItemName")
+ OSUtils.copyToClipboard("${itemsNeeded.toInt()}")
+ }
})
bigList.add(list)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt
index 2ef7e5378..88a4a713c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt
@@ -4,11 +4,11 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.Utils
-import net.minecraft.client.Minecraft
import net.minecraft.client.player.inventory.ContainerLocalMenu
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -45,8 +45,7 @@ class GardenDeskInSBMenu {
fun onStackClick(event: SlotClickEvent) {
if (showItem && event.slotId == 10) {
event.isCanceled = true
- val thePlayer = Minecraft.getMinecraft().thePlayer
- thePlayer.sendChatMessage("/desk")
+ LorenzUtils.sendCommandToServer("desk")
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index c339a5425..6fb6887c3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -142,8 +142,7 @@ class GardenVisitorFeatures {
if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
LorenzUtils.setTextIntoSign("$amount")
} else if (!InventoryUtils.inStorage()) {
- val thePlayer = Minecraft.getMinecraft().thePlayer
- thePlayer.sendChatMessage("/bz ${name.removeColor()}");
+ LorenzUtils.sendCommandToServer("bz ${name.removeColor()}")
OSUtils.copyToClipboard("$amount")
}
}) { GardenAPI.inGarden() && !InventoryUtils.inStorage() })
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c84710fe0..526d2a3c7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -15,6 +15,7 @@ import net.minecraft.entity.SharedMonsterAttributes
import net.minecraft.event.ClickEvent
import net.minecraft.event.HoverEvent
import net.minecraft.util.ChatComponentText
+import org.lwjgl.input.Keyboard
import java.text.DecimalFormat
import java.text.NumberFormat
import java.text.SimpleDateFormat
@@ -224,4 +225,17 @@ object LorenzUtils {
return this
}
+ private var lastCommandSent = 0L
+
+ fun sendCommandToServer(command: String) {
+ if (System.currentTimeMillis() > lastCommandSent + 2_000) {
+ lastCommandSent = System.currentTimeMillis()
+ val thePlayer = Minecraft.getMinecraft().thePlayer
+ thePlayer.sendChatMessage("/$command")
+ }
+ }
+
+ fun isShiftKeyDown() = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
+
+ fun isControlKeyDown() = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
} \ No newline at end of file