mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Staff Charging Fix
This commit is contained in:
1 parent
fed82bc932
commit
38df157c40
2 files changed
+22
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in new issue
Block a user