mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
42 lines
1.0 KiB
Java
42 lines
1.0 KiB
Java
package com.hbm.items.machine;
|
|
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
public class ItemFuelRod extends Item {
|
|
|
|
public int lifeTime;
|
|
|
|
public ItemFuelRod(int life) {
|
|
this.lifeTime = life;
|
|
this.canRepair = false;
|
|
}
|
|
|
|
public static void setLifeTime(ItemStack stack, int time) {
|
|
|
|
if(!stack.hasTagCompound())
|
|
stack.stackTagCompound = new NBTTagCompound();
|
|
|
|
stack.stackTagCompound.setInteger("life", time);
|
|
}
|
|
|
|
public static int getLifeTime(ItemStack stack) {
|
|
|
|
if(!stack.hasTagCompound()) {
|
|
stack.stackTagCompound = new NBTTagCompound();
|
|
return 0;
|
|
}
|
|
|
|
return stack.stackTagCompound.getInteger("life");
|
|
}
|
|
|
|
public boolean showDurabilityBar(ItemStack stack) {
|
|
return getDurabilityForDisplay(stack) > 0D;
|
|
}
|
|
|
|
public double getDurabilityForDisplay(ItemStack stack) {
|
|
return (double)getLifeTime(stack) / (double)((ItemFuelRod)stack.getItem()).lifeTime;
|
|
}
|
|
}
|