Avoid breaking the alicorn amulet, rather just remove its effects when its fully degraded

This commit is contained in:
Sollace 2023-08-30 21:47:20 +01:00
parent 0338348f9d
commit a8d5e45f0e
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 12 additions and 2 deletions

View file

@ -463,7 +463,12 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
}
if (entity.getWorld().random.nextInt(damageInterval) == 0) {
stack.damage(minDamage + entity.getWorld().random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST));
int damageLeft = stack.getMaxDamage() - stack.getDamage();
int damageApplied = Math.min(damageLeft - 1, minDamage + entity.getWorld().random.nextInt(50));
if (damageApplied > 0) {
stack.damage(damageApplied, entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST));
}
}
if (!getFlightType().canFly()) {

View file

@ -85,7 +85,7 @@ public class AmuletItem extends WearableItem implements ChargeableItem {
return stack.getItem() == this && (!isChargable() || ChargeableItem.getEnergy(stack) > 0);
}
public boolean isApplicable(LivingEntity entity) {
public final boolean isApplicable(LivingEntity entity) {
return isApplicable(getForEntity(entity));
}

View file

@ -25,6 +25,11 @@ public class PegasusAmuletItem extends AmuletItem implements ItemTracker.Trackab
}
@Override
public boolean isApplicable(ItemStack stack) {
return stack.getDamage() < stack.getMaxDamage() - 1 && super.isApplicable(stack);
}
@Override
public int getDefaultCharge() {
return getMaxCharge() / 2;