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

walkmc.nbt.SlotAdapter.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package walkmc.nbt

import net.minecraft.server.*
import walkmc.Slot

/**
 * 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