2015-04-23 16:14:22 +00:00
|
|
|
package gregtech.api.items;
|
|
|
|
|
|
|
|
import gregtech.api.GregTech_API;
|
2015-08-02 11:00:23 +00:00
|
|
|
import ic2.core.util.StackUtil;
|
|
|
|
|
2015-04-23 16:14:22 +00:00
|
|
|
import java.util.List;
|
2015-08-02 11:00:23 +00:00
|
|
|
|
2015-04-23 16:14:22 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2015-08-02 11:00:23 +00:00
|
|
|
import net.minecraft.util.StatCollector;
|
2015-04-23 16:14:22 +00:00
|
|
|
|
|
|
|
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));
|
2015-08-02 11:00:23 +00:00
|
|
|
switch (getControlTagOfStack(aStack))
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line1"));
|
|
|
|
aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line2"));
|
|
|
|
}
|
2015-04-23 16:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected static int getHeatOfStack(ItemStack aStack)
|
|
|
|
{
|
|
|
|
NBTTagCompound tNBT = aStack.getTagCompound();
|
|
|
|
if (tNBT == null)
|
|
|
|
{
|
|
|
|
tNBT = new NBTTagCompound();
|
|
|
|
aStack.setTagCompound(tNBT);
|
|
|
|
}
|
|
|
|
return tNBT.getInteger("heat");
|
|
|
|
}
|
2015-08-02 11:00:23 +00:00
|
|
|
|
|
|
|
public int getControlTagOfStack(ItemStack stack)
|
|
|
|
{
|
|
|
|
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
|
|
|
|
return nbtData.getInteger("tag");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setControlTagOfStack(ItemStack stack, int tag)
|
|
|
|
{
|
|
|
|
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
|
|
|
|
nbtData.setInteger("tag", tag);
|
|
|
|
}
|
|
|
|
|
2015-04-23 16:14:22 +00:00
|
|
|
}
|