All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.chestmc.nbt.SlotAdapter.kt Maven / Gradle / Ivy

package net.chestmc.nbt

import net.chestmc.Slot
import net.minecraft.server.NBTTagCompound

/**
 * A tag adapter for adapting [Slot].
 */
object SlotAdapter : TagAdapter {
  override fun load(key: String, tag: NBTTagCompound): Slot {
    val compound = tag.getCompound(key)
    return Slot(compound.getByte("Slot").toInt(), compound.getItem("Item"))
  }

  override fun save(key: String, value: Slot, tag: NBTTagCompound) {
    tag.set(key, NBTTagCompound().apply {
      setByte("Slot", value.slot.toByte())
      setItem("Item", value.item)
    })
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy