mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Nerf batpony blindness. Fixes #58
This commit is contained in:
parent
fb0e870535
commit
869d900f14
4 changed files with 20 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.client;
|
package com.minelittlepony.unicopia.client;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -56,7 +58,10 @@ public class ClientInteractionManager extends InteractionManager {
|
||||||
SoundManager soundManager = client.getSoundManager();
|
SoundManager soundManager = client.getSoundManager();
|
||||||
|
|
||||||
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
|
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) {
|
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
|
||||||
soundManager.playNextTick(
|
soundManager.playNextTick(
|
||||||
((BeeEntity)source).hasAngerTime()
|
((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
|
@Override
|
||||||
public void openScreen(int type) {
|
public void openScreen(int type) {
|
||||||
client.execute(() -> {
|
client.execute(() -> {
|
||||||
|
|
|
@ -21,6 +21,13 @@ public class LoopingSoundInstance<T extends Entity> extends FadeOutSoundInstance
|
||||||
this.attenuationType = SoundInstance.AttenuationType.NONE;
|
this.attenuationType = SoundInstance.AttenuationType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoopingSoundInstance<T> setFadeIn() {
|
||||||
|
float volume = this.volume;
|
||||||
|
this.volume = 0.001F;
|
||||||
|
setTargetVolume(volume);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldKeepPlaying() {
|
protected boolean shouldKeepPlaying() {
|
||||||
if (source.isRemoved() || !shouldPlay.test(source)) {
|
if (source.isRemoved() || !shouldPlay.test(source)) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.entity.effect.StatusEffects;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
|
|
||||||
public class SunBlindnessStatusEffect extends StatusEffect {
|
public class SunBlindnessStatusEffect extends StatusEffect {
|
||||||
public static final int MAX_DURATION = 50;
|
public static final int MAX_DURATION = 250;
|
||||||
|
|
||||||
SunBlindnessStatusEffect(int color) {
|
SunBlindnessStatusEffect(int color) {
|
||||||
super(StatusEffectCategory.NEUTRAL, color);
|
super(StatusEffectCategory.NEUTRAL, color);
|
||||||
|
|
|
@ -364,8 +364,8 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksInSun == 1) {
|
if (ticksInSun == 1) {
|
||||||
|
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false));
|
||||||
if (!isClient()) {
|
if (!isClient()) {
|
||||||
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false));
|
|
||||||
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
||||||
} else if (isClientPlayer()) {
|
} else if (isClientPlayer()) {
|
||||||
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, getEntity().getId());
|
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, getEntity().getId());
|
||||||
|
|
Loading…
Reference in a new issue