package ru.dbotthepony.mc.otm.container

import net.minecraft.world.Container
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import java.util.function.Predicate
import java.util.function.Supplier

/**
 * because mods tend to do crazy shit
 */
class DynamicallyProxiedContainer(private val toProxy: Supplier<Container>) : IContainer {
	override fun clearContent() {
		return toProxy.get().clearContent()
	}

	override fun getContainerSize(): Int {
		return toProxy.get().containerSize
	}

	override fun isEmpty(): Boolean {
		return toProxy.get().isEmpty
	}

	override fun getItem(slot: Int): ItemStack {
		return toProxy.get().getItem(slot)
	}

	override fun removeItem(slot: Int, amount: Int): ItemStack {
		return toProxy.get().removeItem(slot, amount)
	}

	override fun removeItemNoUpdate(slot: Int): ItemStack {
		return toProxy.get().removeItemNoUpdate(slot)
	}

	override fun setItem(slot: Int, itemStack: ItemStack) {
		return toProxy.get().setItem(slot, itemStack)
	}

	override fun setChanged() {
		return toProxy.get().setChanged()
	}

	override fun stillValid(player: Player): Boolean {
		return toProxy.get().stillValid(player)
	}

	override fun getMaxStackSize(): Int {
		return toProxy.get().getMaxStackSize()
	}

	override fun startOpen(player: Player) {
		toProxy.get().startOpen(player)
	}

	override fun stopOpen(player: Player) {
		toProxy.get().stopOpen(player)
	}

	override fun canPlaceItem(slot: Int, itemStack: ItemStack): Boolean {
		return toProxy.get().canPlaceItem(slot, itemStack)
	}

	override fun countItem(item: Item): Int {
		return toProxy.get().countItem(item)
	}

	override fun hasAnyOf(items: Set<Item>): Boolean {
		return toProxy.get().hasAnyOf(items)
	}

	override fun hasAnyMatching(predicate: Predicate<ItemStack>): Boolean {
		return toProxy.get().hasAnyMatching(predicate)
	}
}
