# Pastebin 5HfiyWTt class SomeTE: TileEntity(/* etc */) { val nbtData: NBTTagCompound = NBTTagCompound() val someProp: MutableList by nbtData // Save/Load nbtData in the relevent hooks. // Now you can access someProp as a normal property, except the magick below will transparently read/write it from nbtData at runtime. } // WARNING: MAgick: inline operator fun NBTTagCompound.getValue(thisRef: Any?, prop: KProperty<*>): T { when(T::class) { Int::class -> return getInteger(prop.name) as T String::class -> return getString(prop.name) as T MutableList::class -> { when (T::class.typeParameters[0]) { String::class -> { var list = getTag(prop.name) as NBTTagList return (MutableList(list.tagCount()) { it: Int -> list.getStringTagAt(it) }) as T } } } } throw InvalidArgument("Butts butts butts.") } inline operator fun NBTTagCompound.setValue(thisRef: Any?, prop: KProperty<*>, value: T) { when(T::class) { Int::class -> setInteger(prop.name, value as Int) String::class -> setString(prop.name, value as String) MutableList::class -> { when(T::class.typeParameters[0]) { String::class -> { var list = NBTTagList() (value as MutableList).forEach { list.appendTag(NBTTagString(it)) } setTag(prop.name, list) } } } } }