Fixed network items having a green durability bar all the time
This commit is contained in:
@@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
@@ -92,6 +93,13 @@ public abstract class ItemNetworkItem extends ItemBase implements INetworkItemPr
|
|||||||
return 1D - ((double) energy.getEnergyStored() / (double) energy.getMaxEnergyStored());
|
return 1D - ((double) energy.getEnergyStored() / (double) energy.getMaxEnergyStored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||||
|
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||||
|
|
||||||
|
return MathHelper.hsvToRGB(Math.max(0.0F, (float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored()) / 3.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDamaged(ItemStack stack) {
|
public boolean isDamaged(ItemStack stack) {
|
||||||
return stack.getItemDamage() != TYPE_CREATIVE;
|
return stack.getItemDamage() != TYPE_CREATIVE;
|
||||||
|
|||||||
Reference in New Issue
Block a user