Fixed aura cache not having a durability bar

This commit is contained in:
Ell 2021-12-23 13:24:02 +01:00
parent 75948872b7
commit 6a9f3675af

View file

@ -85,14 +85,20 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
} }
@Override @Override
public int getBarColor(ItemStack stack) { public int getBarWidth(ItemStack stack) {
if (stack.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) { if (stack.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) {
var container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); var container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
return (int) (1 - container.getStoredAura() / (double) container.getMaxAura()); return Math.round((container.getStoredAura() / (float) container.getMaxAura()) * 13);
} }
return 0; return 0;
} }
@Override
public int getBarColor(ItemStack stack) {
var cap = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
return cap != null ? cap.getAuraColor() : super.getBarColor(stack);
}
@Nullable @Nullable
@Override @Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {