Skip to content

Commit

Permalink
time to release
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jun 4, 2024
1 parent 3435665 commit 2755790
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import cc.polyfrost.oneconfig.config.elements.OptionPage;
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.utils.InputHandler;
import me.imtoggle.quickswitch.Selector;
import me.imtoggle.quickswitch.config.ModConfig;
import me.imtoggle.quickswitch.element.Selector;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/me/imtoggle/quickswitch/QuickSwitch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ object QuickSwitch {
}

fun switchTo(type: Any): Boolean {
val index = mc.thePlayer. inventory.mainInventory
val hotbar = mc.thePlayer. inventory.mainInventory
.slice(0..8)
.withIndex()
.filter { (_, itemStack) ->
val index = if (type is Int) {
hotbar.firstOrNull { (_, itemStack) -> itemStack == null }?.index
} else {
hotbar.filter { (_, itemStack) ->
itemStack != null && itemStack.item.isFrom(type)
}.maxByOrNull { (_, itemStack) ->
itemStack.stackSize
}?.index
}

index?.let {
switchQueue = it
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.imtoggle.quickswitch.config
import cc.polyfrost.oneconfig.config.annotations.Exclude
import cc.polyfrost.oneconfig.config.core.OneKeyBind
import cc.polyfrost.oneconfig.libs.universal.UKeyboard
import me.imtoggle.quickswitch.ItemTypes
import me.imtoggle.quickswitch.util.ItemTypes
import me.imtoggle.quickswitch.MainRenderer
import me.imtoggle.quickswitch.QuickSwitch
import me.imtoggle.quickswitch.element.KeyBindElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cc.polyfrost.oneconfig.libs.universal.UResolution
import cc.polyfrost.oneconfig.utils.InputHandler
import cc.polyfrost.oneconfig.utils.color.ColorPalette
import cc.polyfrost.oneconfig.utils.dsl.mc
import me.imtoggle.quickswitch.ItemTypes
import me.imtoggle.quickswitch.util.ItemTypes
import me.imtoggle.quickswitch.MainRenderer
import me.imtoggle.quickswitch.util.EaseOutQuart
import net.minecraft.client.renderer.GlStateManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.imtoggle.quickswitch
package me.imtoggle.quickswitch.element

import cc.polyfrost.oneconfig.utils.InputHandler
import me.imtoggle.quickswitch.element.ItemTypeElement
import me.imtoggle.quickswitch.util.ItemTypes

object Selector {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.imtoggle.quickswitch
package me.imtoggle.quickswitch.util

import net.minecraft.init.*
import net.minecraft.item.*
Expand All @@ -16,9 +16,12 @@ enum class ItemTypes(val type: Any, val renderItem: Item) {
Egg(ItemEgg::class.java, Items.egg),
Snowball(ItemSnowball::class.java, Items.snowball),
EnderPearl(ItemEnderPearl::class.java, Items.ender_pearl),
Fireball(ItemFireball::class.java, Items.fire_charge),
Food(ItemFood::class.java, Items.golden_apple),
Bucket(Items.bucket, Items.bucket),
WaterBucket(Items.water_bucket, Items.water_bucket),
LavaBucket(Items.lava_bucket, Items.lava_bucket);
LavaBucket(Items.lava_bucket, Items.lava_bucket),
NONE(0, Item.getItemFromBlock(Blocks.barrier));

companion object {
fun getRenderItem(index: Int): Item {
Expand Down

0 comments on commit 2755790

Please sign in to comment.