Make it compile again so migration can be done incrementally
This commit is contained in:
parent
5e8ab76f49
commit
ffdd44357d
@ -149,7 +149,7 @@ val ItemStack.matteryEnergy: IMatteryEnergyStorage? get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Player.items(includeCosmetics: Boolean = true): Iterator<ItemStack> {
|
fun Player.items(includeCosmetics: Boolean = true): Iterator<ItemStack> {
|
||||||
val matteryPlayer = matteryPlayer ?: return emptyIterator()
|
val matteryPlayer = matteryPlayer
|
||||||
|
|
||||||
val iterators = ArrayList<Iterator<ItemStack>>()
|
val iterators = ArrayList<Iterator<ItemStack>>()
|
||||||
iterators.add(matteryPlayer.wrappedInventory.slotIterator().filter { !it.isForbiddenForAutomation }.map { it.item })
|
iterators.add(matteryPlayer.wrappedInventory.slotIterator().filter { !it.isForbiddenForAutomation }.map { it.item })
|
||||||
|
@ -79,6 +79,8 @@ import ru.dbotthepony.mc.otm.config.ExopackConfig
|
|||||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||||
import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer
|
import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer
|
||||||
import ru.dbotthepony.mc.otm.container.IContainer
|
import ru.dbotthepony.mc.otm.container.IContainer
|
||||||
|
import ru.dbotthepony.mc.otm.container.IContainerSlot
|
||||||
|
import ru.dbotthepony.mc.otm.container.IFilteredContainerSlot
|
||||||
import ru.dbotthepony.mc.otm.container.IMatteryContainer
|
import ru.dbotthepony.mc.otm.container.IMatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.container.get
|
import ru.dbotthepony.mc.otm.container.get
|
||||||
@ -329,6 +331,14 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
override fun clearSlotFilters() {
|
override fun clearSlotFilters() {
|
||||||
regularSlotFilters.forEach { it.accept(null) }
|
regularSlotFilters.forEach { it.accept(null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun containerSlot(slot: Int): IFilteredContainerSlot {
|
||||||
|
return object : IContainerSlot.Simple(slot, this), IFilteredContainerSlot {
|
||||||
|
override var filter: Item?
|
||||||
|
get() = regularSlotFilters.getOrNull(slot)?.get()
|
||||||
|
set(value) { regularSlotFilters.getOrNull(slot)?.accept(value) }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val wrappedItemInventory: IMatteryContainer = object : IMatteryContainer by wrappedInventory {
|
val wrappedItemInventory: IMatteryContainer = object : IMatteryContainer by wrappedInventory {
|
||||||
|
@ -47,7 +47,7 @@ interface IContainerSlot : Delegate<ItemStack> {
|
|||||||
val isNotEmpty: Boolean
|
val isNotEmpty: Boolean
|
||||||
get() = item.isNotEmpty
|
get() = item.isNotEmpty
|
||||||
|
|
||||||
class Simple(private val slot: Int, private val container: Container) : IContainerSlot {
|
open class Simple(protected val slot: Int, protected val container: Container) : IContainerSlot {
|
||||||
override fun setChanged() {
|
override fun setChanged() {
|
||||||
container.setChanged()
|
container.setChanged()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.core.collect.filter
|
|||||||
import ru.dbotthepony.mc.otm.core.collect.map
|
import ru.dbotthepony.mc.otm.core.collect.map
|
||||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||||
|
|
||||||
interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
interface IMatteryContainer : IEnhancedContainer {
|
||||||
fun getSlotFilter(slot: Int): Item?
|
fun getSlotFilter(slot: Int): Item?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +22,6 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
fun clearSlotFilters()
|
fun clearSlotFilters()
|
||||||
|
|
||||||
override fun isEmpty(): Boolean
|
override fun isEmpty(): Boolean
|
||||||
fun setChanged(slot: Int)
|
|
||||||
|
|
||||||
override fun size(): Int {
|
override fun size(): Int {
|
||||||
return containerSize
|
return containerSize
|
||||||
@ -38,7 +37,7 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
/**
|
/**
|
||||||
* Iterates non-empty slots of this container
|
* Iterates non-empty slots of this container
|
||||||
*/
|
*/
|
||||||
fun slotIterator(): Iterator<IContainerSlot> {
|
override fun slotIterator(): Iterator<IFilteredContainerSlot> {
|
||||||
return slotIterator(true)
|
return slotIterator(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
/**
|
/**
|
||||||
* Iterates either non-empty slots of container or all slots of container
|
* Iterates either non-empty slots of container or all slots of container
|
||||||
*/
|
*/
|
||||||
fun slotIterator(nonEmpty: Boolean): Iterator<IContainerSlot> {
|
fun slotIterator(nonEmpty: Boolean): Iterator<IFilteredContainerSlot> {
|
||||||
if (nonEmpty) {
|
if (nonEmpty) {
|
||||||
return (0 until containerSize).iterator().filter { this[it].isNotEmpty }.map { containerSlot(it) }
|
return (0 until containerSize).iterator().filter { this[it].isNotEmpty }.map { containerSlot(it) }
|
||||||
} else {
|
} else {
|
||||||
@ -61,9 +60,7 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun containerSlot(slot: Int): IContainerSlot {
|
override fun containerSlot(slot: Int): IFilteredContainerSlot
|
||||||
return IContainerSlot.Simple(slot, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hasSlotFilter(slot: Int) = getSlotFilter(slot) !== null
|
fun hasSlotFilter(slot: Int) = getSlotFilter(slot) !== null
|
||||||
fun isSlotForbiddenForAutomation(slot: Int) = getSlotFilter(slot) === Items.AIR
|
fun isSlotForbiddenForAutomation(slot: Int) = getSlotFilter(slot) === Items.AIR
|
||||||
@ -80,7 +77,7 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMaxStackSize(slot: Int, itemStack: ItemStack) = maxStackSize.coerceAtMost(itemStack.maxStackSize)
|
override fun getMaxStackSize(slot: Int, itemStack: ItemStack) = maxStackSize.coerceAtMost(itemStack.maxStackSize)
|
||||||
|
|
||||||
private fun addItem(stack: ItemStack, simulate: Boolean, filterPass: Boolean, slots: IntIterable, onlyIntoExisting: Boolean, popTime: Int?, ignoreFilters: Boolean): ItemStack {
|
private fun addItem(stack: ItemStack, simulate: Boolean, filterPass: Boolean, slots: IntIterable, onlyIntoExisting: Boolean, popTime: Int?, ignoreFilters: Boolean): ItemStack {
|
||||||
if (stack.isEmpty)
|
if (stack.isEmpty)
|
||||||
@ -203,14 +200,4 @@ interface IMatteryContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
|
|
||||||
return addItem(stack, false, slots, ignoreFilters).isEmpty
|
return addItem(stack, false, slots, ignoreFilters).isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toList(): MutableList<ItemStack> {
|
|
||||||
val list = ArrayList<ItemStack>(size())
|
|
||||||
|
|
||||||
for (i in 0 until size()) {
|
|
||||||
list.add(this[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return list
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,8 @@ class PainterMenu(
|
|||||||
if (isBulk.value) {
|
if (isBulk.value) {
|
||||||
val found = player.matteryPlayer.inventoryAndExopack
|
val found = player.matteryPlayer.inventoryAndExopack
|
||||||
.slotIterator()
|
.slotIterator()
|
||||||
.filter { !it.isForbiddenForAutomation && ItemStack.isSameItemSameComponents(it.item, inputSlot.item) }
|
//.filter { !it.isForbiddenForAutomation && ItemStack.isSameItemSameComponents(it.item, inputSlot.item) }
|
||||||
|
.filter { ItemStack.isSameItemSameComponents(it.item, inputSlot.item) }
|
||||||
.maybe()
|
.maybe()
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
|
@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
|||||||
import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter
|
import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter
|
||||||
import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter
|
import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter
|
||||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||||
|
import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
|
||||||
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
|
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
|
||||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||||
@ -28,7 +29,7 @@ class MatterBottlerMenu(
|
|||||||
val progressWidget = ProgressGaugeWidget(this)
|
val progressWidget = ProgressGaugeWidget(this)
|
||||||
val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter))
|
val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter))
|
||||||
|
|
||||||
val storageSlots: ImmutableList<MatterySlot> = makeSlots(CombinedContainer(tile?.bottling ?: SimpleContainer(3), tile?.unbottling ?: SimpleContainer(3))) { it, index ->
|
val storageSlots: ImmutableList<MatterySlot> = makeSlots(CombinedContainer(tile?.bottling ?: SlottedContainer.simple(3), tile?.unbottling ?: SlottedContainer.simple(3))) { it, index ->
|
||||||
object : MatterySlot(it, index) {
|
object : MatterySlot(it, index) {
|
||||||
override fun mayPlace(itemStack: ItemStack): Boolean {
|
override fun mayPlace(itemStack: ItemStack): Boolean {
|
||||||
val cap = itemStack.getCapability(MatteryCapability.MATTER_ITEM) ?: return false
|
val cap = itemStack.getCapability(MatteryCapability.MATTER_ITEM) ?: return false
|
||||||
|
@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
|||||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||||
import net.minecraft.world.SimpleContainer
|
import net.minecraft.world.SimpleContainer
|
||||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||||
|
import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
|
||||||
import ru.dbotthepony.mc.otm.core.immutableList
|
import ru.dbotthepony.mc.otm.core.immutableList
|
||||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||||
import ru.dbotthepony.mc.otm.menu.OutputSlot
|
import ru.dbotthepony.mc.otm.menu.OutputSlot
|
||||||
@ -34,7 +35,7 @@ class MatterReplicatorMenu @JvmOverloads constructor(
|
|||||||
val upgrades = makeUpgradeSlots(3, tile?.upgrades)
|
val upgrades = makeUpgradeSlots(3, tile?.upgrades)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val container = CombinedContainer(tile?.outputContainer ?: SimpleContainer(3), tile?.dustContainer ?: SimpleContainer(2))
|
val container = CombinedContainer(tile?.outputContainer ?: SlottedContainer.simple(3), tile?.dustContainer ?: SlottedContainer.simple(2))
|
||||||
|
|
||||||
storageSlots = immutableList(5) {
|
storageSlots = immutableList(5) {
|
||||||
addStorageSlot(OutputSlot(container, it, onTake = {
|
addStorageSlot(OutputSlot(container, it, onTake = {
|
||||||
|
Loading…
Reference in New Issue
Block a user