mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fix crash when querying abilities for a slot
This commit is contained in:
parent
b4e6b3a037
commit
b312188171
2 changed files with 3 additions and 2 deletions
|
@ -15,8 +15,8 @@ public interface Abilities {
|
|||
Registry<Ability<?>> REGISTRY = Registries.createSimple(new Identifier("unicopia", "abilities"));
|
||||
|
||||
// unicorn / alicorn
|
||||
Ability<?> TELEPORT = register(new UnicornTeleportAbility(), "teleport", AbilitySlot.SECONDARY);
|
||||
Ability<?> CAST = register(new UnicornCastingAbility(), "cast", AbilitySlot.PRIMARY);
|
||||
Ability<?> TELEPORT = register(new UnicornTeleportAbility(), "teleport", AbilitySlot.SECONDARY);
|
||||
|
||||
// earth / alicorn
|
||||
Ability<?> STOMP = register(new EarthPonyStompAbility(), "stomp", AbilitySlot.PRIMARY);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -177,7 +178,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
|
||||
public Optional<Ability<?>> getAbility() {
|
||||
Race race = player.getSpecies();
|
||||
return Abilities.BY_SLOT.get(slot).stream().filter(a -> a.canUse(race)).findFirst();
|
||||
return Abilities.BY_SLOT.computeIfAbsent(slot, c -> Collections.emptySet()).stream().filter(a -> a.canUse(race)).findFirst();
|
||||
}
|
||||
|
||||
protected synchronized void setActiveAbility(Ability<?> power) {
|
||||
|
|
Loading…
Reference in a new issue