mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Change spell constructors to use CustomisedSpellType<?>
This commit is contained in:
parent
22f28c098c
commit
8e65a265f9
29 changed files with 104 additions and 121 deletions
|
@ -1,13 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic.spell;
|
package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.AbstractSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
|
|
||||||
public abstract class AbstractAreaEffectSpell extends AbstractSpell {
|
public abstract class AbstractAreaEffectSpell extends AbstractSpell {
|
||||||
protected AbstractAreaEffectSpell(SpellType<?> type, SpellTraits traits) {
|
protected AbstractAreaEffectSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||||
|
@ -26,8 +27,8 @@ public abstract class AbstractDelegatingSpell implements ProjectileSpell {
|
||||||
|
|
||||||
private final SpellType<?> type;
|
private final SpellType<?> type;
|
||||||
|
|
||||||
public AbstractDelegatingSpell(SpellType<?> type, SpellTraits traits) {
|
public AbstractDelegatingSpell(CustomisedSpellType<?> type) {
|
||||||
this.type = type;
|
this.type = type.type();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Collection<Spell> getDelegates();
|
public abstract Collection<Spell> getDelegates();
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.AbstractSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
@ -21,8 +19,8 @@ public abstract class AbstractDisguiseSpell extends AbstractSpell implements Dis
|
||||||
|
|
||||||
private final EntityAppearance disguise = new EntityAppearance();
|
private final EntityAppearance disguise = new EntityAppearance();
|
||||||
|
|
||||||
public AbstractDisguiseSpell(SpellType<?> type, SpellTraits traits) {
|
public AbstractDisguiseSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,8 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
|
@ -13,8 +12,8 @@ import net.minecraft.nbt.NbtElement;
|
||||||
public class CompoundSpell extends AbstractDelegatingSpell {
|
public class CompoundSpell extends AbstractDelegatingSpell {
|
||||||
private final List<Spell> spells = new ArrayList<>();
|
private final List<Spell> spells = new ArrayList<>();
|
||||||
|
|
||||||
public CompoundSpell(SpellType<?> type, SpellTraits traits) {
|
public CompoundSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,8 +4,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.IllusionarySpell;
|
import com.minelittlepony.unicopia.ability.magic.IllusionarySpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
@ -24,8 +23,8 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
|
||||||
|
|
||||||
private int suppressionCounter;
|
private int suppressionCounter;
|
||||||
|
|
||||||
public DispersableDisguiseSpell(SpellType<?> type, SpellTraits traits) {
|
public DispersableDisguiseSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,8 +5,7 @@ import java.util.*;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.entity.CastSpellEntity;
|
import com.minelittlepony.unicopia.entity.CastSpellEntity;
|
||||||
import com.minelittlepony.unicopia.entity.EntityReference;
|
import com.minelittlepony.unicopia.entity.EntityReference;
|
||||||
import com.minelittlepony.unicopia.entity.UEntities;
|
import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
|
@ -49,8 +48,8 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
|
||||||
*/
|
*/
|
||||||
private Spell spell;
|
private Spell spell;
|
||||||
|
|
||||||
public PlaceableSpell(SpellType<?> type, SpellTraits traits) {
|
public PlaceableSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaceableSpell setSpell(Spell spell) {
|
public PlaceableSpell setSpell(Spell spell) {
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.UTags;
|
import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.AbstractSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
|
import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
||||||
|
@ -36,8 +34,8 @@ public class RainboomAbilitySpell extends AbstractSpell {
|
||||||
|
|
||||||
private int age;
|
private int age;
|
||||||
|
|
||||||
public RainboomAbilitySpell(SpellType<?> type, SpellTraits traits) {
|
public RainboomAbilitySpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -96,14 +96,14 @@ public interface Spell extends NbtSerialisable, Affine {
|
||||||
* Returns a compound spell representing the union of this and the other spell.
|
* Returns a compound spell representing the union of this and the other spell.
|
||||||
*/
|
*/
|
||||||
default Spell combineWith(Spell other) {
|
default Spell combineWith(Spell other) {
|
||||||
return SpellType.COMPOUND_SPELL.create(SpellTraits.EMPTY).combineWith(this).combineWith(other);
|
return SpellType.COMPOUND_SPELL.withTraits().create().combineWith(this).combineWith(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this spell into a placeable spell.
|
* Converts this spell into a placeable spell.
|
||||||
*/
|
*/
|
||||||
default PlaceableSpell toPlaceable() {
|
default PlaceableSpell toPlaceable() {
|
||||||
return SpellType.PLACED_SPELL.create(SpellTraits.EMPTY).setSpell(this);
|
return SpellType.PLACED_SPELL.withTraits().create().setSpell(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,13 +111,13 @@ public interface Spell extends NbtSerialisable, Affine {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
default ThrowableSpell toThrowable() {
|
default ThrowableSpell toThrowable() {
|
||||||
return SpellType.THROWN_SPELL.create(SpellTraits.EMPTY).setSpell(this);
|
return SpellType.THROWN_SPELL.withTraits().create().setSpell(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Spell readNbt(@Nullable NbtCompound compound) {
|
static Spell readNbt(@Nullable NbtCompound compound) {
|
||||||
if (compound != null && compound.contains("effect_id")) {
|
if (compound != null && compound.contains("effect_id")) {
|
||||||
Spell effect = SpellType.getKey(compound).create(SpellTraits.EMPTY);
|
Spell effect = SpellType.getKey(compound).withTraits().create();
|
||||||
|
|
||||||
if (effect != null) {
|
if (effect != null) {
|
||||||
effect.fromNBT(compound);
|
effect.fromNBT(compound);
|
||||||
|
|
|
@ -6,8 +6,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.entity.UEntities;
|
import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
import com.minelittlepony.unicopia.item.GemstoneItem;
|
import com.minelittlepony.unicopia.item.GemstoneItem;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
|
@ -21,8 +20,8 @@ public final class ThrowableSpell extends AbstractDelegatingSpell {
|
||||||
|
|
||||||
private Spell spell;
|
private Spell spell;
|
||||||
|
|
||||||
public ThrowableSpell(SpellType<?> type, SpellTraits traits) {
|
public ThrowableSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThrowableSpell setSpell(Spell spell) {
|
public ThrowableSpell setSpell(Spell spell) {
|
||||||
|
|
|
@ -14,15 +14,12 @@ public abstract class AbstractSpell implements Spell {
|
||||||
private boolean isDead;
|
private boolean isDead;
|
||||||
private boolean isDirty;
|
private boolean isDirty;
|
||||||
|
|
||||||
private final SpellType<?> type;
|
private CustomisedSpellType<?> type;
|
||||||
|
|
||||||
private SpellTraits traits;
|
|
||||||
|
|
||||||
private UUID uuid = UUID.randomUUID();
|
private UUID uuid = UUID.randomUUID();
|
||||||
|
|
||||||
protected AbstractSpell(SpellType<?> type, SpellTraits traits) {
|
protected AbstractSpell(CustomisedSpellType<?> type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.traits = traits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,13 +28,17 @@ public abstract class AbstractSpell implements Spell {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpellType<?> getType() {
|
public final SpellType<?> getType() {
|
||||||
|
return type.type();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final CustomisedSpellType<?> getTypeAndTraits() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final SpellTraits getTraits() {
|
public final SpellTraits getTraits() {
|
||||||
return traits == null ? SpellTraits.EMPTY : traits;
|
return type.traits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,7 +86,12 @@ public abstract class AbstractSpell implements Spell {
|
||||||
}
|
}
|
||||||
isDead = compound.getBoolean("dead");
|
isDead = compound.getBoolean("dead");
|
||||||
if (compound.contains("traits")) {
|
if (compound.contains("traits")) {
|
||||||
traits = SpellTraits.fromNbt(compound.getCompound("traits")).orElse(SpellTraits.EMPTY);
|
type = type.type().withTraits(SpellTraits.fromNbt(compound.getCompound("traits")).orElse(SpellTraits.EMPTY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String toString() {
|
||||||
|
return "Spell[uuid=" + uuid + ", dead=" + isDead + ", type=" + getType() + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.*;
|
import com.minelittlepony.unicopia.ability.magic.spell.*;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.EntityReference;
|
import com.minelittlepony.unicopia.entity.EntityReference;
|
||||||
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
||||||
|
@ -25,9 +24,9 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell, Hom
|
||||||
private int age;
|
private int age;
|
||||||
private int duration;
|
private int duration;
|
||||||
|
|
||||||
protected AttractiveSpell(SpellType<?> type, SpellTraits traits) {
|
protected AttractiveSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
duration = 120 + (int)(traits.get(Trait.FOCUS, 0, 160) * 19);
|
duration = 120 + (int)(getTraits().get(Trait.FOCUS, 0, 160) * 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,7 +139,7 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell, Hom
|
||||||
public void onImpact(MagicProjectileEntity projectile, Entity entity) {
|
public void onImpact(MagicProjectileEntity projectile, Entity entity) {
|
||||||
if (!isDead() && getTraits().get(Trait.CHAOS) > 0) {
|
if (!isDead() && getTraits().get(Trait.CHAOS) > 0) {
|
||||||
setDead();
|
setDead();
|
||||||
Caster.of(entity).ifPresent(getType().create(getTraits())::apply);
|
Caster.of(entity).ifPresent(getTypeAndTraits()::apply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
|
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
|
@ -18,8 +17,8 @@ import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class AwkwardSpell extends AbstractSpell {
|
public class AwkwardSpell extends AbstractSpell {
|
||||||
|
|
||||||
protected AwkwardSpell(SpellType<?> type, SpellTraits traits) {
|
protected AwkwardSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
private static final float HORIZONTAL_VARIANCE = 0.25F;
|
private static final float HORIZONTAL_VARIANCE = 0.25F;
|
||||||
private static final float MAX_STRENGTH = 120;
|
private static final float MAX_STRENGTH = 120;
|
||||||
|
|
||||||
protected CatapultSpell(SpellType<?> type, SpellTraits traits) {
|
protected CatapultSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,8 +14,8 @@ public class ChillingBreathSpell extends AbstractSpell implements HomingSpell {
|
||||||
.with(Trait.ICE, 15)
|
.with(Trait.ICE, 15)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
protected ChillingBreathSpell(SpellType<?> type, SpellTraits traits) {
|
protected ChillingBreathSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,12 +21,28 @@ public record CustomisedSpellType<T extends Spell> (
|
||||||
}
|
}
|
||||||
|
|
||||||
public T create() {
|
public T create() {
|
||||||
return type.create(traits);
|
try {
|
||||||
|
return type.getFactory().create(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public T apply(Caster<?> caster) {
|
public T apply(Caster<?> caster) {
|
||||||
return type.apply(caster, traits);
|
if (isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
T spell = create();
|
||||||
|
if (spell != null && spell.apply(caster)) {
|
||||||
|
return spell;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
|
||||||
private int age = 0;
|
private int age = 0;
|
||||||
private float accumulatedMass = 0;
|
private float accumulatedMass = 0;
|
||||||
|
|
||||||
protected DarkVortexSpell(SpellType<?> type, SpellTraits traits) {
|
protected DarkVortexSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
||||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
|
@ -16,8 +15,8 @@ import net.minecraft.util.math.Vec3d;
|
||||||
* An area-effect spell that disperses illussions.
|
* An area-effect spell that disperses illussions.
|
||||||
*/
|
*/
|
||||||
public class DisperseIllusionSpell extends AbstractAreaEffectSpell {
|
public class DisperseIllusionSpell extends AbstractAreaEffectSpell {
|
||||||
protected DisperseIllusionSpell(SpellType<?> type, SpellTraits traits) {
|
protected DisperseIllusionSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,9 +37,9 @@ public class FeatherFallSpell extends AbstractSpell {
|
||||||
|
|
||||||
private int duration;
|
private int duration;
|
||||||
|
|
||||||
protected FeatherFallSpell(SpellType<?> type, SpellTraits traits) {
|
protected FeatherFallSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
duration = (int)(traits.get(Trait.FOCUS, 0, 160) * 19);
|
duration = (int)(getTraits().get(Trait.FOCUS, 0, 160) * 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
|
||||||
|
|
||||||
private final EntityReference<Entity> target = new EntityReference<>();
|
private final EntityReference<Entity> target = new EntityReference<>();
|
||||||
|
|
||||||
protected FireBoltSpell(SpellType<?> type, SpellTraits traits) {
|
protected FireBoltSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +62,7 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < getNumberOfBalls(caster); i++) {
|
for (int i = 0; i < getNumberOfBalls(caster); i++) {
|
||||||
getType().create(getTraits()).toThrowable().throwProjectile(caster, 2).ifPresent(c -> {
|
getTypeAndTraits().create().toThrowable().throwProjectile(caster, 2).ifPresent(c -> {
|
||||||
target.ifPresent(caster.getReferenceWorld(), c::setHomingTarget);
|
target.ifPresent(caster.getReferenceWorld(), c::setHomingTarget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpel
|
||||||
.with(Trait.FIRE, 15)
|
.with(Trait.FIRE, 15)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
protected FireSpell(SpellType<?> type, SpellTraits traits) {
|
protected FireSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class IceSpell extends AbstractSpell {
|
||||||
private final int rad = 3;
|
private final int rad = 3;
|
||||||
private final Shape outerRange = new Sphere(false, rad);
|
private final Shape outerRange = new Sphere(false, rad);
|
||||||
|
|
||||||
protected IceSpell(SpellType<?> type, SpellTraits traits) {
|
protected IceSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.block.state.BlockStateConverter;
|
import com.minelittlepony.unicopia.block.state.BlockStateConverter;
|
||||||
import com.minelittlepony.unicopia.block.state.StateMaps;
|
import com.minelittlepony.unicopia.block.state.StateMaps;
|
||||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
@ -21,8 +20,8 @@ import net.minecraft.world.World;
|
||||||
*/
|
*/
|
||||||
public class InfernoSpell extends FireSpell {
|
public class InfernoSpell extends FireSpell {
|
||||||
|
|
||||||
protected InfernoSpell(SpellType<?> type, SpellTraits traits) {
|
protected InfernoSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,9 +29,9 @@ public class LightSpell extends AbstractSpell {
|
||||||
|
|
||||||
private final List<EntityReference<FairyEntity>> lights = new ArrayList<>();
|
private final List<EntityReference<FairyEntity>> lights = new ArrayList<>();
|
||||||
|
|
||||||
protected LightSpell(SpellType<?> type, SpellTraits traits) {
|
protected LightSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
duration = 120 + (int)(traits.get(Trait.FOCUS, 0, 160) * 19);
|
duration = 120 + (int)(getTraits().get(Trait.FOCUS, 0, 160) * 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.Creature;
|
import com.minelittlepony.unicopia.entity.Creature;
|
||||||
import com.minelittlepony.unicopia.entity.EntityReference;
|
import com.minelittlepony.unicopia.entity.EntityReference;
|
||||||
|
@ -44,8 +43,8 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
||||||
|
|
||||||
private int spawnCountdown;
|
private int spawnCountdown;
|
||||||
|
|
||||||
protected NecromancySpell(SpellType<?> type, SpellTraits traits) {
|
protected NecromancySpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.block.state.StateMaps;
|
import com.minelittlepony.unicopia.block.state.StateMaps;
|
||||||
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
||||||
|
@ -16,8 +15,8 @@ import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class ScorchSpell extends FireSpell {
|
public class ScorchSpell extends FireSpell {
|
||||||
|
|
||||||
protected ScorchSpell(SpellType<?> type, SpellTraits traits) {
|
protected ScorchSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class ShieldSpell extends AbstractSpell {
|
||||||
|
|
||||||
private final TargetSelecter targetSelecter = new TargetSelecter(this);
|
private final TargetSelecter targetSelecter = new TargetSelecter(this);
|
||||||
|
|
||||||
protected ShieldSpell(SpellType<?> type, SpellTraits traits) {
|
protected ShieldSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.AbstractAreaEffectSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
||||||
|
@ -35,8 +34,8 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
||||||
|
|
||||||
private int ticksUpset;
|
private int ticksUpset;
|
||||||
|
|
||||||
protected SiphoningSpell(SpellType<?> type, SpellTraits traits) {
|
protected SiphoningSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Affine;
|
import com.minelittlepony.unicopia.ability.magic.Affine;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.CompoundSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.CompoundSpell;
|
||||||
|
@ -33,7 +32,7 @@ import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public final class SpellType<T extends Spell> implements Affine, SpellPredicate<T> {
|
public final class SpellType<T extends Spell> implements Affine, SpellPredicate<T> {
|
||||||
public static final Identifier EMPTY_ID = Unicopia.id("none");
|
public static final Identifier EMPTY_ID = Unicopia.id("none");
|
||||||
public static final SpellType<?> EMPTY_KEY = new SpellType<>(EMPTY_ID, Affinity.NEUTRAL, 0xFFFFFF, false, SpellTraits.EMPTY, (t, c) -> null);
|
public static final SpellType<?> EMPTY_KEY = new SpellType<>(EMPTY_ID, Affinity.NEUTRAL, 0xFFFFFF, false, SpellTraits.EMPTY, t -> null);
|
||||||
|
|
||||||
public static final Registry<SpellType<?>> REGISTRY = Registries.createSimple(Unicopia.id("spells"));
|
public static final Registry<SpellType<?>> REGISTRY = Registries.createSimple(Unicopia.id("spells"));
|
||||||
private static final Map<Affinity, Set<SpellType<?>>> BY_AFFINITY = new EnumMap<>(Affinity.class);
|
private static final Map<Affinity, Set<SpellType<?>>> BY_AFFINITY = new EnumMap<>(Affinity.class);
|
||||||
|
@ -138,29 +137,8 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
||||||
return traits.isEmpty() ? withTraits() : new CustomisedSpellType<>(this, traits);
|
return traits.isEmpty() ? withTraits() : new CustomisedSpellType<>(this, traits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public Factory<T> getFactory() {
|
||||||
public T create(SpellTraits traits) {
|
return factory;
|
||||||
try {
|
|
||||||
return factory.create(this, traits);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public T apply(Caster<?> caster, SpellTraits traits) {
|
|
||||||
if (isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
T spell = create(traits);
|
|
||||||
if (spell.apply(caster)) {
|
|
||||||
return spell;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,7 +156,7 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getTranslationKey();
|
return "SpellType[" + getTranslationKey() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
|
@ -216,6 +194,6 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Factory<T extends Spell> {
|
public interface Factory<T extends Spell> {
|
||||||
T create(SpellType<T> type, SpellTraits traits);
|
T create(CustomisedSpellType<T> type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
|
||||||
import com.minelittlepony.unicopia.entity.UEntities;
|
import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||||
|
@ -28,8 +27,8 @@ import net.minecraft.world.World;
|
||||||
* Transforms whatever entity it strikes into a random other entity.
|
* Transforms whatever entity it strikes into a random other entity.
|
||||||
*/
|
*/
|
||||||
public class TransformationSpell extends AbstractSpell implements ProjectileSpell {
|
public class TransformationSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
protected TransformationSpell(SpellType<?> type, SpellTraits traits) {
|
protected TransformationSpell(CustomisedSpellType<?> type) {
|
||||||
super(type, traits);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue