Disallow to quickly pickup items from equipment slots on doubleclick

This commit is contained in:
DBotThePony 2022-10-16 19:46:08 +07:00
parent 054d393976
commit c4de2248ab
Signed by: DBot
GPG Key ID: DCC23B5715498507
4 changed files with 28 additions and 0 deletions

View File

@ -58,6 +58,10 @@ private class CosmeticSlot(container: Container, private val slot: EquipmentSlot
return 1
}
override fun canTakeItemForPickAll(): Boolean {
return false
}
override fun getNoItemIcon(): com.mojang.datafixers.util.Pair<ResourceLocation, ResourceLocation>? {
return when (slot) {
EquipmentSlot.FEET -> com.mojang.datafixers.util.Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS)

View File

@ -113,3 +113,15 @@ fun Player.curiosAwareStream(includeCosmetics: Boolean = true): Stream<out Aware
return curiosAwareStreamImpl(includeCosmetics)
}
val Slot.isCurioSlot: Boolean get() {
if (!isCuriosLoaded) {
return false
}
return isCurioSlotImpl
}
private val Slot.isCurioSlotImpl: Boolean get() {
return this is CurioSlot || this is CosmeticCurioSlot
}

View File

@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel
import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots
import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot
import ru.dbotthepony.mc.otm.container.ItemFilter
import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot
import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget
@ -313,6 +314,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
return moveItemStackToSlots(stack, _playerInventorySlots, simulate = simulate)
}
override fun canTakeItemForPickAll(p_38908_: ItemStack, p_38909_: Slot): Boolean {
if (p_38909_ is EquipmentSlot)
return false
return super.canTakeItemForPickAll(p_38908_, p_38909_) && (p_38909_ !is MatterySlot || p_38909_.canTakeItemForPickAll()) && !p_38909_.isCurioSlot
}
override fun moveItemStackTo(
item: ItemStack,
initialSlot: Int,

View File

@ -20,6 +20,10 @@ open class MatterySlot @JvmOverloads constructor(container: Container, index: In
override fun mayPlace(itemStack: ItemStack): Boolean {
return super.mayPlace(itemStack) && (!ignoreSpectators || runOnClient(true) { minecraft.player?.isSpectator != true })
}
open fun canTakeItemForPickAll(): Boolean {
return false
}
}
open class MachineOutputSlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) {