Improved the ability icons and added separate icons for ability variations
|
@ -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<T extends Hit> {
|
||||
|
@ -47,6 +48,15 @@ public interface Ability<T extends Hit> {
|
|||
|
||||
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.
|
||||
* Only called on the server side.
|
||||
|
|
|
@ -178,7 +178,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
|
||||
public Optional<Ability<?>> 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) {
|
||||
|
|
|
@ -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<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
|
||||
public int getWarmupTime(Pony player) {
|
||||
return 4;
|
||||
|
|
|
@ -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<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
|
||||
public int getWarmupTime(Pony player) {
|
||||
return 20;
|
||||
|
@ -39,8 +50,8 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(Race playerSpecies) {
|
||||
return playerSpecies.canCast();
|
||||
public boolean canUse(Race race) {
|
||||
return race.canCast();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 715 B |
Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 315 B |
After Width: | Height: | Size: 838 B |
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 735 B After Width: | Height: | Size: 746 B |
After Width: | Height: | Size: 488 B |
After Width: | Height: | Size: 427 B |
Before Width: | Height: | Size: 679 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 768 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 368 B |