Give conjured items a blue timer (durability) bar
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user