Advertisement
TechMage66

ContainerInfuser

Nov 23rd, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.68 KB | None | 0 0
  1. package com.techmage.magetech.inventory;
  2.  
  3. import com.techmage.magetech.item.ItemCrystal;
  4. import com.techmage.magetech.tileentity.TileEntityInfuser;
  5. import cpw.mods.fml.relauncher.Side;
  6. import cpw.mods.fml.relauncher.SideOnly;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.entity.player.InventoryPlayer;
  9. import net.minecraft.inventory.ICrafting;
  10. import net.minecraft.inventory.Slot;
  11. import net.minecraft.item.ItemStack;
  12.  
  13. public class ContainerInfuser extends ContainerMageTech
  14. {
  15.     private TileEntityInfuser tileEntityInfuser;
  16.     private int lastCrushingTime;
  17.     private int lastEssenceAmount;
  18.  
  19.     public ContainerInfuser(InventoryPlayer inventoryPlayer, TileEntityInfuser tileEntityInfuser)
  20.     {
  21.         this.tileEntityInfuser = tileEntityInfuser;
  22.  
  23.         this.addSlotToContainer(new Slot(tileEntityInfuser, 0, 80, 22) { });
  24.         this.addSlotToContainer(new Slot(tileEntityInfuser, 1, 37, 106) { });
  25.         this.addSlotToContainer(new Slot(tileEntityInfuser, 2, 122, 106) { });
  26.         this.addSlotToContainer(new Slot(tileEntityInfuser, 3, 80, 70)
  27.         {
  28.             @Override
  29.             public boolean isItemValid(ItemStack itemStack)
  30.             {
  31.                 return false;
  32.             }
  33.  
  34.         });
  35.  
  36.         // Add the player's inventory slots to the container
  37.         for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
  38.         {
  39.             for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
  40.             {
  41.                 this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
  42.             }
  43.         }
  44.  
  45.         // Add the player's action bar slots to the container
  46.         for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
  47.         {
  48.             this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 216));
  49.         }
  50.     }
  51.  
  52.     public void addCraftingToCrafters(ICrafting iCrafting)
  53.     {
  54.         super.addCraftingToCrafters(iCrafting);
  55.         iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityInfuser.InfusionTime);
  56.         iCrafting.sendProgressBarUpdate(this, 1, this.tileEntityInfuser.CurrentEssence);
  57.     }
  58.  
  59.     public void detectAndSendChanges()
  60.     {
  61.         super.detectAndSendChanges();
  62.  
  63.         for (int i = 0; i < this.crafters.size(); ++i)
  64.         {
  65.             ICrafting icrafting = (ICrafting)this.crafters.get(i);
  66.  
  67.             if (this.lastCrushingTime != this.tileEntityInfuser.InfusionTime)
  68.             {
  69.                 icrafting.sendProgressBarUpdate(this, 0, this.tileEntityInfuser.InfusionTime);
  70.             }
  71.  
  72.             if (this.lastEssenceAmount != this.tileEntityInfuser.CurrentEssence)
  73.             {
  74.                 icrafting.sendProgressBarUpdate(this, 1, this.tileEntityInfuser.CurrentEssence);
  75.             }
  76.         }
  77.  
  78.         this.lastCrushingTime = this.tileEntityInfuser.InfusionTime;
  79.         this.lastEssenceAmount = this.tileEntityInfuser.CurrentEssence;
  80.     }
  81.  
  82.     @SideOnly(Side.CLIENT)
  83.     public void updateProgressBar(int valueType, int updatedValue)
  84.     {
  85.         if (valueType == 0)
  86.         {
  87.             this.tileEntityInfuser.InfusionTime = updatedValue;
  88.         }
  89.  
  90.         if (valueType == 1)
  91.         {
  92.             this.tileEntityInfuser.CurrentEssence = updatedValue;
  93.         }
  94.     }
  95.  
  96.     @Override
  97.     public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
  98.     {
  99.         ItemStack itemStack = null;
  100.  
  101.         return itemStack;
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement