diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt index 819864908..a27db5d36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt @@ -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-- diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index 850f75af0..f990a69fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -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 Registry.getHolderOrThrow(value: T): Holder { fun Registry.getReverseTag(value: T): Stream> { 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 +}