Fix issue with insanity
This commit is contained in:
@@ -140,22 +140,34 @@ public class PlayerTickHandler {
|
|||||||
}
|
}
|
||||||
if (player.isSleepingLongEnough())
|
if (player.isSleepingLongEnough())
|
||||||
delta += 0.10f;
|
delta += 0.10f;
|
||||||
sanity.setSanity(value + delta);
|
boolean isInsane = insanity > 0;
|
||||||
if (sanity.getSanity() > 0) {
|
if (isInsane) {
|
||||||
sanity.setInsanity(Math.max(0, insanity - 0.15f));
|
if (value + delta <= 0 && delta < 0) {
|
||||||
insanityDamageTicks.remove(player.getUUID());
|
sanity.setInsanity(Math.min(sanity.getMaxSanity(), insanity + Math.abs(delta)));
|
||||||
|
insanity = sanity.getInsanity();
|
||||||
|
}
|
||||||
|
if (delta > 0) {
|
||||||
|
float insanityReduction = delta * 1.0f;
|
||||||
|
sanity.setInsanity(Math.max(0, insanity - insanityReduction));
|
||||||
|
insanity = sanity.getInsanity();
|
||||||
} else {
|
} else {
|
||||||
sanity.setInsanity(Math.min(sanity.getMaxSanity(), insanity + 0.3f));
|
sanity.setSanity(value + delta);
|
||||||
if (sanity.getInsanity() >= sanity.getMaxSanity()) {
|
}
|
||||||
|
if (sanity.getSanity() <= 0 && sanity.getInsanity() >= sanity.getMaxSanity()) {
|
||||||
UUID id = player.getUUID();
|
UUID id = player.getUUID();
|
||||||
int ticks = insanityDamageTicks.getOrDefault(id, 0) + SANITY_TICK_INTERVAL;
|
int ticks = insanityDamageTicks.getOrDefault(id, 0) + SANITY_TICK_INTERVAL;
|
||||||
insanityDamageTicks.put(id, ticks);
|
insanityDamageTicks.put(id, ticks);
|
||||||
|
|
||||||
float damage = 1.0f + (ticks / 100f);
|
float damage = 1.0f + (ticks / 100f);
|
||||||
player.hurt(player.damageSources().magic(), damage);
|
player.hurt(player.damageSources().magic(), damage);
|
||||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 40, 1));
|
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 40, 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sanity.setSanity(value + delta);
|
||||||
|
if (sanity.getSanity() > 0) {
|
||||||
|
sanity.setInsanity(Math.max(0, insanity - 0.15f));
|
||||||
|
insanityDamageTicks.remove(player.getUUID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
float percent = (value / sanity.getMaxSanity()) * 100f;
|
float percent = (value / sanity.getMaxSanity()) * 100f;
|
||||||
if (percent <= 70 && Math.random() < 0.03) {
|
if (percent <= 70 && Math.random() < 0.03) {
|
||||||
|
|||||||
Reference in New Issue
Block a user