From 035c3edcadcfef557e74b0358e040ef09d0eb4ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 21:14:06 +0700 Subject: [PATCH] Make plate press accept processing upgrade --- .../entity/tech/PlatePressBlockEntity.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt index e5737178a..b68d30b98 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt @@ -32,7 +32,7 @@ class PlatePressBlockEntity( p_155230_: BlockState, val isTwin: Boolean = false, ) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { - override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC) + override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) @@ -87,10 +87,25 @@ class PlatePressBlockEntity( val level = level ?: return JobContainer.failure() - val recipe = level.recipeManager.byType(MRecipes.PLATE_PRESS).values.stream().filter { it.matches(inputContainer, id) }.findAny().orElse(null) ?: return JobContainer.noItem() - inputContainer[id].shrink(1) + val recipe = level.recipeManager + .byType(MRecipes.PLATE_PRESS) + .values + .stream() + .filter { it.matches(inputContainer, id) } + .findAny(). + orElse(null) ?: return JobContainer.noItem() + + val toProcess = inputContainer[id].count.coerceAtMost(1 + upgrades.processingItems) + + inputContainer[id].shrink(toProcess) inputContainer.setChanged(id) - return JobContainer.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) + + return JobContainer.success( + MachineItemJob( + recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), + recipe.workTime.toDouble(), + BASELINE_CONSUMPTION * toProcess, + experience = recipe.experience.sample(level.random))) } override fun tick() {