Search in sources :

Example 1 with LiminalTravelSound

use of net.ludocrypt.limlib.api.sound.LiminalTravelSound in project Liminal-Library by LudoCrypt.

the class LiminalSoundRegistry method getCurrent.

public static Optional<SoundEvent> getCurrent(ServerWorld from, ServerWorld to) {
    MutableObject<Optional<SoundEvent>> mutableSound = new MutableObject<Optional<SoundEvent>>(Optional.of(SoundEvents.BLOCK_PORTAL_TRAVEL));
    Optional<LiminalTravelSound> toTravelSound = ((DimensionTypeAccess) to.getDimension()).getLiminalEffects().getTravel();
    Optional<LiminalTravelSound> fromTravelSound = ((DimensionTypeAccess) from.getDimension()).getLiminalEffects().getTravel();
    if (fromTravelSound.isPresent()) {
        fromTravelSound.get().hookSound(from, to, mutableSound);
    }
    if (toTravelSound.isPresent()) {
        toTravelSound.get().hookSound(from, to, mutableSound);
    }
    List<LiminalTravelSound> list = Lists.newArrayList(OVERRIDE_TRAVEL_SOUND.iterator());
    Collections.sort(list, (a, b) -> Integer.compare(a == null ? 1000 : a.priority(), b == null ? 1000 : b.priority()));
    for (LiminalTravelSound sound : list) {
        sound.hookSound(from, to, mutableSound);
    }
    return mutableSound.getValue();
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) LiminalTravelSound(net.ludocrypt.limlib.api.sound.LiminalTravelSound) Optional(java.util.Optional) MutableObject(org.apache.commons.lang3.mutable.MutableObject)

Aggregations

Optional (java.util.Optional)1 LiminalTravelSound (net.ludocrypt.limlib.api.sound.LiminalTravelSound)1 SoundEvent (net.minecraft.sound.SoundEvent)1 MutableObject (org.apache.commons.lang3.mutable.MutableObject)1