Fix fluid tank not working properly with items

This commit is contained in:
DBotThePony 2024-11-16 10:51:27 +07:00
parent f870c2cefc
commit 9daa3df589
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 28 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter
import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.container.get
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.isNotSameAs
import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu
import ru.dbotthepony.mc.otm.network.wrap
import ru.dbotthepony.mc.otm.registry.MBlockEntities
@ -109,7 +110,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery
val moved1 = moveFluid(source = cap1, destination = fluid)
if (moved1 != moved0 || moved1.amount != moved0.amount) {
if (moved1 isNotSameAs moved0) {
LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from ${cap.container}, moved $moved1 from ${cap1.container} during execution. This is likely a bug in OTM or other mod!")
} else {
item.count--
@ -161,7 +162,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery
val moved1 = moveFluid(source = fluid, destination = cap1)
if (moved1 != moved0 || moved1.amount != moved0.amount) {
if (moved1 isNotSameAs moved0) {
LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from ${cap.container}, moved $moved1 from ${cap1.container} during execution. This is likely a bug in OTM or other mod!")
} else {
item.count--

View File

@ -15,7 +15,6 @@ import net.minecraft.Util
import net.minecraft.core.BlockPos
import net.minecraft.core.Holder
import net.minecraft.core.HolderLookup
import net.minecraft.core.HolderSet
import net.minecraft.core.Registry
import net.minecraft.core.SectionPos
import net.minecraft.core.registries.BuiltInRegistries
@ -568,3 +567,28 @@ fun <T : Any> Registry<T>.getHolderOrThrow(value: T): Holder<T> {
fun <T : Any> Registry<T>.getReverseTag(value: T): Stream<TagKey<T>> {
return getHolder(value)?.tags() ?: Stream.empty()
}
// forge > neoforge moment
infix fun FluidStack.isSameFluidSameComponents(other: FluidStack): Boolean {
return FluidStack.isSameFluidSameComponents(this, other)
}
infix fun FluidStack.isSameFluid(other: FluidStack): Boolean {
return FluidStack.isSameFluid(this, other)
}
infix fun FluidStack.isNotSameFluidSameComponents(other: FluidStack): Boolean {
return !FluidStack.isSameFluidSameComponents(this, other)
}
infix fun FluidStack.isNotSameFluid(other: FluidStack): Boolean {
return !FluidStack.isSameFluid(this, other)
}
infix fun FluidStack.isSameAs(other: FluidStack): Boolean {
return FluidStack.isSameFluidSameComponents(this, other) && amount == other.amount
}
infix fun FluidStack.isNotSameAs(other: FluidStack): Boolean {
return !FluidStack.isSameFluidSameComponents(this, other) && amount == other.amount
}