diff --git a/src/main/java/electroblob/wizardry/item/IConjuredItem.java b/src/main/java/electroblob/wizardry/item/IConjuredItem.java index ea2dfb71..7fabc926 100644 --- a/src/main/java/electroblob/wizardry/item/IConjuredItem.java +++ b/src/main/java/electroblob/wizardry/item/IConjuredItem.java @@ -1,5 +1,6 @@ package electroblob.wizardry.item; +import electroblob.wizardry.client.DrawingUtils; import electroblob.wizardry.spell.Spell; import electroblob.wizardry.spell.SpellConjuration; import net.minecraft.entity.EntityLivingBase; @@ -102,6 +103,12 @@ public interface IConjuredItem { return 8; } + /** Returns a blue colour to use for the durability bar for the given stack, so all items that use it as a timer + * have the same colours. */ + static int getTimerBarColour(ItemStack stack){ + return DrawingUtils.mix(0x8bffe0, 0x2ed1e4, (float)stack.getItem().getDurabilityForDisplay(stack)); + } + @SubscribeEvent static void onLivingDropsEvent(LivingDropsEvent event){ // Destroys conjured items if their caster dies. diff --git a/src/main/java/electroblob/wizardry/item/ItemFlamecatcher.java b/src/main/java/electroblob/wizardry/item/ItemFlamecatcher.java index 42e44e1c..0e69a622 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFlamecatcher.java +++ b/src/main/java/electroblob/wizardry/item/ItemFlamecatcher.java @@ -1,6 +1,7 @@ package electroblob.wizardry.item; import electroblob.wizardry.Wizardry; +import electroblob.wizardry.client.DrawingUtils; import electroblob.wizardry.entity.projectile.EntityFlamecatcherArrow; import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.WizardrySounds; @@ -69,6 +70,11 @@ public class ItemFlamecatcher extends ItemBow implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.flamecatcher); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. diff --git a/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java b/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java index c3632dbc..a015fd30 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java @@ -60,6 +60,11 @@ public class ItemFlamingAxe extends ItemAxe implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.flaming_axe); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. diff --git a/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java b/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java index adcb8c32..35ed354b 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java @@ -62,6 +62,11 @@ public class ItemFrostAxe extends ItemAxe implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.frost_axe); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. diff --git a/src/main/java/electroblob/wizardry/item/ItemLightningHammer.java b/src/main/java/electroblob/wizardry/item/ItemLightningHammer.java index 455dc3bf..f8bb19e9 100644 --- a/src/main/java/electroblob/wizardry/item/ItemLightningHammer.java +++ b/src/main/java/electroblob/wizardry/item/ItemLightningHammer.java @@ -68,6 +68,11 @@ public class ItemLightningHammer extends Item implements IConjuredItem { return super.getMaxDamage(stack); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + private float getDamageMultiplier(ItemStack stack){ if(stack.hasTagCompound() && stack.getTagCompound().hasKey(DAMAGE_MULTIPLIER_NBT_KEY)){ return stack.getTagCompound().getFloat(DAMAGE_MULTIPLIER_NBT_KEY); diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java b/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java index afa653b8..ae12a9cb 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java @@ -25,6 +25,11 @@ public class ItemSpectralArmour extends ItemArmor implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.conjure_armour); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + // Overridden to stop the enchantment trick making the name turn blue. @Override public EnumRarity getRarity(ItemStack stack){ diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java b/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java index 2930a583..0bbad2b8 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java @@ -64,6 +64,11 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.conjure_bow); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java b/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java index 3f40556e..b48ae2b2 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java @@ -41,6 +41,11 @@ public class ItemSpectralPickaxe extends ItemPickaxe implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.conjure_pickaxe); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java b/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java index a10764c7..345cac72 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java @@ -56,6 +56,11 @@ public class ItemSpectralSword extends ItemSword implements IConjuredItem { return this.getMaxDamageFromNBT(stack, Spells.conjure_sword); } + @Override + public int getRGBDurabilityForDisplay(ItemStack stack){ + return IConjuredItem.getTimerBarColour(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff.