Guest User

Untitled

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