Overflow prevention inside painter block entity
This commit is contained in:
parent
604029dcd5
commit
d540cbef3c
@ -66,8 +66,8 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int {
|
override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int {
|
||||||
if (resource.isEmpty || resource.fluid != Fluids.WATER || waterStored() >= MAX_WATER_STORAGE) return 0
|
if (resource.amount <= 0 || resource.fluid != Fluids.WATER || waterStored() >= MAX_WATER_STORAGE) return 0
|
||||||
val diff = (waterStored() + resource.amount).coerceAtMost(MAX_WATER_STORAGE) - waterStored()
|
val diff = ((waterStored().toLong() + resource.amount.toLong()).coerceAtMost(MAX_WATER_STORAGE.toLong()) - waterStored().toLong()).toInt()
|
||||||
if (action.simulate() || diff == 0) return diff
|
if (action.simulate() || diff == 0) return diff
|
||||||
dyeStored[null] = waterStored() + diff
|
dyeStored[null] = waterStored() + diff
|
||||||
return diff
|
return diff
|
||||||
|
Loading…
Reference in New Issue
Block a user