MatterProviders/MatterConsumers handler filter
This commit is contained in:
parent
c5b987c2de
commit
308240ac5b
@ -6,6 +6,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.capability.fluid.stream
|
||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
|
||||
interface HandlerFilter {
|
||||
fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
@ -122,4 +123,32 @@ interface HandlerFilter {
|
||||
return stack.getCapability(MatteryCapability.PATTERN).isPresent
|
||||
}
|
||||
}
|
||||
|
||||
object MatterProviders : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return stack.getCapability(MatteryCapability.MATTER)
|
||||
.map { it.matterFlow.output && it.extractMatterChecked(Decimal.POSITIVE_INFINITY, true) > Decimal.ZERO }
|
||||
.orElse(false)
|
||||
}
|
||||
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return stack.getCapability(MatteryCapability.MATTER)
|
||||
.map { !it.matterFlow.output || it.extractMatterChecked(Decimal.POSITIVE_INFINITY, true) <= Decimal.ZERO }
|
||||
.orElse(true)
|
||||
}
|
||||
}
|
||||
|
||||
object MatterConsumers : HandlerFilter {
|
||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||
return stack.getCapability(MatteryCapability.MATTER)
|
||||
.map { it.matterFlow.input && it.receiveMatterChecked(Decimal.POSITIVE_INFINITY, true) > Decimal.ZERO }
|
||||
.orElse(false)
|
||||
}
|
||||
|
||||
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||
return stack.getCapability(MatteryCapability.MATTER)
|
||||
.map { !it.matterFlow.input || it.receiveMatterChecked(Decimal.POSITIVE_INFINITY, true) <= Decimal.ZERO }
|
||||
.orElse(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user