Make plate press accept processing upgrade
This commit is contained in:
parent
9758a3474c
commit
035c3edcad
@ -32,7 +32,7 @@ class PlatePressBlockEntity(
|
|||||||
p_155230_: BlockState,
|
p_155230_: BlockState,
|
||||||
val isTwin: Boolean = false,
|
val isTwin: Boolean = false,
|
||||||
) : MatteryWorkerBlockEntity<MachineItemJob>(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) {
|
) : MatteryWorkerBlockEntity<MachineItemJob>(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 energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.PLATE_PRESS)))
|
||||||
val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer)
|
val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer)
|
||||||
val outputContainer = 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 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()
|
val recipe = level.recipeManager
|
||||||
inputContainer[id].shrink(1)
|
.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)
|
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() {
|
override fun tick() {
|
||||||
|
Loading…
Reference in New Issue
Block a user