-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
382f226
commit 510c025
Showing
7 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryKeybindsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory; | ||
|
||
import at.hannibal2.skyhanni.config.FeatureToggle; | ||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
public class ChocolateFactoryKeybindsConfig { | ||
@Expose | ||
@ConfigOption(name = "Enabled", desc = "In the Chocolate Factory, press buttons with your number row on the keyboard to upgrade the rabbits.") | ||
@ConfigEditorBoolean | ||
@FeatureToggle | ||
public boolean enabled = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Key 1", desc = "Key for Rabbit Bro.") | ||
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_1) | ||
public int key1 = Keyboard.KEY_1; | ||
|
||
@Expose | ||
@ConfigOption(name = "Key 2", desc = "Key for Rabbit Cousin.") | ||
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_2) | ||
public int key2 = Keyboard.KEY_2; | ||
|
||
@Expose | ||
@ConfigOption(name = "Key 3", desc = "Key for Rabbit Sis.") | ||
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_3) | ||
public int key3 = Keyboard.KEY_3; | ||
|
||
@Expose | ||
@ConfigOption(name = "Key 4", desc = "Key for Rabbit Daddy.") | ||
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_4) | ||
public int key4 = Keyboard.KEY_4; | ||
|
||
@Expose | ||
@ConfigOption(name = "Key 5", desc = "Key for Rabbit Granny.") | ||
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_5) | ||
public int key5 = Keyboard.KEY_5; | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/at/hannibal2/skyhanni/events/GuiKeyPressEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package at.hannibal2.skyhanni.events | ||
|
||
import net.minecraft.client.gui.inventory.GuiContainer | ||
import net.minecraftforge.fml.common.eventhandler.Cancelable | ||
|
||
@Cancelable | ||
class GuiKeyPressEvent(val guiContainer: GuiContainer) : LorenzEvent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ava/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package at.hannibal2.skyhanni.features.inventory.chocolatefactory | ||
|
||
import at.hannibal2.skyhanni.events.GuiKeyPressEvent | ||
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.SimpleTimeMark | ||
import net.minecraft.client.Minecraft | ||
import net.minecraft.client.gui.inventory.GuiChest | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
import kotlin.time.Duration.Companion.milliseconds | ||
|
||
object ChocolateFactoryKeybinds { | ||
private val config get() = ChocolateFactoryAPI.config.keybinds | ||
private var lastClick = SimpleTimeMark.farPast() | ||
|
||
@SubscribeEvent | ||
fun onKeyPress(event: GuiKeyPressEvent) { | ||
if (!LorenzUtils.inSkyBlock) return | ||
if (!config.enabled) return | ||
if (!ChocolateFactoryAPI.inChocolateFactory) return | ||
|
||
val chest = event.guiContainer as? GuiChest ?: return | ||
|
||
for (index in 0..4) { | ||
val key = getKey(index) ?: error("no key for index $index") | ||
if (!key.isKeyClicked()) continue | ||
if (lastClick.passedSince() < 200.milliseconds) break | ||
lastClick = SimpleTimeMark.now() | ||
|
||
event.cancel() | ||
|
||
Minecraft.getMinecraft().playerController.windowClick( | ||
chest.inventorySlots.windowId, | ||
29 + index, | ||
2, | ||
3, | ||
Minecraft.getMinecraft().thePlayer | ||
) | ||
break | ||
} | ||
} | ||
|
||
private fun getKey(index: Int) = when (index) { | ||
0 -> config.key1 | ||
1 -> config.key2 | ||
2 -> config.key3 | ||
3 -> config.key4 | ||
4 -> config.key5 | ||
else -> null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters