Fix being unable to drain sub 1-xp point liquid xp
This commit is contained in:
parent
640aeabb07
commit
f82c7977fa
@ -117,6 +117,10 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
|
||||
experience = (nbt?.asDouble ?: 0.0).coerceAtLeast(0.0)
|
||||
}
|
||||
|
||||
private val liquidXPMilliBuckets: Int get() {
|
||||
return (experience * XP_TO_LIQUID_RATIO).toInt()
|
||||
}
|
||||
|
||||
override fun getTanks(): Int {
|
||||
return 1
|
||||
}
|
||||
@ -125,7 +129,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
|
||||
if (tank != 0)
|
||||
return FluidStack.EMPTY
|
||||
|
||||
return FluidStack(MFluids.LIQUID_XP, (experience * XP_TO_LIQUID_RATIO).toInt())
|
||||
return FluidStack(MFluids.LIQUID_XP, liquidXPMilliBuckets)
|
||||
}
|
||||
|
||||
override fun getTankCapacity(tank: Int): Int {
|
||||
@ -148,13 +152,13 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
|
||||
}
|
||||
|
||||
override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack {
|
||||
val actualDrain = maxDrain.coerceAtMost((experience * XP_TO_LIQUID_RATIO).toInt()).let { it / XP_TO_LIQUID_RATIO * XP_TO_LIQUID_RATIO }
|
||||
val actualDrain = maxDrain.coerceAtMost(liquidXPMilliBuckets)
|
||||
|
||||
if (actualDrain <= 0)
|
||||
return FluidStack.EMPTY
|
||||
|
||||
if (action.execute())
|
||||
experience -= actualDrain / XP_TO_LIQUID_RATIO
|
||||
experience -= actualDrain.toDouble() / XP_TO_LIQUID_RATIO
|
||||
|
||||
return FluidStack(MFluids.LIQUID_XP, actualDrain)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user