Minor cleanup and documentation tweaks

This commit is contained in:
Sollace 2021-11-08 14:43:19 +02:00
parent 2890bc3e07
commit 38e3693384
8 changed files with 24 additions and 12 deletions

View file

@ -58,7 +58,6 @@ public interface Ability<T extends Hit> {
/** /**
* The icon representing this ability on the UI and HUD. * The icon representing this ability on the UI and HUD.
* @return
*/ */
default Identifier getIcon(Pony player, boolean swap) { default Identifier getIcon(Pony player, boolean swap) {
Identifier id = Abilities.REGISTRY.getId(this); Identifier id = Abilities.REGISTRY.getId(this);

View file

@ -25,8 +25,11 @@ import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
/** /**
* A magic casting ability for unicorns. * Casts magic onto the user directly, or uses the item in the main hand slot.
* (only shields for now) * <p>
* 1. If the player is holding nothing, defaults to toggling their equipped spell (currently only shield).
* 2. If the player is holding a gem, consumes it and casts whatever spell is contained within onto the user.
* 3. If the player is holding a amulet, charges it.
*/ */
public class UnicornCastingAbility implements Ability<Hit> { public class UnicornCastingAbility implements Ability<Hit> {

View file

@ -16,14 +16,13 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
/** /**
* A magic casting ability for unicorns. * Fires a spell as a projectile.
* (only shields for now) *
* 1. If the player is holding nothing, casts their equipped offensive spell (currently only vortex - inverse of shield)
* 2. If the player is holding a gem, consumes it and casts whatever spell is contained within onto a projectile.
*/ */
public class UnicornProjectileAbility implements Ability<Hit> { public class UnicornProjectileAbility implements Ability<Hit> {
/**
* The icon representing this ability on the UI and HUD.
*/
@Override @Override
public Identifier getIcon(Pony player, boolean swap) { public Identifier getIcon(Pony player, boolean swap) {
Identifier id = Abilities.REGISTRY.getId(this); Identifier id = Abilities.REGISTRY.getId(this);

View file

@ -6,8 +6,9 @@ import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
import com.minelittlepony.unicopia.ability.magic.spell.Spell; import com.minelittlepony.unicopia.ability.magic.spell.Spell;
public interface SpellPredicate<T extends Spell> extends Predicate<Spell> { public interface SpellPredicate<T extends Spell> extends Predicate<Spell> {
SpellPredicate<ProjectileSpell> IS_THROWN = s -> s instanceof ProjectileSpell; SpellPredicate<Suppressable> CAN_SUPPRESS = s -> s instanceof Suppressable;
SpellPredicate<Suppressable> IS_SUPPRESSABLE = s -> s instanceof Suppressable;
SpellPredicate<ProjectileSpell> HAS_PROJECTILE_EVENTS = s -> s instanceof ProjectileSpell;
default boolean isOn(Caster<?> caster) { default boolean isOn(Caster<?> caster) {
return caster.getSpellSlot().get(this, false).isPresent(); return caster.getSpellSlot().get(this, false).isPresent();

View file

@ -28,6 +28,11 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
/**
* Shapeshifts the player.
* <p>
* Internal. Used by the changeling ability.
*/
public class DisguiseSpell extends AbstractSpell implements Suppressable, FlightType.Provider, PlayerDimensions.Provider, ProjectileImpactListener { public class DisguiseSpell extends AbstractSpell implements Suppressable, FlightType.Provider, PlayerDimensions.Provider, ProjectileImpactListener {
private final Disguise disguise = new Disguise(); private final Disguise disguise = new Disguise();

View file

@ -22,6 +22,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules; import net.minecraft.world.GameRules;
/**
* Internal.
* <p>
* Used by the Rainboom ability.
*/
public class JoustingSpell extends AbstractSpell { public class JoustingSpell extends AbstractSpell {
private final int rad = 5; private final int rad = 5;

View file

@ -34,7 +34,7 @@ public class RevealingSpell extends AbstractSpell {
} }
source.findAllSpellsInRange(15).forEach(e -> { source.findAllSpellsInRange(15).forEach(e -> {
e.getSpellSlot().get(SpellPredicate.IS_SUPPRESSABLE, false) e.getSpellSlot().get(SpellPredicate.CAN_SUPPRESS, false)
.filter(spell -> spell.isVulnerable(source, this)) .filter(spell -> spell.isVulnerable(source, this))
.ifPresent(spell -> { .ifPresent(spell -> {
spell.onSuppressed(source); spell.onSuppressed(source);

View file

@ -269,7 +269,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Li
} }
protected void forEachDelegates(Consumer<ProjectileDelegate> consumer) { protected void forEachDelegates(Consumer<ProjectileDelegate> consumer) {
getSpellSlot().get(SpellPredicate.IS_THROWN, true).ifPresent(consumer); getSpellSlot().get(SpellPredicate.HAS_PROJECTILE_EVENTS, true).ifPresent(consumer);
if (getItem().getItem() instanceof ProjectileDelegate) { if (getItem().getItem() instanceof ProjectileDelegate) {
consumer.accept(((ProjectileDelegate)getItem().getItem())); consumer.accept(((ProjectileDelegate)getItem().getItem()));
} }