<commit_before>package crazypants.util;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;

public class InventoryWrapper implements ISidedInventory {

  public static ISidedInventory asSidedInventory(IInventory inv) {
    if(inv == null) {
      return null;
    }
    if(inv instanceof ISidedInventory) {
      return (ISidedInventory) inv;
    }
    return new InventoryWrapper(inv);
  }

  private IInventory inv;
  private int[] slots;

  public InventoryWrapper(IInventory inventory) {
    this.inv = ItemUtil.getInventory(inventory);
    slots = new int[inv.getSizeInventory()];
    for (int i = 0; i < slots.length; i++) {
      slots[i] = i;
    }
  }

  public IInventory getWrappedInv() {
    return inv;
  }

  @Override
  public int getSizeInventory() {
    return inv.getSizeInventory();
  }

  @Override
  public ItemStack getStackInSlot(int slot) {
    return inv.getStackInSlot(slot);
  }

  @Override
  public ItemStack decrStackSize(int slot, int amount) {
    return inv.decrStackSize(slot, amount);
  }

  @Override
  public ItemStack getStackInSlotOnClosing(int slot) {
    return inv.getStackInSlotOnClosing(slot);
  }

  @Override
  public void setInventorySlotContents(int slot, ItemStack itemStack) {
    inv.setInventorySlotContents(slot, itemStack);
  }

  @Override
  public String getInvName() {
    return inv.getInvName();
  }

  @Override
  public boolean isInvNameLocalized() {
    return inv.isInvNameLocalized();
  }

  @Override
  public int getInventoryStackLimit() {
    return inv.getInventoryStackLimit();
  }

  @Override
  public void onInventoryChanged() {
    inv.onInventoryChanged();
  }

  @Override
  public boolean isUseableByPlayer(EntityPlayer entityplayer) {
    return inv.isUseableByPlayer(entityplayer);
  }

  @Override
  public void openChest() {
    inv.openChest();
  }

  @Override
  public void closeChest() {
    inv.closeChest();
  }

  @Override
  public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
    return inv.isItemValidForSlot(slot, itemStack);
  }

  @Override
  public int[] getAccessibleSlotsFromSide(int var1) {
    return slots;
  }

  @Override
  public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
    return isItemValidForSlot(slot, itemStack);
  }

  @Override
  public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
    return true;
  }
}<commit_msg>#484 Crash when inserting into AE interface from dimensional transceiver.<commit_after>package crazypants.util;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;

public class InventoryWrapper implements ISidedInventory {

  public static ISidedInventory asSidedInventory(IInventory inv) {
    if(inv == null) {
      return null;
    }
    if(inv instanceof ISidedInventory) {
      return (ISidedInventory) inv;
    }
    return new InventoryWrapper(inv);
  }

  private IInventory inv;

  public InventoryWrapper(IInventory inventory) {
    this.inv = ItemUtil.getInventory(inventory);
  }

  public IInventory getWrappedInv() {
    return inv;
  }

  @Override
  public int getSizeInventory() {
    return inv.getSizeInventory();
  }

  @Override
  public ItemStack getStackInSlot(int slot) {
    if(slot < 0 || slot >= inv.getSizeInventory()) {
      return null;
    }
    return inv.getStackInSlot(slot);
  }

  @Override
  public ItemStack decrStackSize(int slot, int amount) {
    return inv.decrStackSize(slot, amount);
  }

  @Override
  public ItemStack getStackInSlotOnClosing(int slot) {
    return inv.getStackInSlotOnClosing(slot);
  }

  @Override
  public void setInventorySlotContents(int slot, ItemStack itemStack) {
    inv.setInventorySlotContents(slot, itemStack);
  }

  @Override
  public String getInvName() {
    return inv.getInvName();
  }

  @Override
  public boolean isInvNameLocalized() {
    return inv.isInvNameLocalized();
  }

  @Override
  public int getInventoryStackLimit() {
    return inv.getInventoryStackLimit();
  }

  @Override
  public void onInventoryChanged() {
    inv.onInventoryChanged();
  }

  @Override
  public boolean isUseableByPlayer(EntityPlayer entityplayer) {
    return inv.isUseableByPlayer(entityplayer);
  }

  @Override
  public void openChest() {
    inv.openChest();
  }

  @Override
  public void closeChest() {
    inv.closeChest();
  }

  @Override
  public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
    return inv.isItemValidForSlot(slot, itemStack);
  }

  @Override
  public int[] getAccessibleSlotsFromSide(int var1) {
    int[] slots = new int[inv.getSizeInventory()];
    for (int i = 0; i < slots.length; i++) {
      slots[i] = i;
    }
    return slots;
  }

  @Override
  public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
    return isItemValidForSlot(slot, itemStack);
  }

  @Override
  public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
    return true;
  }
}
{'fraction_non_alphanumeric': 0.09442393627355741, 'fraction_numerical': 0.0015543034777540316, 'mean_word_length': 3.815715622076707, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5001985', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1615, 'n_words': 373}