mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Avoid breaking the alicorn amulet, rather just remove its effects when its fully degraded
This commit is contained in:
parent
0338348f9d
commit
a8d5e45f0e
3 changed files with 12 additions and 2 deletions
|
@ -463,7 +463,12 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getWorld().random.nextInt(damageInterval) == 0) {
|
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()) {
|
if (!getFlightType().canFly()) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class AmuletItem extends WearableItem implements ChargeableItem {
|
||||||
return stack.getItem() == this && (!isChargable() || ChargeableItem.getEnergy(stack) > 0);
|
return stack.getItem() == this && (!isChargable() || ChargeableItem.getEnergy(stack) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicable(LivingEntity entity) {
|
public final boolean isApplicable(LivingEntity entity) {
|
||||||
return isApplicable(getForEntity(entity));
|
return isApplicable(getForEntity(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
public int getDefaultCharge() {
|
public int getDefaultCharge() {
|
||||||
return getMaxCharge() / 2;
|
return getMaxCharge() / 2;
|
||||||
|
|
Loading…
Reference in a new issue