Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CapCompContainer extends Container {
- private int containerID;
- private int containerInd;
- private IInventory containerInv;
- private int numRows;
- @OnlyIn(Dist.CLIENT)
- public int getInvInd() {
- return this.containerInd;
- }
- public IInventory getInv() {
- return this.containerInv;
- }
- public int getID() {
- return this.containerID;
- }
- @OnlyIn(Dist.CLIENT)
- public int getNumRows() {
- return this.numRows;
- }
- public CapCompContainer(ContainerType<?> type, int id, int ind, PlayerInventory player, int rows) {
- this(type, id, ind, player, new Inventory[]{
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows),
- new Inventory(9 * rows)
- }, rows);
- this.containerInv = new Inventory(9 * rows);
- this.containerID = id;
- this.containerInd = ind;
- this.numRows = rows;
- }
- public static CapCompContainer createMulti9X3(int id, PlayerInventory player) {
- return new CapCompContainer(ModContainerTypes.MULTI_9X3.get(), id, 0, player, 3);
- }
- public CapCompContainer(ContainerType<?> type, int id, int ind, PlayerInventory playerInventoryIn, IInventory[] p_i50092_4_, int rows) {
- super(type, id);
- this.containerID = id;
- this.containerInd = ind;
- this.containerInv = p_i50092_4_[ind];
- assertInventorySize(p_i50092_4_[ind], rows * 9);
- this.numRows = rows;
- p_i50092_4_[ind].openInventory(playerInventoryIn.player);
- int i = (this.numRows - 4) * 18;
- for(int j = 0; j < this.numRows; ++j) {
- for(int k = 0; k < 9; ++k) {
- this.addSlot(new Slot(p_i50092_4_[ind], k + j * 9, 8 + k * 18, 19 + j * 18));
- }
- }
- for(int l = 0; l < 3; ++l) {
- for(int j1 = 0; j1 < 9; ++j1) {
- this.addSlot(new Slot(playerInventoryIn, j1 + l * 9 + 9, 8 + j1 * 18, 122 + l * 18 + i));
- }
- }
- for(int i1 = 0; i1 < 9; ++i1) {
- this.addSlot(new Slot(playerInventoryIn, i1, 8 + i1 * 18, 180 + i));
- }
- }
- public boolean canInteractWith(PlayerEntity playerIn) {
- return this.containerInv.isUsableByPlayer(playerIn);
- }
- public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
- ItemStack itemstack = ItemStack.EMPTY;
- Slot slot = this.inventorySlots.get(index);
- if (slot != null && slot.getHasStack()) {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if (index < this.numRows * 9) {
- if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) {
- return ItemStack.EMPTY;
- }
- } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) {
- return ItemStack.EMPTY;
- }
- if (itemstack1.isEmpty()) {
- slot.putStack(ItemStack.EMPTY);
- } else {
- slot.onSlotChanged();
- }
- }
- return itemstack;
- }
- public void onContainerClosed(PlayerEntity playerIn) {
- super.onContainerClosed(playerIn);
- this.containerInv.closeInventory(playerIn);
- }
- }
RAW Paste Data