<commit_before>package opengrave

import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTBase
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagList

fun NBTTagCompound.getItemStackArray(key: String): Array<ItemStack?> {
    val tagList = getTagList(key, NBTBase.NBT_TYPES.indexOf("COMPOUND"))
    val size = tagList.tagCount()
    if (size == 0)
        return emptyArray()
    val itemStackList = Array<ItemStack?>(size) { null }
    for (i in 0..size - 1) {
        val nbtTagCompound = tagList.getCompoundTagAt(i)
        val slot = nbtTagCompound.getInteger("slot")
        val itemStack = ItemStack.loadItemStackFromNBT(nbtTagCompound)
        println("i:$i\tslot:$slot\tstack:$itemStack")
        itemStackList[slot] = itemStack
    }
    return itemStackList
}

fun Array<ItemStack?>.toNBTTag(): NBTBase {
    val nbtTagList = NBTTagList()
    for ((i, stack) in this.withIndex()) {
        val nbtTagCompound = NBTTagCompound()
        nbtTagCompound.setInteger("slot", i)
        stack?.writeToNBT(nbtTagCompound)
        nbtTagList.appendTag(nbtTagCompound)
    }
    return nbtTagList
}<commit_msg>Removed left in println<commit_after>package opengrave

import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTBase
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagList

fun NBTTagCompound.getItemStackArray(key: String): Array<ItemStack?> {
    val tagList = getTagList(key, NBTBase.NBT_TYPES.indexOf("COMPOUND"))
    val size = tagList.tagCount()
    if (size == 0)
        return emptyArray()
    val itemStackList = Array<ItemStack?>(size) { null }
    for (i in 0..size - 1) {
        val nbtTagCompound = tagList.getCompoundTagAt(i)
        val slot = nbtTagCompound.getInteger("slot")
        val itemStack = ItemStack.loadItemStackFromNBT(nbtTagCompound)
        itemStackList[slot] = itemStack
    }
    return itemStackList
}

fun Array<ItemStack?>.toNBTTag(): NBTBase {
    val nbtTagList = NBTTagList()
    for ((i, stack) in this.withIndex()) {
        val nbtTagCompound = NBTTagCompound()
        nbtTagCompound.setInteger("slot", i)
        stack?.writeToNBT(nbtTagCompound)
        nbtTagList.appendTag(nbtTagCompound)
    }
    return nbtTagList
}
{'fraction_non_alphanumeric': 0.10822898032200358, 'fraction_numerical': 0.0026833631484794273, 'mean_word_length': 3.631469979296066, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '813152', 'n_tokens_mistral': 771, 'n_tokens_neox': 771, 'n_words': 140}