diff --git a/src/main/java/com/minelittlepony/unicopia/Affinity.java b/src/main/java/com/minelittlepony/unicopia/Affinity.java index 35285a76..fb34045a 100644 --- a/src/main/java/com/minelittlepony/unicopia/Affinity.java +++ b/src/main/java/com/minelittlepony/unicopia/Affinity.java @@ -1,12 +1,17 @@ package com.minelittlepony.unicopia; -import net.minecraft.util.Formatting; +import java.util.Locale; -public enum Affinity { +import net.minecraft.util.Formatting; +import net.minecraft.util.StringIdentifiable; + +public enum Affinity implements StringIdentifiable { GOOD(Formatting.BLUE, -1, 0), NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F), BAD(Formatting.RED, 1, 1); + public static final Codec CODEC = StringIdentifiable.createCodec(Affinity::values); + private final Formatting color; private final int corruption; @@ -20,6 +25,11 @@ public enum Affinity { this.alignment = alignment; } + @Override + public String asString() { + return name().toLowerCase(Locale.ROOT); + } + public Formatting getColor() { return color; } diff --git a/src/main/java/com/minelittlepony/unicopia/Availability.java b/src/main/java/com/minelittlepony/unicopia/Availability.java index f24497a3..a8df720a 100644 --- a/src/main/java/com/minelittlepony/unicopia/Availability.java +++ b/src/main/java/com/minelittlepony/unicopia/Availability.java @@ -1,10 +1,23 @@ package com.minelittlepony.unicopia; -public enum Availability { +import java.util.Locale; + +import net.minecraft.util.StringIdentifiable; + +public enum Availability implements StringIdentifiable { DEFAULT, COMMANDS, NONE; + public static final Codec CODEC = StringIdentifiable.createCodec(Availability::values); + + private final String name = name().toLowerCase(Locale.ROOT); + + @Override + public String asString() { + return name; + } + public boolean isSelectable() { return this == DEFAULT; } diff --git a/src/main/java/com/minelittlepony/unicopia/FlightType.java b/src/main/java/com/minelittlepony/unicopia/FlightType.java index f2ef92f0..9faca7f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/FlightType.java +++ b/src/main/java/com/minelittlepony/unicopia/FlightType.java @@ -1,15 +1,27 @@ package com.minelittlepony.unicopia; +import java.util.Locale; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvent; +import net.minecraft.util.StringIdentifiable; -public enum FlightType { +public enum FlightType implements StringIdentifiable { UNSET, NONE, AVIAN, INSECTOID, ARTIFICIAL; + public static final Codec CODEC = StringIdentifiable.createCodec(FlightType::values); + + private final String name = name().toLowerCase(Locale.ROOT); + + @Override + public String asString() { + return name; + } + public boolean isGrounded() { return this == NONE; } diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index dd3bf4d9..9e06f047 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -1,20 +1,21 @@ package com.minelittlepony.unicopia; import java.util.*; +import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.stream.Collectors; import org.jetbrains.annotations.Nullable; -import org.spongepowered.include.com.google.common.base.Objects; - import com.google.common.base.Strings; -import com.google.common.base.Suppliers; +import com.minelittlepony.unicopia.ability.Abilities; +import com.minelittlepony.unicopia.ability.Ability; import com.minelittlepony.unicopia.ability.magic.Affine; import com.minelittlepony.unicopia.util.RegistryUtils; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.command.argument.RegistryKeyArgumentType; import net.minecraft.entity.player.PlayerEntity; @@ -22,52 +23,89 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; -public record Race (Supplier compositeSupplier, Availability availability, boolean canCast, FlightType flightType, boolean canUseEarth, boolean isNocturnal, boolean canHang) implements Affine { +public record Race ( + List> abilities, + Affinity affinity, + Availability availability, + FlightType flightType, + boolean canCast, + boolean hasIronGut, + boolean canUseEarth, + boolean isNocturnal, + boolean canHang, + boolean isFish, + boolean canInfluenceWeather, + boolean canInteractWithClouds + ) implements Affine { public static final String DEFAULT_ID = "unicopia:unset"; public static final Registry REGISTRY = RegistryUtils.createDefaulted(Unicopia.id("race"), DEFAULT_ID); public static final Registry COMMAND_REGISTRY = RegistryUtils.createDefaulted(Unicopia.id("race/grantable"), DEFAULT_ID); public static final RegistryKey> REGISTRY_KEY = REGISTRY.getKey(); private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> Text.translatable("race.unknown", id)); + private static final Function COMPOSITES = Util.memoize(race -> new Composite(race, null, null)); - public static Race register(String name, Availability availability, boolean magic, FlightType flight, boolean earth, boolean nocturnal, boolean canHang) { - return register(Unicopia.id(name), availability, magic, flight, earth, nocturnal, canHang); - } - - public static Race register(Identifier id, Availability availability, boolean magic, FlightType flight, boolean earth, boolean nocturnal, boolean canHang) { - Race race = Registry.register(REGISTRY, id, new Race(Suppliers.memoize(() -> new Composite(REGISTRY.get(id), null, null)), availability, magic, flight, earth, nocturnal, canHang)); - if (availability.isGrantable()) { - Registry.register(COMMAND_REGISTRY, id, race); - } - return race; - } - - public static RegistryKeyArgumentType argument() { - return RegistryKeyArgumentType.registryKey(COMMAND_REGISTRY.getKey()); - } + public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( + Abilities.REGISTRY.getCodec().listOf().fieldOf("abilities").forGetter(Race::abilities), + Affinity.CODEC.fieldOf("affinity").forGetter(Race::affinity), + Availability.CODEC.fieldOf("availability").forGetter(Race::availability), + FlightType.CODEC.fieldOf("flight").forGetter(Race::flightType), + Codec.BOOL.fieldOf("magic").forGetter(Race::canCast), + Codec.BOOL.fieldOf("can_forage").forGetter(Race::hasIronGut), + Codec.BOOL.fieldOf("earth_pony_strength").forGetter(Race::canUseEarth), + Codec.BOOL.fieldOf("nocturnal").forGetter(Race::isNocturnal), + Codec.BOOL.fieldOf("hanging").forGetter(Race::canHang), + Codec.BOOL.fieldOf("aquatic").forGetter(Race::isFish), + Codec.BOOL.fieldOf("weather_magic").forGetter(Race::canInfluenceWeather), + Codec.BOOL.fieldOf("cloud_magic").forGetter(Race::canInteractWithClouds) + ).apply(i, Race::new)); /** * The default, unset race. * This is used if there are no other races. */ - public static final Race UNSET = register("unset", Availability.COMMANDS, false, FlightType.NONE, false, false, false); - public static final Race HUMAN = register("human", Availability.COMMANDS, false, FlightType.NONE, false, false, false); - public static final Race EARTH = register("earth", Availability.DEFAULT, false, FlightType.NONE, true, false, false); - public static final Race UNICORN = register("unicorn", Availability.DEFAULT, true, FlightType.NONE, false, false, false); - public static final Race PEGASUS = register("pegasus", Availability.DEFAULT, false, FlightType.AVIAN, false, false, false); - public static final Race BAT = register("bat", Availability.DEFAULT, false, FlightType.AVIAN, false, true, true); - public static final Race ALICORN = register("alicorn", Availability.COMMANDS, true, FlightType.AVIAN, true, false, false); - public static final Race CHANGELING = register("changeling", Availability.DEFAULT, false, FlightType.INSECTOID, false, false, true); - public static final Race KIRIN = register("kirin", Availability.DEFAULT, true, FlightType.NONE, false, false, false); - public static final Race HIPPOGRIFF = register("hippogriff", Availability.DEFAULT, false, FlightType.AVIAN, false, false, false); - public static final Race SEAPONY = register("seapony", Availability.NONE, false, FlightType.NONE, false, false, false); + public static final Race UNSET = register("unset", new Builder().availability(Availability.COMMANDS)); + public static final Race HUMAN = register("human", new Builder().availability(Availability.COMMANDS)); + public static final Race EARTH = register("earth", new Builder().foraging().earth() + .abilities(Abilities.HUG, Abilities.STOMP, Abilities.KICK, Abilities.GROW) + ); + public static final Race UNICORN = register("unicorn", new Builder().foraging().magic() + .abilities(Abilities.TELEPORT, Abilities.GROUP_TELEPORT, Abilities.SHOOT, Abilities.DISPELL) + ); + public static final Race PEGASUS = register("pegasus", new Builder().foraging().flight(FlightType.AVIAN).weatherMagic().cloudMagic() + .abilities(Abilities.TOGGLE_FLIGHT, Abilities.RAINBOOM, Abilities.CAPTURE_CLOUD, Abilities.CARRY) + ); + public static final Race BAT = register("bat", new Builder().foraging().flight(FlightType.AVIAN).canHang().cloudMagic() + .abilities(Abilities.TOGGLE_FLIGHT, Abilities.CARRY, Abilities.HANG, Abilities.EEEE) + ); + public static final Race ALICORN = register("alicorn", new Builder().foraging().availability(Availability.COMMANDS).flight(FlightType.AVIAN).earth().magic().weatherMagic().cloudMagic() + .abilities( + Abilities.TELEPORT, Abilities.GROUP_TELEPORT, Abilities.SHOOT, Abilities.DISPELL, + Abilities.TOGGLE_FLIGHT, Abilities.RAINBOOM, Abilities.CAPTURE_CLOUD, Abilities.CARRY, + Abilities.HUG, Abilities.STOMP, Abilities.KICK, Abilities.GROW, + Abilities.TIME + ) + ); + public static final Race CHANGELING = register("changeling", new Builder().foraging().affinity(Affinity.BAD).flight(FlightType.INSECTOID).canHang() + .abilities(Abilities.DISPELL, Abilities.TOGGLE_FLIGHT, Abilities.FEED, Abilities.DISGUISE, Abilities.CARRY) + ); + public static final Race KIRIN = register("kirin", new Builder().foraging().magic() + .abilities(Abilities.DISPELL, Abilities.RAGE, Abilities.NIRIK_BLAST, Abilities.KIRIN_CAST) + ); + public static final Race HIPPOGRIFF = register("hippogriff", new Builder().foraging().flight(FlightType.AVIAN).cloudMagic() + .abilities(Abilities.TOGGLE_FLIGHT, Abilities.SCREECH, Abilities.PECK, Abilities.DASH, Abilities.CARRY) + ); + public static final Race SEAPONY = register("seapony", new Builder().foraging().fish() + .abilities(Abilities.SONAR_PULSE) + ); public static void bootstrap() {} public Composite composite() { - return compositeSupplier.get(); + return COMPOSITES.apply(this); } public Composite composite(@Nullable Race pseudo, @Nullable Race potential) { @@ -76,11 +114,7 @@ public record Race (Supplier compositeSupplier, Availability availabi @Override public Affinity getAffinity() { - return this == CHANGELING ? Affinity.BAD : Affinity.NEUTRAL; - } - - public boolean hasIronGut() { - return !isHuman(); + return affinity; } public boolean isUnset() { @@ -91,12 +125,8 @@ public record Race (Supplier compositeSupplier, Availability availabi return !isHuman(); } - public boolean isFish() { - return this == SEAPONY; - } - public boolean isHuman() { - return this == UNSET || this == HUMAN; + return isUnset() || this == HUMAN; } public boolean isDayurnal() { @@ -107,18 +137,14 @@ public record Race (Supplier compositeSupplier, Availability availabi return !flightType().isGrounded(); } - public boolean canInteractWithClouds() { - return canFly() && this != CHANGELING; - } - - public boolean canInfluenceWeather() { - return canFly() && this != CHANGELING && this != BAT && this != HIPPOGRIFF; - } - public boolean hasPersistentWeatherMagic() { return canInfluenceWeather(); } + public boolean canUse(Ability ability) { + return abilities.contains(ability); + } + public Identifier getId() { return REGISTRY.getId(this); } @@ -132,13 +158,11 @@ public record Race (Supplier compositeSupplier, Availability availabi } public String getTranslationKey() { - Identifier id = getId(); - return String.format("%s.race.%s", id.getNamespace(), id.getPath().toLowerCase()); + return Util.createTranslationKey("race", getId()); } public Identifier getIcon() { - Identifier id = getId(); - return new Identifier(id.getNamespace(), "textures/gui/race/" + id.getPath() + ".png"); + return getId().withPath(p -> "textures/gui/race/" + p + ".png"); } public boolean isPermitted(@Nullable PlayerEntity sender) { @@ -161,16 +185,6 @@ public record Race (Supplier compositeSupplier, Availability availabi return isEquine() ? this : other; } - @Override - public int hashCode() { - return getId().hashCode(); - } - - @Override - public boolean equals(Object o) { - return o instanceof Race race && Objects.equal(race.getId(), getId()); - } - @Override public String toString() { return "Race{ " + getId().toString() + " }"; @@ -195,8 +209,20 @@ public record Race (Supplier compositeSupplier, Availability availabi return def; } - public static Race fromName(String name) { - return fromName(name, EARTH); + public static Race register(String name, Builder builder) { + return register(Unicopia.id(name), builder); + } + + public static Race register(Identifier id, Builder builder) { + Race race = Registry.register(REGISTRY, id, builder.build()); + if (race.availability().isGrantable()) { + Registry.register(COMMAND_REGISTRY, id, race); + } + return race; + } + + public static RegistryKeyArgumentType argument() { + return RegistryKeyArgumentType.registryKey(COMMAND_REGISTRY.getKey()); } public static Race fromArgument(CommandContext context, String name) throws CommandSyntaxException { @@ -233,6 +259,10 @@ public record Race (Supplier compositeSupplier, Availability availabi return any(Race::canCast); } + public boolean canUse(Ability ability) { + return any(r -> r.canUse(ability)); + } + public boolean canInteractWithClouds() { return any(Race::canInteractWithClouds); } @@ -252,6 +282,85 @@ public record Race (Supplier compositeSupplier, Availability availabi return physical().flightType().or(pseudo().flightType()); } } + + public static final class Builder { + private final List> abilities = new ArrayList<>(); + private Affinity affinity = Affinity.NEUTRAL; + private Availability availability = Availability.DEFAULT; + private boolean canCast; + private boolean hasIronGut; + private FlightType flightType = FlightType.NONE; + private boolean canUseEarth; + private boolean isNocturnal; + private boolean canHang; + private boolean isFish; + private boolean canInfluenceWeather; + private boolean canInteractWithClouds; + + public Builder abilities(Ability...abilities) { + this.abilities.addAll(List.of(abilities)); + return this; + } + + public Builder foraging() { + hasIronGut = true; + return this; + } + + public Builder affinity(Affinity affinity) { + this.affinity = affinity; + return this; + } + + public Builder availability(Availability availability) { + this.availability = availability; + return this; + } + + public Builder flight(FlightType flight) { + flightType = flight; + return this; + } + + public Builder magic() { + canCast = true; + return this; + } + + public Builder earth() { + canUseEarth = true; + return this; + } + + public Builder nocturnal() { + isNocturnal = true; + return this; + } + + public Builder canHang() { + canHang = true; + return this; + } + + public Builder fish() { + isFish = true; + return this; + } + + public Builder weatherMagic() { + canInfluenceWeather = true; + return this; + } + + public Builder cloudMagic() { + canInteractWithClouds = true; + return this; + } + + public Race build() { + return new Race(List.copyOf(abilities), affinity, availability, flightType, canCast, hasIronGut, canUseEarth, isNocturnal, canHang, isFish, canInfluenceWeather, canInteractWithClouds); + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index 979d7f97..eaa96379 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -68,7 +68,9 @@ public interface Ability { * Checks if the given race is permitted to use this ability * @param playerSpecies The player's species */ - boolean canUse(Race playerSpecies); + default boolean canUse(Race race) { + return race.canUse(this); + } /** * Called when an ability is about to be triggered. This event occurs on both the client and server so check {@code Pony#isClient} if you need to know which one you're on. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbstractSpellCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/AbstractSpellCastingAbility.java index 2ff33f62..abe2489e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbstractSpellCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbstractSpellCastingAbility.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.ability; -import com.minelittlepony.unicopia.*; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType; import com.minelittlepony.unicopia.entity.player.Pony; @@ -11,17 +10,11 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.TypedActionResult; abstract class AbstractSpellCastingAbility implements Ability { - @Override public int getCooldownTime(Pony player) { return 0; } - @Override - public boolean canUse(Race race) { - return race.canCast() && race != Race.KIRIN; - } - @Override public Text getName(Pony player) { CustomisedSpellType spell = player.getCharms().getEquippedSpell(player.getCharms().getHand()); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java index 867f67ae..826f29a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.ability; import com.minelittlepony.unicopia.AwaitTickQueue; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.entity.damage.UDamageTypes; @@ -16,11 +15,6 @@ import net.minecraft.world.event.GameEvent; public class BatEeeeAbility extends ScreechAbility { public static final int SELF_SPOOK_PROBABILITY = 20000; - @Override - public boolean canUse(Race race) { - return race == Race.BAT; - } - @Override protected void playSounds(Pony player, Random rng, float strength) { int count = 1 + rng.nextInt(10) + (int)(strength * 10); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java index 9237ab34..723cc0f5 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java @@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Multi; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.TraceHelper; @@ -30,11 +29,6 @@ public class BatPonyHangAbility implements Ability { return 0; } - @Override - public boolean canUse(Race race) { - return race == Race.BAT; - } - @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index e93d1c2a..844fd96f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -6,7 +6,6 @@ import java.util.UUID; import java.util.stream.StreamSupport; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; @@ -37,11 +36,6 @@ public class CarryAbility implements Ability { return 0; } - @Override - public boolean canUse(Race race) { - return race.canFly(); - } - @Override public Optional prepare(Pony player) { return Hit.INSTANCE; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 7a4e1f76..974f212c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -7,7 +7,6 @@ import java.util.stream.Stream; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.ChangelingFeedingSpell; @@ -48,11 +47,6 @@ public class ChangelingFeedAbility implements Ability { return !SpellType.FEED.isOn(player) && ChangelingFeedingSpell.canFeed(player) ? 15 : 80; } - @Override - public boolean canUse(Race race) { - return race == Race.CHANGELING; - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java index 0454681e..744ee4a5 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; import java.util.function.DoubleSupplier; import java.util.function.Supplier; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.ability.data.Hit; @@ -48,11 +47,6 @@ public class EarthPonyGrowAbility implements Ability { return 50; } - @Override - public boolean canUse(Race race) { - return race.canUseEarth(); - } - @Override public Optional prepare(Pony player) { return TraceHelper.findBlock(player.asEntity(), 3, 1).map(Pos::new); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 0affd0cf..62dfda4a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -53,11 +53,6 @@ public class EarthPonyKickAbility implements Ability { return 50; } - @Override - public boolean canUse(Race race) { - return race.canUseEarth(); - } - @Override public Identifier getIcon(Pony player) { return getId().withPath(p -> "textures/gui/ability/" + p diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 285266c9..78314ba7 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -62,11 +62,6 @@ public class EarthPonyStompAbility implements Ability { return 50; } - @Override - public boolean canUse(Race race) { - return race.canUseEarth(); - } - @Override public Identifier getIcon(Pony player) { Identifier id = Abilities.REGISTRY.getId(this); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java index 0a9f5f6b..c9436ce9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java @@ -4,7 +4,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.player.Pony; @@ -23,11 +22,6 @@ public class FlyingDashAbility implements Ability { return 30; } - @Override - public boolean canUse(Race race) { - return race == Race.HIPPOGRIFF; - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/HugAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/HugAbility.java index 6457ccb9..caca424f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/HugAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/HugAbility.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.ability; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; import com.minelittlepony.unicopia.entity.Living; @@ -16,12 +15,6 @@ import net.minecraft.particle.ParticleTypes; * Ability to hug mobs. Not all of them are receptive to your advances though, so be careful! */ public class HugAbility extends CarryAbility { - - @Override - public boolean canUse(Race race) { - return race.canUseEarth(); - } - @Override public boolean apply(Pony pony, Hit data) { PlayerEntity player = pony.asEntity(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/KirinCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/KirinCastingAbility.java index 5b82e4cc..53b2e56c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/KirinCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/KirinCastingAbility.java @@ -1,16 +1,10 @@ package com.minelittlepony.unicopia.ability; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.particle.ParticleTypes; public class KirinCastingAbility extends UnicornCastingAbility { - @Override - public boolean canUse(Race race) { - return race == Race.KIRIN; - } - @Override public void coolDown(Pony player, AbilitySlot slot) { player.spawnParticles(ParticleTypes.FLAME, 5); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/KirinRageAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/KirinRageAbility.java index 92d0074c..dce16e46 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/KirinRageAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/KirinRageAbility.java @@ -4,7 +4,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod; @@ -30,11 +29,6 @@ public class KirinRageAbility implements Ability { return 60; } - @Override - public boolean canUse(Race race) { - return race == Race.KIRIN; - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/NirikBlastAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/NirikBlastAbility.java index 3c516f32..65c6f353 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/NirikBlastAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/NirikBlastAbility.java @@ -5,7 +5,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation.Recipient; @@ -36,11 +35,6 @@ public class NirikBlastAbility implements Ability { return 3; } - @Override - public boolean canUse(Race race) { - return race == Race.KIRIN; - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PeckAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PeckAbility.java index 849dbb4c..db5b09fc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PeckAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PeckAbility.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Numeric; @@ -54,11 +53,6 @@ public class PeckAbility implements Ability { return true; } - @Override - public boolean canUse(Race race) { - return race == Race.HIPPOGRIFF; - } - @Override public Optional prepare(Pony player) { return Hit.INSTANCE; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java index b02579df..6b59dfe4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java @@ -4,7 +4,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; @@ -33,11 +32,6 @@ public class PegasusCaptureStormAbility implements Ability { return 6; } - @Override - public boolean canUse(Race race) { - return race.canInfluenceWeather(); - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java index 606cd65f..c9abd9b6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java @@ -4,7 +4,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; @@ -26,11 +25,6 @@ public class PegasusRainboomAbility implements Ability { return 60; } - @Override - public boolean canUse(Race race) { - return race.canInfluenceWeather(); - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ScreechAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ScreechAbility.java index 60319ba1..55b9c393 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ScreechAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ScreechAbility.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.ability.data.Numeric; @@ -49,11 +48,6 @@ public class ScreechAbility implements Ability { return true; } - @Override - public boolean canUse(Race race) { - return race == Race.HIPPOGRIFF; - } - @Override public Optional prepare(Pony player) { return player.getAbilities().getActiveStat() diff --git a/src/main/java/com/minelittlepony/unicopia/ability/SeaponySonarPulseAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/SeaponySonarPulseAbility.java index 95078776..f1be14f7 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/SeaponySonarPulseAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/SeaponySonarPulseAbility.java @@ -5,7 +5,6 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.AwaitTickQueue; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.UPOIs; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; @@ -38,11 +37,6 @@ public class SeaponySonarPulseAbility implements Ability { return 100; } - @Override - public boolean canUse(Race race) { - return race == Race.SEAPONY; - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java index a1e92a03..b06df709 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java @@ -12,11 +12,6 @@ import com.minelittlepony.unicopia.server.world.UGameRules; public class TimeChangeAbility implements Ability { - @Override - public boolean canUse(Race race) { - return race == Race.ALICORN; - } - @Override public boolean canUse(Race.Composite race) { return canUse(race.physical()) || race.pseudo() == Race.UNICORN; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java index 4f20d77d..caa3c701 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java @@ -24,11 +24,6 @@ public class ToggleFlightAbility implements Ability { return 0; } - @Override - public boolean canUse(Race race) { - return race.canFly(); - } - @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java index d965f9da..7b0c35d6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java @@ -33,11 +33,6 @@ public class UnicornDispellAbility implements Ability { return 0; } - @Override - public boolean canUse(Race race) { - return race.canCast() || race == Race.CHANGELING; - } - @Override public int getColor(Pony player) { return SpellType.PORTAL.getColor(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 7f75d688..c5e3bbd4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; -import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Pos; @@ -60,11 +59,6 @@ public class UnicornTeleportAbility implements Ability { return (int)(50 - Math.min(45F, player.getLevel().get() * 0.75F)); } - @Override - public boolean canUse(Race race) { - return race.canCast() && race != Race.KIRIN; - } - @Override public double getCostEstimate(Pony player) { return prepare(player).map(pos -> pos.distanceTo(player) / 10).orElse(0D);