Skip to content

Commit

Permalink
simplify mana component
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed May 20, 2024
1 parent 8942166 commit 90ee2c4
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public ManaComponent(LivingEntity entity) {
public void serverTick() {
EntityAttributeInstance manaRegenAttr = entity.getAttributeInstance(ArcanusEntityAttributes.MANA_REGEN.get());

if (manaRegenAttr != null && addMana(manaRegenAttr.getValue(), true))
if(manaRegenAttr != null) {
addMana(manaRegenAttr.getValue() / (entity instanceof PlayerEntity player && player.isCreative() ? 1 : 20), false);
}
}

@Override
Expand All @@ -42,9 +43,7 @@ public double getMana() {

public void setMana(double mana) {
this.mana = MathHelper.clamp(mana, 0, getTrueMaxMana());

if (entity instanceof PlayerEntity)
ArcanusComponents.MANA_COMPONENT.sync(entity);
ArcanusComponents.MANA_COMPONENT.sync(entity);
}

public double getTrueMaxMana() {
Expand Down Expand Up @@ -72,14 +71,11 @@ public double getManaLock() {
public boolean addMana(double amount, boolean simulate) {
if (getMana() < getTrueMaxMana()) {
if (!simulate)
setMana(Math.min(getTrueMaxMana(), getMana() + amount));
setMana(getMana() + amount);

return true;
}

if (getMana() > getTrueMaxMana())
setMana(getTrueMaxMana());

return false;
}

Expand Down

0 comments on commit 90ee2c4

Please sign in to comment.