Fix durability bars
This commit is contained in:
parent
e845332846
commit
11fe41c654
|
@ -14,6 +14,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -72,7 +73,7 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro
|
|||
{
|
||||
stack.getTagCompound().setInteger(Constants.NBT.USES, --uses);
|
||||
if (uses <= 0)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -83,18 +84,25 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro
|
|||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
return stack.hasTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
int uses = stack.getTagCompound().getInteger(Constants.NBT.USES);
|
||||
|
||||
return 1.0 - ((double) uses / (double) 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
int uses = stack.getTagCompound().getInteger(Constants.NBT.USES);
|
||||
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)(uses) / 10) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean advanced)
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -145,6 +146,19 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
return 1.0 - (getWill(type, stack) / maxWill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double maxWill = getMaxWill(type, stack);
|
||||
if (maxWill <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)(getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue