diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt index 7f3a1aace..312d24e96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt @@ -43,6 +43,7 @@ import java.util.* import kotlin.collections.HashMap import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer +import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList @@ -211,10 +212,9 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte // a lot of code is hardcoded to take CraftingContainer as it's input // hence we are forced to work around this by providing proxy container - val craftingGrid = object : MatteryContainer(3 * 3) { + val craftingGrid = object : MatteryCraftingContainer(::markDirtyFast, 3, 3) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { markDirtyFast() - craftingGridVanilla[slot] = new if (!inProcessOfCraft) { scanCraftingGrid(false) @@ -222,20 +222,15 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } }.also(::addDroppableContainer) - private val craftingGridVanilla = TransientCraftingContainer(object : AbstractContainerMenu(null, Int.MIN_VALUE) { - override fun stillValid(p_38874_: Player) = true - override fun quickMoveStack(p_38941_: Player, p_38942_: Int) = ItemStack.EMPTY - }, 3, 3) - private fun scanCraftingGrid(justCheckForRecipeChange: Boolean): Boolean { val level = level ?: return false val server = level.server ?: return false var craftingRecipe = craftingRecipe - if (craftingRecipe != null && craftingRecipe.matches(craftingGridVanilla, level)) return true + if (craftingRecipe != null && craftingRecipe.matches(craftingGrid, level)) return true if (justCheckForRecipeChange) return false - craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGridVanilla, level).orElse(null) + craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGrid, level).orElse(null) Arrays.fill(craftingGridTuples, null) val poweredView = poweredView @@ -335,7 +330,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val result: ItemStack try { - residue = craftingRecipe.getRemainingItems(craftingGridVanilla) + residue = craftingRecipe.getRemainingItems(craftingGrid) result = craftingRecipe.getResultItem(level.registryAccess()) } finally { ForgeHooks.setCraftingPlayer(null) @@ -344,7 +339,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte check(residue.size == craftingGrid.containerSize) { "Container and residue list sizes mismatch: ${residue.size} != ${craftingGrid.containerSize}" } val combinedInventory = craftingPlayer.matteryPlayer?.inventoryAndExopack - val copy = craftingGrid.iterator(true).map { it.copy() }.toList() + val copy = craftingGrid.iterator(false).map { it.copy() }.toList() // удаляем по одному предмету из сетки крафта for (slot in 0 until craftingGrid.containerSize) {