mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Add casting abilities for kirins
This commit is contained in:
parent
1b0505375a
commit
8961cc2cff
9 changed files with 42 additions and 5 deletions
|
@ -54,7 +54,7 @@ public record Race (Supplier<Composite> compositeSupplier, boolean canCast, Flig
|
||||||
public static final Race BAT = register("bat", false, FlightType.AVIAN, false, true, true);
|
public static final Race BAT = register("bat", false, FlightType.AVIAN, false, true, true);
|
||||||
public static final Race ALICORN = register("alicorn", true, FlightType.AVIAN, true, false, false);
|
public static final Race ALICORN = register("alicorn", true, FlightType.AVIAN, true, false, false);
|
||||||
public static final Race CHANGELING = register("changeling", false, FlightType.INSECTOID, false, false, true);
|
public static final Race CHANGELING = register("changeling", false, FlightType.INSECTOID, false, false, true);
|
||||||
public static final Race KIRIN = register("kirin", false, FlightType.NONE, false, false, false);
|
public static final Race KIRIN = register("kirin", true, FlightType.NONE, false, false, false);
|
||||||
|
|
||||||
public static void bootstrap() {}
|
public static void bootstrap() {}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ public interface Abilities {
|
||||||
|
|
||||||
// kirin
|
// kirin
|
||||||
Ability<?> RAGE = register(new KirinRageAbility(), "rage", AbilitySlot.PRIMARY);
|
Ability<?> RAGE = register(new KirinRageAbility(), "rage", AbilitySlot.PRIMARY);
|
||||||
|
Ability<?> KIRIN_CAST = register(new KirinCastingAbility(), "kirin_cast", AbilitySlot.SECONDARY);
|
||||||
|
|
||||||
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
|
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
|
||||||
Identifier id = Unicopia.id(name);
|
Identifier id = Unicopia.id(name);
|
||||||
|
|
|
@ -19,7 +19,7 @@ abstract class AbstractSpellCastingAbility implements Ability<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(Race race) {
|
public boolean canUse(Race race) {
|
||||||
return race.canCast();
|
return race.canCast() && race != Race.KIRIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canCast(SpellType<?> type) {
|
||||||
|
return type == SpellType.FIRE_BOLT || type == SpellType.FLAME || type == SpellType.INFERNAL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,7 +42,11 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Hit> prepare(Pony player) {
|
public Optional<Hit> prepare(Pony player) {
|
||||||
return Hit.of(player.canCast() && player.getMagicalReserves().getMana().get() >= getCostEstimate(player));
|
TypedActionResult<CustomisedSpellType<?>> spell = player.getCharms().getSpellInHand(false);
|
||||||
|
return Hit.of(player.canCast()
|
||||||
|
&& player.getMagicalReserves().getMana().get() >= getCostEstimate(player)
|
||||||
|
&& (!spell.getResult().isAccepted() || canCast(spell.getValue().type()))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,7 +98,7 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
||||||
} else {
|
} else {
|
||||||
TypedActionResult<CustomisedSpellType<?>> newSpell = player.getCharms().getSpellInHand(true);
|
TypedActionResult<CustomisedSpellType<?>> newSpell = player.getCharms().getSpellInHand(true);
|
||||||
|
|
||||||
if (newSpell.getResult() != ActionResult.FAIL) {
|
if (newSpell.getResult() != ActionResult.FAIL && canCast(newSpell.getValue().type())) {
|
||||||
CustomisedSpellType<?> spell = newSpell.getValue();
|
CustomisedSpellType<?> spell = newSpell.getValue();
|
||||||
|
|
||||||
boolean removed = player.getSpellSlot().removeWhere(s -> {
|
boolean removed = player.getSpellSlot().removeWhere(s -> {
|
||||||
|
@ -122,6 +126,10 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canCast(SpellType<?> type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private TypedActionResult<ItemStack> getAmulet(Pony player) {
|
private TypedActionResult<ItemStack> getAmulet(Pony player) {
|
||||||
|
|
||||||
ItemStack stack = player.asEntity().getStackInHand(Hand.MAIN_HAND);
|
ItemStack stack = player.asEntity().getStackInHand(Hand.MAIN_HAND);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(Race race) {
|
public boolean canUse(Race race) {
|
||||||
return race.canCast();
|
return race.canCast() && race != Race.KIRIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -380,6 +380,11 @@
|
||||||
"ability.unicopia.cast.with_spell.active": "Casting %s",
|
"ability.unicopia.cast.with_spell.active": "Casting %s",
|
||||||
"ability.unicopia.cast.with_spell.hand": "Casting %s from hand",
|
"ability.unicopia.cast.with_spell.hand": "Casting %s from hand",
|
||||||
"ability.unicopia.cast.with_spell.replacing": "Replace %s with %s",
|
"ability.unicopia.cast.with_spell.replacing": "Replace %s with %s",
|
||||||
|
"ability.unicopia.kirin_cast": "Cast Spell",
|
||||||
|
"ability.unicopia.kirin_cast.with_spell": "Cast %s",
|
||||||
|
"ability.unicopia.kirin_cast.with_spell.active": "Casting %s",
|
||||||
|
"ability.unicopia.kirin_cast.with_spell.hand": "Casting %s from hand",
|
||||||
|
"ability.unicopia.kirin_cast.with_spell.replacing": "Replace %s with %s",
|
||||||
"ability.unicopia.dispell": "Dispell Magic",
|
"ability.unicopia.dispell": "Dispell Magic",
|
||||||
"ability.unicopia.teleport": "Teleport",
|
"ability.unicopia.teleport": "Teleport",
|
||||||
"ability.unicopia.teleport.far": "Teleport (Far)",
|
"ability.unicopia.teleport.far": "Teleport (Far)",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
src/main/resources/assets/unicopia/textures/gui/race/kirin.png
Normal file
BIN
src/main/resources/assets/unicopia/textures/gui/race/kirin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Reference in a new issue