package org.cyclops.cyclopscore.inventory.container;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.ContainerType;

import javax.annotation.Nullable;

/**
 * A container for an inventory.
 * @author rubensworks
 */
public abstract class InventoryContainer extends ContainerExtended {

	protected final IInventory inventory;

	public InventoryContainer(@Nullable ContainerType<?> type, int id, PlayerInventory playerInventory, IInventory inventory) {
		super(type, id, playerInventory);
		this.inventory = inventory;
		assertInventorySize(inventory, getSizeInventory());
		this.inventory.openInventory(playerInventory.player);
	}

	public IInventory getContainerInventory() {
		return inventory;
	}

	@Override
	protected int getSizeInventory() {
		return inventory.getSizeInventory();
	}

	@Override
	public boolean canInteractWith(PlayerEntity player) {
		return this.inventory.isUsableByPlayer(player);
	}

	@Override
	public void onContainerClosed(PlayerEntity player) {
		super.onContainerClosed(player);
		this.inventory.closeInventory(player);
	}
}

@@ -648,16 +648,50 @@
 entory;%0A
+%09%09if (isAssertInventorySize()) %7B%0A%09
 %09%09assert
@@ -736,16 +736,20 @@
 ory());%0A
+%09%09%7D%0A
 %09%09this.i
@@ -800,16 +800,80 @@
 r);%0A%09%7D%0A%0A
+%09protected boolean isAssertInventorySize() %7B%0A%09%09return true;%0A%09%7D%0A%0A
 %09public 

Allow inventory size assertion to be skipped