mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
fix slot type checking
This commit is contained in:
parent
e9ab22e20a
commit
5028064bbc
@ -19,6 +19,5 @@ import de.bixilon.minosoft.data.registries.other.containers.Container
|
||||
object ReadOnlySlotType : SlotType {
|
||||
|
||||
override fun canRemove(container: Container, slot: Int, stack: ItemStack): Boolean = false
|
||||
override fun canModify(container: Container, slot: Int, stack: ItemStack): Boolean = false
|
||||
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean = false
|
||||
}
|
||||
|
@ -19,6 +19,5 @@ import de.bixilon.minosoft.data.registries.other.containers.Container
|
||||
object RemoveOnlySlotType : SlotType {
|
||||
|
||||
override fun canRemove(container: Container, slot: Int, stack: ItemStack): Boolean = true
|
||||
override fun canModify(container: Container, slot: Int, stack: ItemStack): Boolean = true
|
||||
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean = true
|
||||
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean = false
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ import de.bixilon.minosoft.data.registries.other.containers.Container
|
||||
|
||||
interface SlotType {
|
||||
|
||||
fun canRemove(container: Container, slot: Int, stack: ItemStack) = true
|
||||
fun canModify(container: Container, slot: Int, stack: ItemStack) = true
|
||||
fun canRemove(container: Container, slot: Int, stack: ItemStack): Boolean {
|
||||
// ToDo: Check course of binding
|
||||
return true
|
||||
}
|
||||
|
||||
fun canPut(container: Container, slot: Int, stack: ItemStack) = true
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ object ChestSlotType : EquipmentSlotType {
|
||||
if (item !is ArmorItem) {
|
||||
return false
|
||||
}
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.CHEST
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.CHEST && super.canPut(container, slot, stack)
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ object FeetSlotType : EquipmentSlotType {
|
||||
if (item !is ArmorItem) {
|
||||
return false
|
||||
}
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.FEET
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.FEET && super.canPut(container, slot, stack)
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.data.registries.other.containers.slots.equipment
|
||||
|
||||
import de.bixilon.minosoft.data.inventory.InventorySlots
|
||||
import de.bixilon.minosoft.data.inventory.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
||||
import de.bixilon.minosoft.data.registries.items.armor.ArmorItem
|
||||
import de.bixilon.minosoft.data.registries.other.containers.Container
|
||||
|
||||
@ -22,10 +23,12 @@ object HeadSlotType : EquipmentSlotType {
|
||||
|
||||
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
|
||||
val item = stack.item.item
|
||||
// ToDo: Carved pumpkin
|
||||
if (item.resourceLocation == MinecraftBlocks.CARVED_PUMPKIN) {
|
||||
return super.canPut(container, slot, stack)
|
||||
}
|
||||
if (item !is ArmorItem) {
|
||||
return false
|
||||
}
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.HEAD
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.HEAD && super.canPut(container, slot, stack)
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ object LegsSlotType : EquipmentSlotType {
|
||||
if (item !is ArmorItem) {
|
||||
return false
|
||||
}
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.LEGS
|
||||
return item.equipmentSlot == InventorySlots.EquipmentSlots.LEGS && super.canPut(container, slot, stack)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user