Improved the ability icons and added separate icons for ability variations

This commit is contained in:
Sollace 2020-10-09 12:59:38 +02:00
parent d057e09877
commit 3a22954baa
17 changed files with 39 additions and 8 deletions

View file

@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.util.Identifier;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface Ability<T extends Hit> { public interface Ability<T extends Hit> {
@ -47,6 +48,15 @@ public interface Ability<T extends Hit> {
Hit.Serializer<T> getSerializer(); Hit.Serializer<T> 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. * Called to actually apply the ability.
* Only called on the server side. * Only called on the server side.

View file

@ -178,7 +178,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
public Optional<Ability<?>> getAbility() { public Optional<Ability<?>> getAbility() {
Race race = player.getSpecies(); 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) { protected synchronized void setActiveAbility(Ability<?> power) {

View file

@ -11,12 +11,23 @@ import com.minelittlepony.unicopia.ability.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import net.minecraft.util.Identifier;
/** /**
* A magic casting ability for unicorns. * A magic casting ability for unicorns.
* (only shields for now) * (only shields for now)
*/ */
public class UnicornProjectileAbility implements Ability<Hit> { public class UnicornProjectileAbility implements Ability<Hit> {
/**
* 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 @Override
public int getWarmupTime(Pony player) { public int getWarmupTime(Pony player) {
return 4; return 4;

View file

@ -18,6 +18,7 @@ import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult; import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -28,6 +29,16 @@ import net.minecraft.world.World;
* Unicorn teleport ability * Unicorn teleport ability
*/ */
public class UnicornTeleportAbility implements Ability<Pos> { public class UnicornTeleportAbility implements Ability<Pos> {
/**
* 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 @Override
public int getWarmupTime(Pony player) { public int getWarmupTime(Pony player) {
return 20; return 20;
@ -39,8 +50,8 @@ public class UnicornTeleportAbility implements Ability<Pos> {
} }
@Override @Override
public boolean canUse(Race playerSpecies) { public boolean canUse(Race race) {
return playerSpecies.canCast(); return race.canCast();
} }
@Override @Override

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.client.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ability.AbilityDispatcher;
import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.ability.AbilitySlot;
import com.minelittlepony.unicopia.entity.player.Pony; 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) { void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
stat.getAbility().ifPresent(ability -> { stat.getAbility().ifPresent(ability -> {
Identifier id = Abilities.REGISTRY.getId(ability); client.getTextureManager().bindTexture(ability.getIcon(Pony.of(client.player)));
client.getTextureManager().bindTexture(new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + ".png"));
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
client.getTextureManager().bindTexture(HUD_TEXTURE); client.getTextureManager().bindTexture(HUD_TEXTURE);
}); });
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B