Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1. package melonslise.runicinscription.common.inventory;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.inventory.IInventory;
  5. import net.minecraft.item.ItemStack;
  6.  
  7. public class InventoryRuneInscription implements IInventory
  8. {
  9.     private ItemStack[] inventory = new ItemStack[2];
  10.     private String name = "Rune Inscription";
  11.    
  12.     public InventoryRuneInscription()
  13.     {
  14.        
  15.     }
  16.    
  17.     @Override
  18.     public int getSizeInventory()
  19.     {
  20.         return inventory.length;
  21.     }
  22.  
  23.     @Override
  24.     public ItemStack getStackInSlot(int slot)
  25.     {
  26.         return inventory[slot];
  27.     }
  28.  
  29.     @Override
  30.     public ItemStack decrStackSize(int slot, int amount)
  31.     {
  32.         ItemStack itemStack = getStackInSlot(slot);
  33.        
  34.         if(itemStack != null)
  35.         {
  36.             if(itemStack.stackSize > amount)
  37.             {
  38.                 itemStack = itemStack.splitStack(amount);
  39.             }
  40.             else
  41.             {
  42.                 setInventorySlotContents(slot, null);
  43.             }
  44.         }
  45.        
  46.         return itemStack;
  47.     }
  48.  
  49.     @Override
  50.     public ItemStack getStackInSlotOnClosing(int slot)
  51.     {
  52.         ItemStack itemStack = getStackInSlot(slot);
  53.         setInventorySlotContents(slot, null);
  54.         return itemStack;
  55.     }
  56.  
  57.     @Override
  58.     public void setInventorySlotContents(int slot, ItemStack itemStack)
  59.     {
  60.         inventory[slot] = itemStack;
  61.  
  62.         if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
  63.         {
  64.             itemStack.stackSize = getInventoryStackLimit();
  65.         }
  66.     }
  67.  
  68.     @Override
  69.     public String getInventoryName()
  70.     {
  71.         return this.name;
  72.     }
  73.  
  74.     @Override
  75.     public boolean hasCustomInventoryName()
  76.     {
  77.         return name.length() > 0;
  78.     }
  79.  
  80.     @Override
  81.     public int getInventoryStackLimit()
  82.     {
  83.         return 1;
  84.     }
  85.  
  86.     @Override
  87.     public void markDirty()
  88.     {
  89.        
  90.     }
  91.  
  92.     @Override
  93.     public boolean isUseableByPlayer(EntityPlayer player)
  94.     {
  95.         return true;
  96.     }
  97.  
  98.     @Override
  99.     public void openInventory()
  100.     {
  101.        
  102.     }
  103.  
  104.     @Override
  105.     public void closeInventory()
  106.     {
  107.        
  108.     }
  109.  
  110.     @Override
  111.     public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
  112.     {
  113.         return true;
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement