diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index c6428de8..ecbbe0dc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.player.Pony; +import net.minecraft.util.Identifier; import net.minecraft.world.World; public interface Ability { @@ -47,6 +48,15 @@ public interface Ability { Hit.Serializer getSerializer(); + /** + * The icon representing this ability on the UI and HUD. + * @return + */ + default Identifier getIcon(Pony player) { + Identifier id = Abilities.REGISTRY.getId(this); + return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + ".png"); + } + /** * Called to actually apply the ability. * Only called on the server side. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index fdd01760..42486e1f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -178,7 +178,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { public Optional> getAbility() { Race race = player.getSpecies(); - return Abilities.BY_SLOT.computeIfAbsent(slot, c -> Collections.emptySet()).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) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java index 4814670c..1969106e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java @@ -11,12 +11,23 @@ import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.particle.MagicParticleEffect; +import net.minecraft.util.Identifier; + /** * A magic casting ability for unicorns. * (only shields for now) */ public class UnicornProjectileAbility implements Ability { + /** + * The icon representing this ability on the UI and HUD. + */ + @Override + public Identifier getIcon(Pony player) { + Identifier id = Abilities.REGISTRY.getId(this); + return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + (player.getEntity().isSneaking() ? "_focused" : "_unfocused") + ".png"); + } + @Override public int getWarmupTime(Pony player) { return 4; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index e6e6dda5..97a40855 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -18,6 +18,7 @@ import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +import net.minecraft.util.Identifier; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -28,6 +29,16 @@ import net.minecraft.world.World; * Unicorn teleport ability */ public class UnicornTeleportAbility implements Ability { + + /** + * The icon representing this ability on the UI and HUD. + */ + @Override + public Identifier getIcon(Pony player) { + Identifier id = Abilities.REGISTRY.getId(this); + return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + (player.getEntity().isSneaking() ? "_far" : "_near") + ".png"); + } + @Override public int getWarmupTime(Pony player) { return 20; @@ -39,8 +50,8 @@ public class UnicornTeleportAbility implements Ability { } @Override - public boolean canUse(Race playerSpecies) { - return playerSpecies.canCast(); + public boolean canUse(Race race) { + return race.canCast(); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index c312ca06..3fa67233 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.client.gui; import java.util.ArrayList; import java.util.List; -import com.minelittlepony.unicopia.ability.Abilities; import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.entity.player.Pony; @@ -67,11 +66,8 @@ public class UHud extends DrawableHelper { void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { stat.getAbility().ifPresent(ability -> { - Identifier id = Abilities.REGISTRY.getId(ability); - client.getTextureManager().bindTexture(new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + ".png")); - + client.getTextureManager().bindTexture(ability.getIcon(Pony.of(client.player))); drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); - client.getTextureManager().bindTexture(HUD_TEXTURE); }); } diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/cast.png b/src/main/resources/assets/unicopia/textures/gui/ability/cast.png index 1640da82..097c07af 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/cast.png and b/src/main/resources/assets/unicopia/textures/gui/ability/cast.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/cast_original.png b/src/main/resources/assets/unicopia/textures/gui/ability/cast_original.png new file mode 100644 index 00000000..1640da82 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/cast_original.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/disguise.png b/src/main/resources/assets/unicopia/textures/gui/ability/disguise.png index a2fe153a..5aff5925 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/disguise.png and b/src/main/resources/assets/unicopia/textures/gui/ability/disguise.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png b/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png new file mode 100644 index 00000000..a2fe153a Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/grow.png b/src/main/resources/assets/unicopia/textures/gui/ability/grow.png index 713e6477..08c7192e 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/grow.png and b/src/main/resources/assets/unicopia/textures/gui/ability/grow.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/hang.png b/src/main/resources/assets/unicopia/textures/gui/ability/hang.png index b762d2ac..fe0bf0b0 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/hang.png and b/src/main/resources/assets/unicopia/textures/gui/ability/hang.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/shoot_focused.png b/src/main/resources/assets/unicopia/textures/gui/ability/shoot_focused.png new file mode 100644 index 00000000..b9b27929 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/shoot_focused.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/shoot_unfocused.png b/src/main/resources/assets/unicopia/textures/gui/ability/shoot_unfocused.png new file mode 100644 index 00000000..80914096 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/shoot_unfocused.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/stomp.png b/src/main/resources/assets/unicopia/textures/gui/ability/stomp.png index be49dcae..add9938b 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/stomp.png and b/src/main/resources/assets/unicopia/textures/gui/ability/stomp.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/teleport.png b/src/main/resources/assets/unicopia/textures/gui/ability/teleport.png deleted file mode 100644 index 0a0ac19d..00000000 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/teleport.png and /dev/null differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/teleport_far.png b/src/main/resources/assets/unicopia/textures/gui/ability/teleport_far.png new file mode 100644 index 00000000..c3ad1194 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/teleport_far.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/teleport_near.png b/src/main/resources/assets/unicopia/textures/gui/ability/teleport_near.png new file mode 100644 index 00000000..6a16d61e Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/teleport_near.png differ