mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
rework some container sections
This commit is contained in:
parent
3ca82f202f
commit
660e41db88
@ -57,7 +57,7 @@ class FastMoveContainerActionTest {
|
|||||||
container.invokeAction(FastMoveContainerAction(0))
|
container.invokeAction(FastMoveContainerAction(0))
|
||||||
assertNull(container.floatingItem)
|
assertNull(container.floatingItem)
|
||||||
assertEquals(container.slots, slotsOf(62 to ItemStack(AppleTestO.item, 9)))
|
assertEquals(container.slots, slotsOf(62 to ItemStack(AppleTestO.item, 9)))
|
||||||
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(62 to null, 0 to ItemStack(AppleTestO.item, count = 9)), null))
|
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(0 to null, 62 to ItemStack(AppleTestO.item, count = 9)), null))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fullHotbarChestToHotbar() {
|
fun fullHotbarChestToHotbar() {
|
||||||
@ -116,11 +116,7 @@ class FastMoveContainerActionTest {
|
|||||||
|
|
||||||
container.invokeAction(FastMoveContainerAction(30))
|
container.invokeAction(FastMoveContainerAction(30))
|
||||||
assertNull(container.floatingItem)
|
assertNull(container.floatingItem)
|
||||||
assertNull(container[0])
|
assertEquals(container.slots, slotsOf(3 to ItemStack(EggTestO.item, 12)))
|
||||||
assertNull(container[1])
|
|
||||||
assertNull(container[2])
|
|
||||||
assertNull(container[30])
|
|
||||||
assertEquals(container[3], ItemStack(EggTestO.item, 12))
|
|
||||||
|
|
||||||
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(30 to null, 3 to ItemStack(AppleTestO.item, count = 8)), null))
|
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(30 to null, 3 to ItemStack(AppleTestO.item, count = 8)), null))
|
||||||
}
|
}
|
||||||
@ -133,11 +129,9 @@ class FastMoveContainerActionTest {
|
|||||||
|
|
||||||
container.invokeAction(FastMoveContainerAction(30))
|
container.invokeAction(FastMoveContainerAction(30))
|
||||||
assertNull(container.floatingItem)
|
assertNull(container.floatingItem)
|
||||||
assertNull(container[0])
|
assertEquals(container.slots, slotsOf(1 to ItemStack(CoalTest0.item, 12)))
|
||||||
assertEquals(container[1], ItemStack(CoalTest0.item, 12))
|
|
||||||
assertNull(container[2])
|
|
||||||
|
|
||||||
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(30 to null, 1 to ItemStack(AppleTestO.item, count = 8)), null))
|
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 30, 1, 0, 0, slotsOf(30 to null, 1 to ItemStack(CoalTest0.item, count = 12)), null))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: revert, full container
|
// TODO: revert, full container
|
||||||
|
@ -87,7 +87,15 @@ open class Container(
|
|||||||
|
|
||||||
open fun getSlotType(slotId: Int): SlotType? = DefaultSlotType
|
open fun getSlotType(slotId: Int): SlotType? = DefaultSlotType
|
||||||
open fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? = null
|
open fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? = null
|
||||||
open fun getSection(slotId: Int): Int? = null
|
|
||||||
|
open fun getSection(slotId: Int): Int? {
|
||||||
|
for ((index, section) in sections.withIndex()) {
|
||||||
|
if (slotId in section) {
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
operator fun get(slotId: Int): ItemStack? {
|
operator fun get(slotId: Int): ItemStack? {
|
||||||
try {
|
try {
|
||||||
|
@ -32,4 +32,8 @@ object ContainerUtil {
|
|||||||
|
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun section(offset: Int, count: Int): IntRange {
|
||||||
|
return offset until offset + count
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.container
|
package de.bixilon.minosoft.data.container
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.container.ContainerUtil.section
|
||||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||||
import de.bixilon.minosoft.data.container.types.PlayerInventory
|
import de.bixilon.minosoft.data.container.types.PlayerInventory
|
||||||
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
|
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
|
||||||
@ -24,7 +25,7 @@ abstract class InventorySynchronizedContainer(
|
|||||||
type: ContainerType,
|
type: ContainerType,
|
||||||
title: ChatComponent? = null,
|
title: ChatComponent? = null,
|
||||||
protected var synchronizedSlots: IntRange,
|
protected var synchronizedSlots: IntRange,
|
||||||
protected var inventorySlots: IntRange = PlayerInventory.MAIN_SLOTS_START until (PlayerInventory.MAIN_SLOTS_START + PlayerInventory.MAIN_SLOTS),
|
protected var inventorySlots: IntRange = section(PlayerInventory.MAIN_SLOTS_START, PlayerInventory.MAIN_SLOTS),
|
||||||
) : Container(connection, type, title) {
|
) : Container(connection, type, title) {
|
||||||
private val playerInventory = connection.player.inventory
|
private val playerInventory = connection.player.inventory
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.container.stack.ItemStack
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||||
|
|
||||||
class FastMoveContainerAction(
|
class FastMoveContainerAction(
|
||||||
val slot: Int,
|
val slot: Int,
|
||||||
@ -32,13 +33,18 @@ class FastMoveContainerAction(
|
|||||||
val sourceSection = container.getSection(slot) ?: Int.MAX_VALUE
|
val sourceSection = container.getSection(slot) ?: Int.MAX_VALUE
|
||||||
|
|
||||||
// loop over all sections and get the lowest slot in the lowest section that fits best
|
// loop over all sections and get the lowest slot in the lowest section that fits best
|
||||||
val targets = Int2ObjectOpenHashMap<ItemStack?>()
|
val targets: MutableList<IntArrayList> = mutableListOf()
|
||||||
for ((index, section) in container.sections.withIndex()) {
|
for ((index, section) in container.sections.withIndex()) {
|
||||||
if (index == sourceSection) {
|
if (index == sourceSection) {
|
||||||
// we don't want to swap into the same section, that is just useless
|
// we don't want to swap into the same section, that is just useless
|
||||||
// ToDo: Is this vanilla behavior?
|
// ToDo: Is this vanilla behavior?
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if (section.isEmpty()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val list = IntArrayList()
|
||||||
|
targets += list
|
||||||
for (slot in section) {
|
for (slot in section) {
|
||||||
val content = container.slots[slot]
|
val content = container.slots[slot]
|
||||||
if (content != null && !source.matches(content)) { // only check slots that are not empty
|
if (content != null && !source.matches(content)) { // only check slots that are not empty
|
||||||
@ -49,26 +55,28 @@ class FastMoveContainerAction(
|
|||||||
// this item is not allowed in this slot (e.g. blocks in armor slot)
|
// this item is not allowed in this slot (e.g. blocks in armor slot)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
list += slot
|
||||||
targets[slot] = content
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val changes: Int2ObjectOpenHashMap<ItemStack> = Int2ObjectOpenHashMap()
|
val changes: Int2ObjectOpenHashMap<ItemStack> = Int2ObjectOpenHashMap()
|
||||||
for ((slot, content) in targets.toSortedMap()) {
|
sections@ for (list in targets) {
|
||||||
if (content == null) {
|
for (slot in list.intIterator()) {
|
||||||
changes[slot] = source
|
val content = container.slots[slot]
|
||||||
changes[this.slot] = null
|
if (content == null) {
|
||||||
container._set(slot, source)
|
changes[slot] = source
|
||||||
container._set(this.slot, null)
|
changes[this.slot] = null
|
||||||
break
|
container._set(slot, source)
|
||||||
}
|
container._set(this.slot, null)
|
||||||
val countToPut = source.item._count - (source.item.item.maxStackSize - content.item._count)
|
break@sections
|
||||||
source.item._count -= countToPut
|
}
|
||||||
content.item._count += countToPut
|
val countToPut = source.item._count - (source.item.item.maxStackSize - content.item._count)
|
||||||
changes[slot] = content
|
source.item._count -= countToPut
|
||||||
changes[this.slot] = source // duplicated
|
content.item._count += countToPut
|
||||||
if (source.item._count <= 0) {
|
changes[slot] = content
|
||||||
break
|
changes[this.slot] = source // duplicated
|
||||||
|
if (source.item._count <= 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import de.bixilon.minosoft.data.container.stack.ItemStack
|
|||||||
import de.bixilon.minosoft.data.registries.fluid.lava.LavaFluid
|
import de.bixilon.minosoft.data.registries.fluid.lava.LavaFluid
|
||||||
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
|
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
|
||||||
|
|
||||||
@Deprecated("ToDo")
|
|
||||||
object FuelSlotType : SlotType {
|
object FuelSlotType : SlotType {
|
||||||
|
|
||||||
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
|
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.container.types
|
package de.bixilon.minosoft.data.container.types
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.container.ContainerUtil.section
|
||||||
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
||||||
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
||||||
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
||||||
@ -26,8 +27,8 @@ import de.bixilon.minosoft.data.text.ChatComponent
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
|
||||||
class CraftingContainer(connection: PlayConnection, type: ContainerType, title: ChatComponent?) : InventorySynchronizedContainer(connection, type, title, (CRAFTING_SLOTS + 1)..(CRAFTING_SLOTS + PlayerInventory.MAIN_SLOTS)) {
|
class CraftingContainer(connection: PlayConnection, type: ContainerType, title: ChatComponent?) : InventorySynchronizedContainer(connection, type, title, section(CRAFTING_SLOTS + 1, PlayerInventory.MAIN_SLOTS)) {
|
||||||
override val sections: Array<IntRange> = arrayOf(0 until 1, 1 until 1 + CRAFTING_SLOTS, 1 + CRAFTING_SLOTS until 1 + CRAFTING_SLOTS + PlayerInventory.MAIN_SLOTS)
|
override val sections: Array<IntRange> get() = SECTIONS
|
||||||
|
|
||||||
override fun getSlotType(slotId: Int): SlotType? {
|
override fun getSlotType(slotId: Int): SlotType? {
|
||||||
if (slotId == 0) {
|
if (slotId == 0) {
|
||||||
@ -64,6 +65,12 @@ class CraftingContainer(connection: PlayConnection, type: ContainerType, title:
|
|||||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:crafting".toResourceLocation()
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:crafting".toResourceLocation()
|
||||||
override val ALIASES: Set<ResourceLocation> = setOf("minecraft:crafting_table".toResourceLocation())
|
override val ALIASES: Set<ResourceLocation> = setOf("minecraft:crafting_table".toResourceLocation())
|
||||||
const val CRAFTING_SLOTS = 3 * 3
|
const val CRAFTING_SLOTS = 3 * 3
|
||||||
|
val SECTIONS: Array<IntRange> = arrayOf(
|
||||||
|
// crafting slots are not shift clickable, no section
|
||||||
|
section(CRAFTING_SLOTS + 1 + PlayerInventory.PASSIVE_SLOTS, PlayerInventory.HOTBAR_SLOTS),
|
||||||
|
section(CRAFTING_SLOTS + 1, PlayerInventory.PASSIVE_SLOTS),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
override fun build(connection: PlayConnection, type: ContainerType, title: ChatComponent?): CraftingContainer {
|
override fun build(connection: PlayConnection, type: ContainerType, title: ChatComponent?): CraftingContainer {
|
||||||
return CraftingContainer(connection, type, title)
|
return CraftingContainer(connection, type, title)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.data.container.types
|
package de.bixilon.minosoft.data.container.types
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.container.Container
|
import de.bixilon.minosoft.data.container.Container
|
||||||
|
import de.bixilon.minosoft.data.container.ContainerUtil.section
|
||||||
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
||||||
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
||||||
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
||||||
@ -30,8 +31,8 @@ import de.bixilon.minosoft.data.text.ChatComponent
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
|
||||||
class EnchantingContainer(connection: PlayConnection, type: ContainerType, title: ChatComponent?) : InventorySynchronizedContainer(connection, type, title, ENCHANTING_SLOTS until (ENCHANTING_SLOTS + PlayerInventory.MAIN_SLOTS)) {
|
class EnchantingContainer(connection: PlayConnection, type: ContainerType, title: ChatComponent?) : InventorySynchronizedContainer(connection, type, title, section(ENCHANTING_SLOTS, PlayerInventory.MAIN_SLOTS)) {
|
||||||
override val sections: Array<IntRange> = arrayOf(0 until ENCHANTING_SLOTS, ENCHANTING_SLOTS until ENCHANTING_SLOTS + PlayerInventory.MAIN_SLOTS)
|
override val sections: Array<IntRange> get() = SECTIONS
|
||||||
val costs = IntArray(ENCHANTING_OPTIONS) { -1 }
|
val costs = IntArray(ENCHANTING_OPTIONS) { -1 }
|
||||||
val enchantments: Array<Enchantment?> = arrayOfNulls(ENCHANTING_OPTIONS)
|
val enchantments: Array<Enchantment?> = arrayOfNulls(ENCHANTING_OPTIONS)
|
||||||
var enchantmentLevels = IntArray(ENCHANTING_OPTIONS) { -1 }
|
var enchantmentLevels = IntArray(ENCHANTING_OPTIONS) { -1 }
|
||||||
@ -47,16 +48,6 @@ class EnchantingContainer(connection: PlayConnection, type: ContainerType, title
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSection(slotId: Int): Int? {
|
|
||||||
if (slotId in 0..1) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if (slotId in ENCHANTING_SLOTS..ENCHANTING_SLOTS + PlayerInventory.MAIN_SLOTS) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? {
|
override fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? {
|
||||||
if (slot == SlotSwapContainerAction.SwapTargets.OFFHAND) {
|
if (slot == SlotSwapContainerAction.SwapTargets.OFFHAND) {
|
||||||
return null // ToDo: It is possible to press F in vanilla, but there is no slot for it
|
return null // ToDo: It is possible to press F in vanilla, but there is no slot for it
|
||||||
@ -87,6 +78,13 @@ class EnchantingContainer(connection: PlayConnection, type: ContainerType, title
|
|||||||
const val ENCHANTING_SLOTS = 2
|
const val ENCHANTING_SLOTS = 2
|
||||||
const val ENCHANTING_OPTIONS = 3
|
const val ENCHANTING_OPTIONS = 3
|
||||||
|
|
||||||
|
|
||||||
|
private val SECTIONS: Array<IntRange> = arrayOf(
|
||||||
|
section(0, ENCHANTING_SLOTS),
|
||||||
|
section(ENCHANTING_SLOTS + PlayerInventory.PASSIVE_SLOTS, PlayerInventory.HOTBAR_SLOTS),
|
||||||
|
section(ENCHANTING_SLOTS, PlayerInventory.PASSIVE_SLOTS),
|
||||||
|
)
|
||||||
|
|
||||||
override fun build(connection: PlayConnection, type: ContainerType, title: ChatComponent?): EnchantingContainer {
|
override fun build(connection: PlayConnection, type: ContainerType, title: ChatComponent?): EnchantingContainer {
|
||||||
return EnchantingContainer(connection, type, title)
|
return EnchantingContainer(connection, type, title)
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,7 @@ class PlayerInventory(connection: PlayConnection) : Container(connection = conne
|
|||||||
|
|
||||||
const val MAIN_SLOTS_PER_ROW = 9
|
const val MAIN_SLOTS_PER_ROW = 9
|
||||||
const val MAIN_ROWS = 4
|
const val MAIN_ROWS = 4
|
||||||
|
const val PASSIVE_SLOTS = MAIN_SLOTS_PER_ROW * (MAIN_ROWS - 1)
|
||||||
const val MAIN_SLOTS = MAIN_SLOTS_PER_ROW * MAIN_ROWS
|
const val MAIN_SLOTS = MAIN_SLOTS_PER_ROW * MAIN_ROWS
|
||||||
const val MAIN_SLOTS_START = ARMOR_OFFSET + 4
|
const val MAIN_SLOTS_START = ARMOR_OFFSET + 4
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.container.types.generic
|
package de.bixilon.minosoft.data.container.types.generic
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.container.ContainerUtil.section
|
||||||
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
import de.bixilon.minosoft.data.container.InventorySynchronizedContainer
|
||||||
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
import de.bixilon.minosoft.data.container.click.SlotSwapContainerAction
|
||||||
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
import de.bixilon.minosoft.data.container.slots.DefaultSlotType
|
||||||
@ -27,8 +28,12 @@ abstract class GenericContainer(
|
|||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
type: ContainerType,
|
type: ContainerType,
|
||||||
title: ChatComponent?,
|
title: ChatComponent?,
|
||||||
) : InventorySynchronizedContainer(connection, type, title, (rows * SLOTS_PER_ROW) until (rows * SLOTS_PER_ROW + PlayerInventory.MAIN_SLOTS)) {
|
) : InventorySynchronizedContainer(connection, type, title, section(rows * SLOTS_PER_ROW, PlayerInventory.MAIN_SLOTS)) {
|
||||||
override val sections: Array<IntRange> = arrayOf(0 until rows * SLOTS_PER_ROW, rows * SLOTS_PER_ROW + 1 until rows * SLOTS_PER_ROW + PlayerInventory.MAIN_SLOTS)
|
override val sections: Array<IntRange> = arrayOf(
|
||||||
|
section(0, rows * SLOTS_PER_ROW),
|
||||||
|
section(rows * SLOTS_PER_ROW + PlayerInventory.PASSIVE_SLOTS, PlayerInventory.HOTBAR_SLOTS),
|
||||||
|
section(rows * SLOTS_PER_ROW, PlayerInventory.PASSIVE_SLOTS),
|
||||||
|
)
|
||||||
|
|
||||||
override fun getSlotType(slotId: Int): SlotType? {
|
override fun getSlotType(slotId: Int): SlotType? {
|
||||||
if (slotId in 0 until rows * SLOTS_PER_ROW + PlayerInventory.MAIN_SLOTS) {
|
if (slotId in 0 until rows * SLOTS_PER_ROW + PlayerInventory.MAIN_SLOTS) {
|
||||||
@ -37,16 +42,6 @@ abstract class GenericContainer(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSection(slotId: Int): Int? {
|
|
||||||
if (slotId in 0 until rows * SLOTS_PER_ROW) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if (slotId in rows * SLOTS_PER_ROW until rows * SLOTS_PER_ROW + PlayerInventory.MAIN_SLOTS) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? {
|
override fun getSlotSwap(slot: SlotSwapContainerAction.SwapTargets): Int? {
|
||||||
if (slot == SlotSwapContainerAction.SwapTargets.OFFHAND) {
|
if (slot == SlotSwapContainerAction.SwapTargets.OFFHAND) {
|
||||||
return null // ToDo: It is possible to press F in vanilla, but there is no slot for it
|
return null // ToDo: It is possible to press F in vanilla, but there is no slot for it
|
||||||
|
@ -37,10 +37,12 @@ abstract class SmeltingContainer(connection: PlayConnection, type: ContainerType
|
|||||||
var maxFuel: Int = 0
|
var maxFuel: Int = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
override val sections: Array<IntRange> get() = SECTIONS
|
||||||
|
|
||||||
|
|
||||||
override fun getSlotType(slotId: Int): SlotType? {
|
override fun getSlotType(slotId: Int): SlotType? {
|
||||||
if (slotId == 0) {
|
if (slotId == 0) {
|
||||||
return DefaultSlotType // ToDo: only smeltable items
|
return DefaultSlotType // ToDo: only smeltable items (check recipes)
|
||||||
}
|
}
|
||||||
if (slotId == 1) {
|
if (slotId == 1) {
|
||||||
return FuelSlotType
|
return FuelSlotType
|
||||||
@ -58,12 +60,15 @@ abstract class SmeltingContainer(connection: PlayConnection, type: ContainerType
|
|||||||
if (slotId == 2) {
|
if (slotId == 2) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (slotId == 0 || slotId == 1) {
|
if (slotId == 1) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if (slotId in SMELTING_SLOTS until SMELTING_SLOTS + PlayerInventory.MAIN_SLOTS) {
|
if (slotId == 0) {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
if (slotId in SMELTING_SLOTS until SMELTING_SLOTS + PlayerInventory.MAIN_SLOTS) {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,5 +91,12 @@ abstract class SmeltingContainer(connection: PlayConnection, type: ContainerType
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SMELTING_SLOTS = 3
|
const val SMELTING_SLOTS = 3
|
||||||
|
|
||||||
|
val SECTIONS: Array<IntRange> = arrayOf(
|
||||||
|
2..2,
|
||||||
|
1..1,
|
||||||
|
0..0,
|
||||||
|
SMELTING_SLOTS..SMELTING_SLOTS + PlayerInventory.MAIN_SLOTS,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user