<commit_before>package net.ndrei.teslapoweredthingies.machines.poweredkiln

import net.minecraft.inventory.Slot
import net.minecraft.item.EnumDyeColor
import net.minecraft.item.ItemStack
import net.minecraftforge.items.ItemStackHandler
import net.ndrei.teslacorelib.compatibility.ItemStackUtil
import net.ndrei.teslacorelib.containers.BasicTeslaContainer
import net.ndrei.teslacorelib.containers.FilteredSlot
import net.ndrei.teslacorelib.gui.BasicTeslaGuiContainer
import net.ndrei.teslacorelib.gui.IGuiContainerPiece
import net.ndrei.teslacorelib.gui.TiledRenderedGuiPiece
import net.ndrei.teslacorelib.inventory.BoundingRectangle
import net.ndrei.teslacorelib.inventory.ColoredItemHandler
import net.ndrei.teslacorelib.inventory.LockableItemHandler
import net.ndrei.teslapoweredthingies.client.Textures
import net.ndrei.teslapoweredthingies.gui.FurnaceBurnPiece
import net.ndrei.teslapoweredthingies.gui.IWorkItemProvider
import net.ndrei.teslapoweredthingies.gui.ItemStackPiece
import net.ndrei.teslapoweredthingies.machines.BaseThingyMachine

/**
 * Created by CF on 2017-07-06.
 */
