aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/api/items/GT_CoolantCell_Item.java
blob: 723a3eef955a5975afca8cbae0924535cad1f931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gregtech.api.items;

import gregtech.api.GregTech_API;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class GT_CoolantCell_Item
  extends GT_Generic_Item
{
  protected int heatStorage;
  
  public GT_CoolantCell_Item(String aUnlocalized, String aEnglish, int aMaxStore)
  {
    super(aUnlocalized, aEnglish, null);
    this.setMaxStackSize(1);
    this.setMaxDamage(100);
    setNoRepair();
    this.heatStorage = aMaxStore;
    this.setCreativeTab(GregTech_API.TAB_GREGTECH);
  }
  
  protected void setHeatForStack(ItemStack aStack, int aHeat)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null)
    {
      tNBT = new NBTTagCompound();
      aStack.setTagCompound(tNBT);
    }
    tNBT.setInteger("heat", aHeat);
    if (this.heatStorage > 0)
    {
      double var4 = (double)aHeat / (double)this.heatStorage;
      int var6 = (int)(aStack.getMaxDamage() * var4);
      if (var6 >= aStack.getMaxDamage()) {
        var6 = aStack.getMaxDamage() - 1;
      }
      aStack.setItemDamage(var6);
    }
  }
  
  public void addAdditionalToolTips(List aList, ItemStack aStack)
  {
    super.addAdditionalToolTips(aList, aStack);
    aList.add("Stored Heat: " + getHeatOfStack(aStack));
  }
  
  protected static int getHeatOfStack(ItemStack aStack)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null)
    {
      tNBT = new NBTTagCompound();
      aStack.setTagCompound(tNBT);
    }
    return tNBT.getInteger("heat");
  }
}