More backporting
This commit is contained in:
parent
0bcc078fe9
commit
afe7d698c8
@ -11,7 +11,6 @@ import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.TransientCraftingContainer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.RecipeType
|
||||
@ -28,11 +27,9 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.graph.storage.StorageNode
|
||||
import ru.dbotthepony.mc.otm.graph.storage.StorageGraph
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.container.set
|
||||
import ru.dbotthepony.mc.otm.core.nbt.mapString
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu
|
||||
@ -44,6 +41,8 @@ import kotlin.collections.HashMap
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||
import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer
|
||||
import ru.dbotthepony.mc.otm.container.get
|
||||
import ru.dbotthepony.mc.otm.container.set
|
||||
import ru.dbotthepony.mc.otm.container.util.slotIterator
|
||||
import ru.dbotthepony.mc.otm.core.collect.map
|
||||
import ru.dbotthepony.mc.otm.core.collect.toList
|
||||
|
@ -1,22 +1,113 @@
|
||||
package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
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.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.common.util.INBTSerializable
|
||||
import java.util.function.Predicate
|
||||
|
||||
open class MatteryCraftingContainer(watcher: Runnable, private val width: Int, private val height: Int) : MatteryContainer(watcher, width * height), CraftingContainer {
|
||||
constructor(width: Int, height: Int) : this({}, width, height)
|
||||
final override fun getWidth(): Int {
|
||||
return width
|
||||
object DummyMenu : AbstractContainerMenu(null, 0) {
|
||||
override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
final override fun getHeight(): Int {
|
||||
return height
|
||||
}
|
||||
|
||||
final override fun getItems(): MutableList<ItemStack> {
|
||||
val i = spliterator()
|
||||
val result = ArrayList<ItemStack>(i.estimateSize().toInt())
|
||||
i.forEachRemaining { result.add(it) }
|
||||
return result
|
||||
override fun stillValid(pPlayer: Player): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// урод
|
||||
open class MatteryCraftingContainer private constructor(watcher: Runnable, width: Int, height: Int, private val parent: MatteryContainer) : CraftingContainer(DummyMenu, width, height), IMatteryContainer by parent, INBTSerializable<CompoundTag?> {
|
||||
constructor(width: Int, height: Int) : this({}, width, height)
|
||||
constructor(watcher: Runnable, width: Int, height: Int) : this(watcher, width, height, MatteryContainer(watcher, width * height))
|
||||
|
||||
override fun serializeNBT(): CompoundTag {
|
||||
return parent.serializeNBT()
|
||||
}
|
||||
|
||||
override fun deserializeNBT(nbt: CompoundTag?) {
|
||||
parent.deserializeNBT(nbt)
|
||||
}
|
||||
|
||||
fun deserializeNBT(nbt: Tag?) {
|
||||
parent.deserializeNBT(nbt as? CompoundTag)
|
||||
}
|
||||
|
||||
override fun clearContent() {
|
||||
parent.clearContent()
|
||||
}
|
||||
|
||||
override fun getContainerSize(): Int {
|
||||
return parent.getContainerSize()
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return parent.isEmpty()
|
||||
}
|
||||
|
||||
override fun getItem(p_39332_: Int): ItemStack {
|
||||
return parent.getItem(p_39332_)
|
||||
}
|
||||
|
||||
override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack {
|
||||
return parent.removeItem(p_39334_, p_39335_)
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(p_39344_: Int): ItemStack {
|
||||
return parent.removeItemNoUpdate(p_39344_)
|
||||
}
|
||||
|
||||
override fun setItem(p_39337_: Int, p_39338_: ItemStack) {
|
||||
parent.setItem(p_39337_, p_39338_)
|
||||
}
|
||||
|
||||
override fun setChanged() {
|
||||
parent.setChanged()
|
||||
}
|
||||
|
||||
override fun stillValid(p_39340_: Player): Boolean {
|
||||
return parent.stillValid(p_39340_)
|
||||
}
|
||||
|
||||
override fun fillStackedContents(p_39342_: StackedContents) {
|
||||
parent.fillStackedContents(p_39342_)
|
||||
}
|
||||
|
||||
override fun getMaxStackSize(): Int {
|
||||
return parent.getMaxStackSize()
|
||||
}
|
||||
|
||||
override fun startOpen(p_18955_: Player) {
|
||||
parent.startOpen(p_18955_)
|
||||
}
|
||||
|
||||
override fun stopOpen(p_18954_: Player) {
|
||||
parent.stopOpen(p_18954_)
|
||||
}
|
||||
|
||||
override fun canPlaceItem(p_18952_: Int, p_18953_: ItemStack): Boolean {
|
||||
return parent.canPlaceItem(p_18952_, p_18953_)
|
||||
}
|
||||
|
||||
override fun canTakeItem(p_273520_: Container, p_272681_: Int, p_273702_: ItemStack): Boolean {
|
||||
return parent.canTakeItem(p_273520_, p_272681_, p_273702_)
|
||||
}
|
||||
|
||||
override fun countItem(p_18948_: Item): Int {
|
||||
return parent.countItem(p_18948_)
|
||||
}
|
||||
|
||||
override fun hasAnyOf(p_18950_: MutableSet<Item>): Boolean {
|
||||
return parent.hasAnyOf(p_18950_)
|
||||
}
|
||||
|
||||
override fun hasAnyMatching(p_216875_: Predicate<ItemStack>): Boolean {
|
||||
return parent.hasAnyMatching(p_216875_)
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import net.minecraft.world.entity.player.Player
|
||||
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 {
|
||||
class ShadowCraftingContainer private constructor(private val parent: CraftingContainer, private val shadow: ShadowContainer) : CraftingContainer(DummyMenu, parent.width, parent.height), IContainer by shadow {
|
||||
constructor(parent: CraftingContainer) : this(parent, ShadowContainer(parent))
|
||||
|
||||
override fun fillStackedContents(contents: StackedContents) {
|
||||
for (item in iterator()) {
|
||||
contents.accountStack(item)
|
||||
@ -21,8 +24,40 @@ class ShadowCraftingContainer(private val parent: CraftingContainer) : IContaine
|
||||
return parent.height
|
||||
}
|
||||
|
||||
override fun getItems(): MutableList<ItemStack> {
|
||||
return iterator().toList()
|
||||
override fun clearContent() {
|
||||
shadow.clearContent()
|
||||
}
|
||||
|
||||
override fun getContainerSize(): Int {
|
||||
return shadow.getContainerSize()
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return shadow.isEmpty()
|
||||
}
|
||||
|
||||
override fun getItem(p_39332_: Int): ItemStack {
|
||||
return shadow.getItem(p_39332_)
|
||||
}
|
||||
|
||||
override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack {
|
||||
return shadow.removeItem(p_39334_, p_39335_)
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(p_39344_: Int): ItemStack {
|
||||
return shadow.removeItemNoUpdate(p_39344_)
|
||||
}
|
||||
|
||||
override fun setItem(p_39337_: Int, p_39338_: ItemStack) {
|
||||
shadow.setItem(p_39337_, p_39338_)
|
||||
}
|
||||
|
||||
override fun setChanged() {
|
||||
shadow.setChanged()
|
||||
}
|
||||
|
||||
override fun stillValid(p_39340_: Player): Boolean {
|
||||
return shadow.stillValid(p_39340_)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -39,7 +39,7 @@ import net.minecraft.util.profiling.ProfilerFiller
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.TransientCraftingContainer
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
@ -521,7 +521,7 @@ object MatterManager {
|
||||
height = it.value.ingredients.size.coerceAtLeast(height)
|
||||
}
|
||||
|
||||
val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) {
|
||||
val container = CraftingContainer(object : AbstractContainerMenu(null, 0) {
|
||||
override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
|
||||
init {
|
||||
if (capability.isExopackCraftingUpgraded) {
|
||||
craftingGrid = TransientCraftingContainer(this, 3, 3)
|
||||
craftingGrid = CraftingContainer(this, 3, 3)
|
||||
} else {
|
||||
craftingGrid = TransientCraftingContainer(this, 2, 2)
|
||||
craftingGrid = CraftingContainer(this, 2, 2)
|
||||
}
|
||||
|
||||
val builder = ImmutableList.builder<MatterySlot>()
|
||||
|
Loading…
Reference in New Issue
Block a user