class PoweredKilnEntity
    : BaseThingyMachine(PoweredKilnEntity::class.java.name.hashCode()) {

    private lateinit var inputs: LockableItemHandler
    private lateinit var outputs: ItemStackHandler
    private lateinit var currentItems: ItemStackHandler

    //#region Inventory and GUI stuff

    override fun initializeInventories() {
        super.initializeInventories()

        this.inputs = object : LockableItemHandler(3) {
            override fun onContentsChanged(slot: Int) {
                this@PoweredKilnEntity.markDirty()
            }
        }
        super.addInventory(object : ColoredItemHandler(this.inputs, EnumDyeColor.GREEN, "Input Items", BoundingRectangle(57, 25, 62, 18)) {
            override fun canExtractItem(slot: Int) = false

            override fun canInsertItem(slot: Int, stack: ItemStack)
                = super.canInsertItem(slot, stack) && !stack.isEmpty && PoweredKilnRecipes.hasRecipe(stack)

            override fun getSlots(container: BasicTeslaContainer<*>): MutableList<Slot> {
                val result = mutableListOf<Slot>()

                val box = this.boundingBox
                if (!box.isEmpty) {
                    val columns = box.width / 18
                    (0 until this.innerHandler.slots).mapTo(result) {
                        FilteredSlot(this.itemHandlerForContainer, it,
                                box.left + 1 + (it % columns) * (18 + 4),
                                box.top  + 1
                        )
                    }
                }

                return result
            }
        })
        super.addInventoryToStorage(this.inputs, "inv_inputs")

        this.outputs = object : ItemStackHandler(6) {
            override fun onContentsChanged(slot: Int) {
                this@PoweredKilnEntity.markDirty()
            }
        }
        super.addInventory(object : ColoredItemHandler(this.outputs, EnumDyeColor.PURPLE, "Output Items", BoundingRectangle(133, 25, 36, 54)) {
            override fun canInsertItem(slot: Int, stack: ItemStack) = false
        })
        super.addInventoryToStorage(this.outputs, "inv_outputs")

        this.currentItems = object : ItemStackHandler(3) {
            override fun onContentsChanged(slot: Int) {
                this@PoweredKilnEntity.markDirty()
            }
        }
        super.addInventoryToStorage(this.currentItems, "inv_current")
    }

    override fun getGuiContainerPieces(container: BasicTeslaGuiContainer<*>): MutableList<IGuiContainerPiece> {
        val list = super.getGuiContainerPieces(container)

        list.add(TiledRenderedGuiPiece(55, 44, 22, 22, 3, 1,
                Textures.MACHINES_TEXTURES.resource, 119, 4, null))

        list.add(ItemStackPiece(55, 44, 22, 22, object: IWorkItemProvider {
            override val workItem: ItemStack
                get() = this@PoweredKilnEntity.currentItems.getStackInSlot(0)<commit_msg>fixed ui/sync bug<commit_after>package net.ndrei.teslapoweredthingies.machines.poweredkiln

import net.minecraft.inventory.Slot
import net.minecraft.item.EnumDyeColor
import net.minecraft.item.ItemStack
import net.minecraftforge.items.IItemHandler
import net.minecraftforge.items.IItemHandlerModifiable
import net.minecraftforge.items.ItemStackHandler
import net.ndrei.teslacorelib.compatibility.ItemStackUtil
import net.ndrei.teslacorelib.containers.BasicTeslaContainer
import net.ndrei.teslacorelib.containers.FilteredSlot
import net.ndrei.teslacorelib.gui.BasicTeslaGuiContainer
import net.ndrei.teslacorelib.gui.IGuiContainerPiece
import net.ndrei.teslacorelib.gui.TiledRenderedGuiPiece
import net.ndrei.teslacorelib.inventory.BoundingRectangle
import net.ndrei.teslacorelib.inventory.ColoredItemHandler
import net.ndrei.teslacorelib.inventory.LockableItemHandler
import net.ndrei.teslacorelib.inventory.SyncItemHandler
import net.ndrei.teslapoweredthingies.client.Textures
import net.ndrei.teslapoweredthingies.gui.FurnaceBurnPiece
import net.ndrei.teslapoweredthingies.gui.IWorkItemProvider
import net.ndrei.teslapoweredthingies.gui.ItemStackPiece
import net.ndrei.teslapoweredthingies.machines.BaseThingyMachine

/**
 * Created by CF on 2017-07-06.
 */
class PoweredKilnEntity
    : BaseThingyMachine(PoweredKilnEntity::class.java.name.hashCode()) {

    private lateinit var inputs: ItemStackHandler
    private lateinit var outputs: IItemHandler
    private lateinit var currentItems: IItemHandlerModifiable

    //#region Inventory and GUI stuff

    override fun initializeInventories() {
        super.initializeInventories()

        this.inputs = LockableItemHandler(3)
        super.addInventory(object : ColoredItemHandler(this.inputs, EnumDyeColor.GREEN, "Input Items", BoundingRectangle(57, 25, 62, 18)) {
            override fun canExtractItem(slot: Int) = false

            override fun canInsertItem(slot: Int, stack: ItemStack)
                = super.canInsertItem(slot, stack) && !stack.isEmpty && PoweredKilnRecipes.hasRecipe(stack)

            override fun getSlots(container: BasicTeslaContainer<*>): MutableList<Slot> {
                val result = mutableListOf<Slot>()

                val box = this.boundingBox
                if (!box.isEmpty) {
                    val columns = box.width / 18
                    (0 until this.innerHandler.slots).mapTo(result) {
                        FilteredSlot(this.itemHandlerForContainer, it,
                                box.left + 1 + (it % columns) * (18 + 4),
                                box.top  + 1
                        )
                    }
                }

                return result
            }
        })
        super.addInventoryToStorage(this.inputs, "inv_inputs")

        this.outputs = this.addSimpleInventory(6, "inv_outputs", EnumDyeColor.PURPLE, "Output Items",
            BoundingRectangle.slots(133, 25, 2, 3),
            { _, _ -> false})

        this.currentItems = SyncItemHandler(3)
        super.addInventoryToStorage(this.currentItems as SyncItemHandler, "inv_current")
    }

    override fun getGuiContainerPieces(container: BasicTeslaGuiContainer<*>): MutableList<IGuiContainerPiece> {
        val list = super.getGuiContainerPieces(container)

        list.add(TiledRenderedGuiPiece(55, 44, 22, 22, 3, 1,
                Textures.MACHINES_TEXTURES.resource, 119, 4, null))

        list.add(ItemStackPiece(55, 44, 22, 22, object: IWorkItemProvider {
            override val workItem: ItemStack
                get() = this@PoweredKilnEntity.currentItems.getStackInSlot(0)
{'fraction_non_alphanumeric': 0.08670520231213873, 'fraction_numerical': 0.015239096163951655, 'mean_word_length': 2.936401240951396, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, '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': '5111299', 'n_tokens_mistral': 2403, 'n_tokens_neox': 2217, 'n_words': 386}