diff --git a/src/main/java/kamkeel/npcs/entity/EntityEnergyAbility.java b/src/main/java/kamkeel/npcs/entity/EntityEnergyAbility.java index 7922f7191..d3fac4faf 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityEnergyAbility.java +++ b/src/main/java/kamkeel/npcs/entity/EntityEnergyAbility.java @@ -88,6 +88,15 @@ public abstract class EntityEnergyAbility extends Entity implements IEntityAddit this.chargeDuration = duration; } + /** + * Reset chargeTick back to chargeDuration so the charging timeout + * grace period restarts. Used by items that let the player hold + * a fully-charged orb indefinitely. + */ + public void resetChargeTick() { + this.chargeTick = this.chargeDuration; + } + public float getChargeProgress() { if (chargeDuration <= 0) return 1.0f; return Math.min(1.0f, (float) chargeTick / chargeDuration); diff --git a/src/main/java/noppes/npcs/items/ItemStaff.java b/src/main/java/noppes/npcs/items/ItemStaff.java index 5ce50d011..5dc674b30 100644 --- a/src/main/java/noppes/npcs/items/ItemStaff.java +++ b/src/main/java/noppes/npcs/items/ItemStaff.java @@ -91,6 +91,19 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback { int chargeTime = 20 + material.getHarvestLevel() * 8; + // Keep a fully-charged orb alive while the player is still holding + if (tick > chargeTime && stack.stackTagCompound != null) { + Entity existing = ((WorldServer) player.worldObj) + .getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); + if (existing instanceof EntityAbilityOrb) { + EntityAbilityOrb orb = (EntityAbilityOrb) existing; + if (orb.isCharging()) { + orb.resetChargeTick(); + } + } + return; + } + if (tick == chargeTime) { if (!player.capabilities.isCreativeMode && !hasInfinite(stack)) {