Advertisement
Mrolas

ContainerShopStop.java

Dec 28th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. package mrolas.muchMoney.common.gui.container;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import mrolas.muchMoney.common.gui.container.slot.SlotCoin;
  6. import mrolas.muchMoney.common.item.Items;
  7. import mrolas.muchMoney.common.tileEntities.TileEntityShopStop;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.entity.player.InventoryPlayer;
  10. import net.minecraft.inventory.Container;
  11. import net.minecraft.inventory.ICrafting;
  12. import net.minecraft.inventory.Slot;
  13. import net.minecraft.item.ItemStack;
  14.  
  15. public class ContainerShopStop
  16.     extends Container
  17. {
  18.     TileEntityShopStop shopStop;
  19.    
  20.     public ContainerShopStop (InventoryPlayer inventory, TileEntityShopStop entity)
  21.     {
  22.         this.shopStop = entity;
  23.        
  24.         //HotBar
  25.         for (int x = 0; x < 9; x++)
  26.         {
  27.             addSlotToContainer(new Slot(inventory, x, 8 + 18*x, 232));
  28.         }
  29.        
  30.         //Player Inventory
  31.         for (int y = 0; y < 3; y++)
  32.         {
  33.             for (int x = 0; x < 9; x++)
  34.             {
  35.                 addSlotToContainer(new Slot(inventory, 9 + x + 9*y, 8 + 18*x, 174 + 18*y));
  36.             }
  37.         }
  38.        
  39.         //Coin Slots
  40.         for (int x = 0; x < 5; x++)
  41.         {
  42.             addSlotToContainer(new SlotCoin(entity, x, 8 + 18*x, 144));
  43.         }
  44.        
  45.         //Item Slot
  46.         addSlotToContainer(new Slot(entity, 5, 125, 144));
  47.     }
  48.    
  49.     @Override
  50.     public boolean canInteractWith(EntityPlayer entityplayer)
  51.     {
  52.         return shopStop.isUseableByPlayer(entityplayer);
  53.     }
  54.  
  55.     public TileEntityShopStop getShopStop()
  56.     {
  57.         return this.shopStop;
  58.     }
  59.    
  60.     @Override
  61.     public ItemStack transferStackInSlot(EntityPlayer player, int i)
  62.     {
  63.         Slot slot = getSlot(i);
  64.        
  65.         if (slot != null && slot.getHasStack())
  66.         {
  67.             ItemStack stack = slot.getStack();
  68.             ItemStack result = stack.copy();
  69.            
  70.             if (i >= 36)
  71.             {
  72.                 if (!mergeItemStack(stack, 0, 36, false))
  73.                 {
  74.                     return null;
  75.                 }
  76.             }
  77.             else if (stack.itemID != Items.coin.itemID || !mergeItemStack(stack, 36, 41, false))
  78.             {
  79.                 return null;
  80.             }
  81.            
  82.             if (stack.stackSize == 0)
  83.             {
  84.                 slot.putStack(null);
  85.             }
  86.             else
  87.             {
  88.                 slot.onSlotChanged();
  89.             }
  90.            
  91.             slot.onPickupFromSlot(player, stack);
  92.            
  93.             return result;
  94.         }
  95.        
  96.         return null;
  97.     }
  98.    
  99.     @Override
  100.     public void addCraftingToCrafters (ICrafting player)
  101.     {
  102.         super.addCraftingToCrafters(player);
  103.     }
  104.    
  105.     @Override
  106.     @SideOnly(Side.CLIENT)
  107.     public void updateProgressBar (int id, int data)
  108.     {
  109.        
  110.     }
  111.    
  112.     @Override
  113.     public void detectAndSendChanges ()
  114.     {
  115.         super.detectAndSendChanges();
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement