diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 20f3f0319..eeb688851 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -29,7 +29,6 @@ import net.minecraft.world.phys.Vec3 import net.neoforged.neoforge.capabilities.Capabilities import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer 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 8f8a2a83d..deeea262e 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 @@ -19,7 +19,6 @@ import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.config.ItemsConfig 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.container.slotted.AutomationFilter import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt index 8078b8dbf..2e1c5679f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt @@ -19,7 +19,6 @@ import net.neoforged.neoforge.fluids.FluidStack import net.neoforged.neoforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.immutableList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 485fea8b9..d105cc7b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -21,7 +21,6 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index d5193ae07..f0c2fa62d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -17,7 +17,6 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.immutableList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index d12f61704..4db7331f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -22,7 +22,6 @@ import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 3f3c67d79..7cc732dca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -26,7 +26,6 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 26a120f93..2698b997b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index aa10846f0..5f76987db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -14,7 +14,6 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 40f4eabd7..2e01e7368 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -18,7 +18,6 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.EnhancedContainer -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index fc816a029..ce692be8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.transcieveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt index 784e74320..d0ab00ab4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt @@ -12,7 +12,6 @@ import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index b575ae8dd..f8ed9261c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -11,7 +11,6 @@ import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyHatchBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyHatchBlockEntity.kt index d9a8c7517..da9d414d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyHatchBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyHatchBlockEntity.kt @@ -17,7 +17,6 @@ import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.RelativeSide diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt index ab84548ff..feb34a081 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt @@ -19,7 +19,6 @@ import ru.dbotthepony.mc.otm.capability.energy.CombinedProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.RelativeSide diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index b40910235..627227a9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -16,7 +16,6 @@ import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.capability.receiveEnergy -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index e5221721c..35f4e5b7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -25,7 +25,6 @@ import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.EnhancedContainer import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ItemHatchBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ItemHatchBlockEntity.kt index 2f40e9a0b..c6cab62b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ItemHatchBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ItemHatchBlockEntity.kt @@ -10,7 +10,6 @@ import net.neoforged.neoforge.capabilities.Capabilities import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt index 7a85e84e0..b493464c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt @@ -16,7 +16,6 @@ import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.capability.moveMatter import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt index ff5f4e31c..ac4949ce1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt @@ -18,7 +18,6 @@ import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.balance import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt deleted file mode 100644 index fc9c3d58d..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ /dev/null @@ -1,498 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import com.mojang.serialization.Codec -import com.mojang.serialization.codecs.RecordCodecBuilder -import it.unimi.dsi.fastutil.ints.IntAVLTreeSet -import it.unimi.dsi.fastutil.ints.IntArrayList -import it.unimi.dsi.fastutil.ints.IntComparators -import it.unimi.dsi.fastutil.ints.IntSpliterator -import it.unimi.dsi.fastutil.objects.ObjectSpliterators -import net.minecraft.core.HolderLookup -import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.world.item.ItemStack -import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.NbtOps -import net.minecraft.nbt.Tag -import net.minecraft.world.Container -import net.minecraft.world.entity.player.Player -import net.minecraft.world.entity.player.StackedContents -import net.minecraft.world.inventory.StackedContentsCompatible -import net.minecraft.world.item.Item -import net.minecraft.world.item.Items -import net.neoforged.neoforge.common.util.INBTSerializable -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.kommons.util.Delegate -import ru.dbotthepony.mc.otm.core.addSorted -import ru.dbotthepony.mc.otm.core.collect.any -import ru.dbotthepony.mc.otm.core.collect.count -import ru.dbotthepony.mc.otm.core.collect.emptyIterator -import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.core.collect.map -import ru.dbotthepony.mc.otm.core.collect.toList -import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.core.isNotEmpty -import ru.dbotthepony.mc.otm.data.codec.minRange -import ru.dbotthepony.mc.otm.network.StreamCodecs -import ru.dbotthepony.mc.otm.network.syncher.ISynchable -import ru.dbotthepony.mc.otm.network.syncher.SynchableObservedDelegate -import java.util.* -import java.util.function.Consumer -import java.util.function.Predicate -import java.util.function.Supplier -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlin.collections.ArrayList - -@Suppress("UNUSED") -open class MatteryContainer(var listener: ContainerListener, private val size: Int) : IMatteryContainer, INBTSerializable, StackedContentsCompatible { - constructor(watcher: Runnable, size: Int) : this({ _, _, _ -> watcher.run() }, size) - constructor(size: Int) : this(EmptyListener, size) - - fun interface ContainerListener { - fun setChanged(slot: Int, new: ItemStack, old: ItemStack) - } - - object EmptyListener : ContainerListener { - override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {} - } - - init { - require(size >= 0) { "Invalid container size $size" } - } - - private val slots = Array(size) { ItemStack.EMPTY } - private val nonEmptyFlags = BitSet() - private var nonEmptyIndices = IntArrayList() - private var indicesReferenced = false - private data class Update(val slot: Int, val new: ItemStack, val old: ItemStack) - private val queuedUpdates = ArrayList() - private var queueUpdates = false - - private fun cowIndices() { - if (indicesReferenced) { - nonEmptyIndices = IntArrayList(nonEmptyIndices) - indicesReferenced = false - } - } - - private val trackedSlots: Array = Array(size) { ItemStack.EMPTY } - private val filters: Array = arrayOfNulls(size) - - var changeset = 0 - private set - - override fun clearSlotFilters() { - Arrays.fill(filters, null) - } - - val synchableFilters by lazy { - immutableList { - for (i in 0 until size) { - accept(SynchableObservedDelegate(Delegate.Of({ filters[i] }, { filters[i] = it }), StreamCodecs.ITEM_TYPE_NULLABLE)) - } - } - } - - final override fun setSlotFilter(slot: Int, filter: Item?): Boolean { - filters[slot] = filter - return true - } - - final override fun getSlotFilter(slot: Int) = filters[slot] - final override fun hasSlotFilter(slot: Int) = filters[slot] !== null - final override fun isSlotForbiddenForAutomation(slot: Int) = filters[slot] === Items.AIR - - final override fun testSlotFilter(slot: Int, itemStack: ItemStack): Boolean { - return testSlotFilter(slot, itemStack.item) - } - - final override fun testSlotFilter(slot: Int, item: Item): Boolean { - if (filters[slot] == null) { - return true - } else { - return filters[slot] === item - } - } - - final override fun getContainerSize() = size - protected open fun startedIgnoringUpdates() {} - protected open fun stoppedIgnoringUpdates() {} - - private data class SerializedItem(val item: ItemStack, val slot: Int) { - companion object { - val CODEC: Codec = RecordCodecBuilder.create { - it.group( - ItemStack.OPTIONAL_CODEC.fieldOf("item").forGetter { it.item }, - Codec.INT.minRange(0).fieldOf("slot").forGetter { it.slot }, - ).apply(it, ::SerializedItem) - } - } - } - - private data class SerializedFilter(val item: Item, val slot: Int) { - companion object { - val CODEC: Codec = RecordCodecBuilder.create { - it.group( - BuiltInRegistries.ITEM.byNameCodec().fieldOf("item").forGetter { it.item }, - Codec.INT.minRange(0).fieldOf("slot").forGetter { it.slot }, - ).apply(it, ::SerializedFilter) - } - } - } - - private data class SerializedState( - val items: List, - val filters: List - ) { - companion object { - val CODEC: Codec = RecordCodecBuilder.create { - it.group( - Codec.list(SerializedItem.CODEC).fieldOf("items").forGetter { it.items }, - Codec.list(SerializedFilter.CODEC).fieldOf("filters").forGetter { it.filters }, - ).apply(it, ::SerializedState) - } - } - } - - override fun deserializeNBT(registries: HolderLookup.Provider, tag: Tag?) { - Arrays.fill(slots, ItemStack.EMPTY) - Arrays.fill(filters, null) - nonEmptyFlags.clear() - nonEmptyIndices = IntArrayList() - - if (tag != null) { - SerializedState.CODEC.parse(registries.createSerializationContext(NbtOps.INSTANCE), tag) - .resultOrPartial { LOGGER.error("Error deserializing container: $it") } - .ifPresent { - val freeSlots = IntAVLTreeSet() - - for (i in 0 until size) - freeSlots.add(i) - - for ((item, slotID) in it.items) { - if (item.isEmpty) - continue - - if (freeSlots.remove(slotID)) { - slots[slotID] = item - // trackedSlots[slotID] = item.copy() - } else if (freeSlots.isEmpty()) { - break - } else { - val slotID = freeSlots.firstInt() - freeSlots.remove(slotID) - slots[slotID] = item - // trackedSlots[slotID] = item.copy() - } - } - - for ((item, index) in it.filters) { - if (index in 0 until size) - filters[index] = item - } - - setChanged() - } - } - } - - private fun internalSetChanged(slot: Int, new: ItemStack, old: ItemStack) { - if (queueUpdates) { - queuedUpdates.add(Update(slot, new, old)) - } else { - setChanged(slot, new, old) - } - } - - private fun runUpdates() { - for ((slot, new, old) in queuedUpdates) { - setChanged(slot, new, old) - } - - queuedUpdates.clear() - } - - protected open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - listener.setChanged(slot, new, old) - } - - override fun serializeNBT(registries: HolderLookup.Provider): CompoundTag { - val state = SerializedState( - slotIterator(true).map { SerializedItem(it.item, it.slot) }.toList(size), - filters.withIndex().iterator().filter { it.value != null }.map { SerializedFilter(it.value!!, it.index) }.toList() - ) - - return SerializedState.CODEC.encodeStart(registries.createSerializationContext(NbtOps.INSTANCE), state) - .resultOrPartial { throw RuntimeException("Failed to encode container contents: $it") }.get() as CompoundTag - } - - final override fun isEmpty(): Boolean { - return nonEmptyIndices.isEmpty - } - - operator fun contains(other: ItemStack): Boolean { - for (i in 0 until size) { - if (ItemStack.isSameItemSameComponents(this[i], other)) { - return true - } - } - - return false - } - - final override fun getItem(slot: Int): ItemStack { - val item = slots[slot] - - if (item.isEmpty) { - if (nonEmptyFlags[slot]) { - setChanged(slot) - } - - return ItemStack.EMPTY - } else { - if (!nonEmptyFlags[slot]) { - setChanged(slot) - } - - return item - } - } - - override fun fillStackedContents(contents: StackedContents) { - for (item in iterator()) { - contents.accountStack(item) - } - } - - final override fun removeItem(slot: Int, amount: Int): ItemStack { - if (amount <= 0 || slot < 0 || slot >= size || slots[slot].isEmpty) - return ItemStack.EMPTY - - val old = slots[slot].copy() - val split = slots[slot].split(amount) - trackedSlots[slot] = slots[slot].copy() - changeset++ - updateEmptyFlag(slot) - internalSetChanged(slot, if (slots[slot].isEmpty) ItemStack.EMPTY else slots[slot], old) - - return split - } - - final override fun removeItemNoUpdate(slot: Int): ItemStack { - val old = slots[slot] - slots[slot] = ItemStack.EMPTY - trackedSlots[slot] = ItemStack.EMPTY - - if (old.isNotEmpty) { - updateEmptyFlag(slot) - changeset++ - } - - return old - } - - final override fun setItem(slot: Int, itemStack: ItemStack) { - if (slots[slot].isEmpty && itemStack.isEmpty || itemStack === slots[slot]) - return - - val old = slots[slot] - slots[slot] = if (itemStack.isEmpty) ItemStack.EMPTY else itemStack - trackedSlots[slot] = if (itemStack.isEmpty) ItemStack.EMPTY else itemStack.copy() - - updateEmptyFlag(slot) - changeset++ - internalSetChanged(slot, itemStack, old) - } - - final override fun setChanged() { - queueUpdates = true - - try { - for (slot in 0 until size) { - setChanged(slot) - } - - runUpdates() - } finally { - queuedUpdates.clear() - queueUpdates = false - } - } - - final override fun setChanged(slot: Int) { - if (!ItemStack.isSameItemSameComponents(slots[slot], trackedSlots[slot])) { - trackedSlots[slot] = slots[slot].copy() - updateEmptyFlag(slot) - changeset++ - internalSetChanged(slot, slots[slot], trackedSlots[slot]) - // mojang соси))0)0))0)))))0) - } - } - - private fun updateEmptyFlag(slot: Int) { - if (slots[slot].isEmpty) { - if (nonEmptyFlags[slot]) { - nonEmptyFlags[slot] = false - cowIndices() - nonEmptyIndices.rem(slot) - } - } else { - if (!nonEmptyFlags[slot]) { - nonEmptyFlags[slot] = true - cowIndices() - nonEmptyIndices.addSorted(slot, IntComparators.NATURAL_COMPARATOR) - } - } - } - - override fun stillValid(player: Player): Boolean { - return true - } - - final override fun clearContent() { - nonEmptyFlags.clear() - nonEmptyIndices = IntArrayList() - - Arrays.fill(trackedSlots, ItemStack.EMPTY) - - for (slot in 0 until size) { - if (!slots[slot].isEmpty) { - val old = slots[slot] - slots[slot] = ItemStack.EMPTY - internalSetChanged(slot, ItemStack.EMPTY, old) - } - } - } - - private inner class Iterator : kotlin.collections.Iterator { - init { - indicesReferenced = true - } - - private val parent = nonEmptyIndices.intIterator() - private var lastIndex = -1 - - override fun hasNext(): Boolean { - return parent.hasNext() - } - - override fun next(): ItemStack { - lastIndex = parent.nextInt() - return getItem(lastIndex) - } - } - - private inner class Spliterator(private val parent: IntSpliterator) : java.util.Spliterator { - override fun tryAdvance(action: Consumer): Boolean { - return parent.tryAdvance { - action.accept(getItem(it)) - } - } - - override fun trySplit(): java.util.Spliterator? { - return parent.trySplit()?.let(::Spliterator) - } - - override fun estimateSize(): Long { - return parent.estimateSize() - } - - override fun characteristics(): Int { - return parent.characteristics() - } - } - - final override fun iterator(): kotlin.collections.Iterator { - if (isEmpty) { - return emptyIterator() - } - - return Iterator() - } - - final override fun iterator(nonEmpty: Boolean): kotlin.collections.Iterator { - if (!nonEmpty) { - return (0 until size).iterator().map { slots[it] } - } else if (isEmpty) { - return emptyIterator() - } else { - return Iterator() - } - } - - inner class Slot(val slot: Int) : IFilteredContainerSlot { - override var item: ItemStack - get() = this@MatteryContainer[slot] - set(value) { this@MatteryContainer[slot] = value } - override val maxStackSize: Int - get() = this@MatteryContainer.maxStackSize - - override fun remove(): ItemStack { - return removeItemNoUpdate(slot) - } - - override fun remove(count: Int): ItemStack { - return removeItem(slot, count) - } - - override var filter: Item? - get() = getSlotFilter(slot) - set(value) { setSlotFilter(slot, value) } - - override val isForbiddenForAutomation: Boolean - get() = isSlotForbiddenForAutomation(slot) - - override fun maxStackSize(item: ItemStack): Int { - return getMaxStackSize(slot, item) - } - - override fun setChanged() { - setChanged(slot) - } - } - - final override fun slotIterator(): kotlin.collections.Iterator { - indicesReferenced = true - return nonEmptyIndices.iterator().map { Slot(it) } - } - - final override fun slotIterator(nonEmpty: Boolean): kotlin.collections.Iterator { - if (!nonEmpty) { - return (0 until size).iterator().map { Slot(it) } - } else if (isEmpty) { - return emptyIterator() - } else { - indicesReferenced = true - return nonEmptyIndices.iterator().map { Slot(it) } - } - } - - final override fun containerSlot(slot: Int): Slot { - return Slot(slot) - } - - final override fun countItem(item: Item): Int { - return iterator().filter { it.item == item }.count().toInt() - } - - final override fun hasAnyOf(items: Set): Boolean { - return iterator().any { it.item in items } - } - - final override fun hasAnyMatching(predicate: Predicate): Boolean { - return iterator().any(predicate) - } - - final override fun spliterator(): java.util.Spliterator { - if (isEmpty) { - return ObjectSpliterators.emptySpliterator() - } - - indicesReferenced = true - return Spliterator(nonEmptyIndices.intSpliterator()) - } - - companion object { - private val LOGGER = LogManager.getLogger() - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt deleted file mode 100644 index 93c85355e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt +++ /dev/null @@ -1,47 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap -import net.minecraft.world.Container -import net.minecraft.world.item.ItemStack - -class ShadowContainer(private val parent: Container) : IContainer by IContainer.wrap(parent) { - private val shadowed = Int2ObjectArrayMap(0) - - override fun clearContent() { - shadowed.clear() - parent.clearContent() - } - - override fun isEmpty(): Boolean { - return parent.isEmpty && shadowed.isEmpty() - } - - override fun getItem(slot: Int): ItemStack { - return shadowed[slot] ?: parent.getItem(slot) - } - - override fun removeItem(slot: Int, count: Int): ItemStack { - val shadow = shadowed[slot] ?: return parent.removeItem(slot, count) - val copy = shadow.copyWithCount(shadow.count.coerceAtLeast(count)) - shadow.split(count) - if (shadow.isEmpty) shadowed[slot] = ItemStack.EMPTY - return copy - } - - override fun removeItemNoUpdate(slot: Int): ItemStack { - shadowed[slot] ?: return parent.removeItemNoUpdate(slot) - val old = shadowed[slot] - shadowed[slot] = ItemStack.EMPTY - return old!! - } - - override fun setItem(slot: Int, item: ItemStack) { - shadowed[slot] = item - } - - companion object { - fun shadow(container: Container, slot: Int, itemStack: ItemStack): Container { - return ShadowContainer(container).also { it[slot] = itemStack } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt deleted file mode 100644 index 95123a710..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt +++ /dev/null @@ -1,33 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import net.minecraft.world.entity.player.StackedContents -import net.minecraft.world.inventory.CraftingContainer -import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.container.util.iterator -import ru.dbotthepony.mc.otm.core.collect.toList - -class ShadowCraftingContainer(private val parent: CraftingContainer) : IContainer by ShadowContainer(parent), CraftingContainer { - override fun fillStackedContents(contents: StackedContents) { - for (item in iterator()) { - contents.accountStack(item) - } - } - - override fun getWidth(): Int { - return parent.width - } - - override fun getHeight(): Int { - return parent.height - } - - override fun getItems(): MutableList { - return iterator().toList() - } - - companion object { - fun shadow(container: CraftingContainer, slot: Int, itemStack: ItemStack): CraftingContainer { - return ShadowCraftingContainer(container).also { it[slot] = itemStack } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt index 4ee84e841..0ab1d1033 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt @@ -23,7 +23,6 @@ import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.ClientConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/GrillMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/GrillMenu.kt index 644d81902..57a021e42 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/GrillMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/GrillMenu.kt @@ -10,7 +10,6 @@ import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.crafting.SingleRecipeInput import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.mc.otm.block.entity.decorative.GrillBlockEntity -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.immutableList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt index bff6b40eb..ec7eec0dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt @@ -16,7 +16,6 @@ import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.player.matteryPlayer -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.addAll diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index c8bc3e8df..c8d12575e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -86,7 +86,6 @@ import ru.dbotthepony.mc.otm.container.IContainerSlot import ru.dbotthepony.mc.otm.container.IEnhancedContainer import ru.dbotthepony.mc.otm.container.IFilteredContainerSlot import ru.dbotthepony.mc.otm.container.IMatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer