Calculate fluid operations using Longs

This commit is contained in:
DBotThePony 2024-01-09 13:53:06 +07:00
parent ddaa0dafe5
commit 3a813d4353
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -50,7 +50,7 @@ abstract class AbstractMatteryFluidHandler : IFluidHandler {
val fluid = fluid val fluid = fluid
if (fluid.isEmpty || fluid.isFluidEqual(resource)) { if (fluid.isEmpty || fluid.isFluidEqual(resource)) {
val new = (fluid.amount + resource.amount).coerceAtMost(capacity) val new = (fluid.amount.toLong() + resource.amount.toLong()).coerceAtMost(capacity.toLong()).toInt()
if (new <= fluid.amount) return 0 if (new <= fluid.amount) return 0
if (action.execute()) { if (action.execute()) {
@ -86,7 +86,7 @@ abstract class AbstractMatteryFluidHandler : IFluidHandler {
if (fluid.isEmpty) { if (fluid.isEmpty) {
return FluidStack.EMPTY return FluidStack.EMPTY
} else { } else {
val new = (fluid.amount - maxDrain).coerceAtLeast(0) val new = (fluid.amount.toLong() - maxDrain.toLong()).coerceAtLeast(0L).toInt()
if (action.execute()) { if (action.execute()) {
if (new == 0) { if (new == 0) {