summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-06-23 20:18:45 +0200
committerGitHub <noreply@github.com>2024-06-23 20:18:45 +0200
commit739a48d4679ce05c1f555a04fcdaa4e509d59d5d (patch)
treeb7b21a3548f441db11262f1e90267c9ec4666696 /src/main/java/at/hannibal2/skyhanni/test
parent6eb085f4e2ba69e98934ffa9489c8679ba23d244 (diff)
downloadskyhanni-739a48d4679ce05c1f555a04fcdaa4e509d59d5d.tar.gz
skyhanni-739a48d4679ce05c1f555a04fcdaa4e509d59d5d.tar.bz2
skyhanni-739a48d4679ce05c1f555a04fcdaa4e509d59d5d.zip
Backend: Drag and Drop for Renderables (#1864)
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index f3fe16222..e718593f3 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -56,8 +56,11 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.renderables.DragNDrop
+import at.hannibal2.skyhanni.utils.renderables.Droppable
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.renderables.Renderable.Companion.renderBounds
+import at.hannibal2.skyhanni.utils.renderables.toDragItem
import kotlinx.coroutines.launch
import net.minecraft.client.Minecraft
import net.minecraft.init.Blocks
@@ -202,7 +205,7 @@ object SkyHanniDebugsAndTests {
onClick = { resetConfig() },
"§eClick to confirm.",
prefix = false,
- oneTimeClick = true
+ oneTimeClick = true,
)
}
@@ -535,6 +538,45 @@ object SkyHanniDebugsAndTests {
config.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display")
}
+ @SubscribeEvent
+ fun onGuiRenderChestGuiOverlayRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
+ @Suppress("ConstantConditionIf")
+ if (false) {
+ dragAbleTest()
+ }
+ }
+
+ private fun dragAbleTest() {
+ val bone = ItemStack(Items.bone, 1).toDragItem()
+ val leaf = ItemStack(Blocks.leaves, 1).toDragItem()
+
+ config.debugItemPos.renderRenderables(
+ listOf(
+ DragNDrop.draggable(Renderable.string("A Bone"), { bone }),
+ Renderable.placeholder(0, 30),
+ DragNDrop.draggable(Renderable.string("A Leaf"), { leaf }),
+ Renderable.placeholder(0, 30),
+ DragNDrop.droppable(
+ Renderable.string("Feed Dog"),
+ object : Droppable {
+ override fun handle(drop: Any?) {
+ val unit = drop as ItemStack
+ if (unit.item == Items.bone) {
+ LorenzDebug.chatAndLog("Oh, a bone!")
+ } else {
+ LorenzDebug.chatAndLog("Disgusting that is not a bone!")
+ }
+ }
+
+ override fun validTarget(item: Any?) = item is ItemStack
+
+ },
+ ),
+ ),
+ posLabel = "Item Debug",
+ )
+ }
+
private fun itemRenderDebug() {
val scale = 0.1
val renderables = listOf(
@@ -547,7 +589,8 @@ object SkyHanniDebugsAndTests {
}.editCopy {
this.add(
0,
- generateSequence(scale) { it + 0.1 }.take(25).map { Renderable.string(it.round(1).toString()) }.toList(),
+ generateSequence(scale) { it + 0.1 }.take(25).map { Renderable.string(it.round(1).toString()) }
+ .toList(),
)
}
config.debugItemPos.renderRenderables(