Nerf batpony blindness. Fixes #58

This commit is contained in:
Sollace 2022-09-18 23:05:28 +02:00
parent fb0e870535
commit 869d900f14
4 changed files with 20 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.client;
import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -56,7 +58,10 @@ public class ClientInteractionManager extends InteractionManager {
SoundManager soundManager = client.getSoundManager();
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1, 1, Random.create(seed)));
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source,
createTicker(100).and(e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS)),
USounds.ENTITY_PLAYER_EARS_RINGING, 0.01F, 2, Random.create(seed)).setFadeIn()
);
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
soundManager.playNextTick(
((BeeEntity)source).hasAngerTime()
@ -78,6 +83,11 @@ public class ClientInteractionManager extends InteractionManager {
});
}
static Predicate<LivingEntity> createTicker(int ticks) {
int[] ticker = new int[] {ticks};
return entity -> ticker[0]-- > 0;
}
@Override
public void openScreen(int type) {
client.execute(() -> {

View file

@ -21,6 +21,13 @@ public class LoopingSoundInstance<T extends Entity> extends FadeOutSoundInstance
this.attenuationType = SoundInstance.AttenuationType.NONE;
}
public LoopingSoundInstance<T> setFadeIn() {
float volume = this.volume;
this.volume = 0.001F;
setTargetVolume(volume);
return this;
}
@Override
protected boolean shouldKeepPlaying() {
if (source.isRemoved() || !shouldPlay.test(source)) {

View file

@ -16,7 +16,7 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.world.LightType;
public class SunBlindnessStatusEffect extends StatusEffect {
public static final int MAX_DURATION = 50;
public static final int MAX_DURATION = 250;
SunBlindnessStatusEffect(int color) {
super(StatusEffectCategory.NEUTRAL, color);

View file

@ -364,8 +364,8 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
if (ticksInSun == 1) {
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false));
if (!isClient()) {
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false));
UCriteria.LOOK_INTO_SUN.trigger(entity);
} else if (isClientPlayer()) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, getEntity().getId());