Some terminology changes and cleanup

This commit is contained in:
Sollace 2020-05-28 18:27:30 +02:00
parent ad4a449723
commit 2f6ffe43a9
54 changed files with 286 additions and 294 deletions

View file

@ -54,7 +54,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
if (looked instanceof PlayerEntity) { if (looked instanceof PlayerEntity) {
looked = Pony.of((PlayerEntity)looked) looked = Pony.of((PlayerEntity)looked)
.getEffect(DisguiseSpell.class) .getSpell(DisguiseSpell.class)
.map(DisguiseSpell::getDisguise) .map(DisguiseSpell::getDisguise)
.orElse(looked); .orElse(looked);
} }
@ -67,10 +67,10 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_RAVAGER, SoundCategory.PLAYERS, 1.4F, 0.4F); player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_RAVAGER, SoundCategory.PLAYERS, 1.4F, 0.4F);
iplayer.getEffect(DisguiseSpell.class).orElseGet(() -> { iplayer.getSpell(DisguiseSpell.class).orElseGet(() -> {
DisguiseSpell disc = new DisguiseSpell(); DisguiseSpell disc = new DisguiseSpell();
iplayer.setEffect(disc); iplayer.setSpell(disc);
return disc; return disc;
}).setDisguise(looked); }).setDisguise(looked);

View file

@ -42,9 +42,9 @@ public class UnicornCastingAbility implements Ability<Hit> {
@Override @Override
public void apply(Pony player, Hit data) { public void apply(Pony player, Hit data) {
if (player.hasEffect()) { if (player.hasSpell()) {
String current = player.getEffect().getName(); String current = player.getSpell().getName();
player.setEffect(Streams.stream(player.getOwner().getItemsHand()) player.setSpell(Streams.stream(player.getOwner().getItemsHand())
.map(SpellRegistry::getKeyFromStack) .map(SpellRegistry::getKeyFromStack)
.filter(i -> i != null && !current.equals(i)) .filter(i -> i != null && !current.equals(i))
.map(SpellRegistry.instance()::getSpellFromName) .map(SpellRegistry.instance()::getSpellFromName)
@ -52,7 +52,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
.findFirst() .findFirst()
.orElse(null)); .orElse(null));
} else { } else {
player.setEffect(Streams.stream(player.getOwner().getItemsHand()) player.setSpell(Streams.stream(player.getOwner().getItemsHand())
.map(SpellRegistry.instance()::getSpellFrom) .map(SpellRegistry.instance()::getSpellFrom)
.filter(i -> i != null) .filter(i -> i != null)
.findFirst() .findFirst()

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.util.Color; import com.minelittlepony.util.Color;
@ -25,7 +25,7 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
private ModelPart body; private ModelPart body;
@Nullable @Nullable
private MagicEffect effect; private Spell effect;
public GemEntityModel() { public GemEntityModel() {
textureWidth = 256; textureWidth = 256;
@ -37,7 +37,7 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
@Override @Override
public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
effect = entity.hasEffect() ? entity.getEffect() : null; effect = entity.hasSpell() ? entity.getSpell() : null;
float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F; float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F;

View file

@ -60,10 +60,10 @@ public class DisguiseCommand {
throw FAILED_EXCEPTION.create(); throw FAILED_EXCEPTION.create();
} }
DisguiseSpell effect = iplayer.getEffect(DisguiseSpell.class, true); DisguiseSpell effect = iplayer.getSpell(DisguiseSpell.class, true);
if (effect == null) { if (effect == null) {
iplayer.setEffect(new DisguiseSpell().setDisguise(entity)); iplayer.setSpell(new DisguiseSpell().setDisguise(entity));
} else { } else {
effect.setDisguise(entity); effect.setDisguise(entity);
} }
@ -82,7 +82,7 @@ public class DisguiseCommand {
static int reveal(ServerCommandSource source, PlayerEntity player) { static int reveal(ServerCommandSource source, PlayerEntity player) {
Pony iplayer = Pony.of(player); Pony iplayer = Pony.of(player);
iplayer.getEffect(DisguiseSpell.class).ifPresent(disguise -> { iplayer.getSpell(DisguiseSpell.class).ifPresent(disguise -> {
disguise.onDestroyed(iplayer); disguise.onDestroyed(iplayer);
}); });

View file

@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Affine; import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
@ -48,24 +48,14 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
} }
@Override @Override
public void setEffect(MagicEffect effect) { public EffectSync getPrimarySpellSlot() {
effectDelegate.set(effect); return effectDelegate;
}
@Override
public <T> T getEffect(Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@Override
public boolean hasEffect() {
return effectDelegate.has();
} }
@Override @Override
public void tick() { public void tick() {
if (hasEffect()) { if (hasSpell()) {
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true); AttachableSpell effect = getSpell(AttachableSpell.class, true);
if (effect != null) { if (effect != null) {
if (entity.getEntityWorld().isClient()) { if (entity.getEntityWorld().isClient()) {
@ -73,7 +63,7 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
} }
if (!effect.updateOnPerson(this)) { if (!effect.updateOnPerson(this)) {
setEffect(null); setSpell(null);
} }
} }
} }
@ -108,10 +98,10 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
@Override @Override
public void toNBT(CompoundTag compound) { public void toNBT(CompoundTag compound) {
MagicEffect effect = getEffect(); Spell effect = getSpell();
if (effect != null) { if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect)); compound.put("effect", SpellRegistry.toNBT(effect));
} }
physics.toNBT(compound); physics.toNBT(compound);
} }
@ -119,7 +109,7 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
@Override @Override
public void fromNBT(CompoundTag compound) { public void fromNBT(CompoundTag compound) {
if (compound.contains("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setSpell(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
physics.fromNBT(compound); physics.fromNBT(compound);
} }

View file

@ -5,8 +5,8 @@ import java.util.UUID;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener; import com.minelittlepony.unicopia.magic.EtherialListener;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
@ -114,7 +114,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
@Override @Override
public Affinity getAffinity() { public Affinity getAffinity() {
return hasEffect() ? Affinity.NEUTRAL : getEffect().getAffinity(); return hasSpell() ? Affinity.NEUTRAL : getSpell().getAffinity();
} }
@Override @Override
@ -123,29 +123,24 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
} }
@Override @Override
public void setEffect(TossedMagicEffect effect) { public void setEffect(ThrowableSpell effect) {
setEffect((MagicEffect)effect); setSpell(effect);
} }
@Override @Override
public void setEffect(MagicEffect effect) { public EffectSync getPrimarySpellSlot() {
effectDelegate.set(effect); return effectDelegate;
}
@Override
public void setSpell(Spell effect) {
Caster.super.setSpell(effect);
if (effect != null) { if (effect != null) {
effect.onPlaced(this); effect.onPlaced(this);
} }
} }
@Override
public <T> T getEffect(Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@Override
public boolean hasEffect() {
return effectDelegate.has();
}
@Override @Override
public void setThrowDamage(float damage) { public void setThrowDamage(float damage) {
getDataTracker().set(DAMAGE, Math.max(0, damage)); getDataTracker().set(DAMAGE, Math.max(0, damage));
@ -181,21 +176,21 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
setNoGravity(false); setNoGravity(false);
} }
if (hasEffect()) { if (hasSpell()) {
if (lastBlockPos == null || !lastBlockPos.equals(getBlockPos())) { if (lastBlockPos == null || !lastBlockPos.equals(getBlockPos())) {
notifyNearbySpells(getEffect(), lastBlockPos, 6, EtherialListener.REMOVED); notifyNearbySpells(getSpell(), lastBlockPos, 6, EtherialListener.REMOVED);
lastBlockPos = getBlockPos(); lastBlockPos = getBlockPos();
notifyNearbySpells(getEffect(), 6, EtherialListener.ADDED); notifyNearbySpells(getSpell(), 6, EtherialListener.ADDED);
} }
if (getEffect().isDead()) { if (getSpell().isDead()) {
remove(); remove();
} else { } else {
getEffect().update(this); getSpell().update(this);
} }
if (world.isClient()) { if (world.isClient()) {
getEffect().render(this); getSpell().render(this);
} }
} }
@ -248,7 +243,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
super.readCustomDataFromTag(compound); super.readCustomDataFromTag(compound);
if (compound.contains("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setSpell(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
} }
@ -256,8 +251,8 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
public void writeCustomDataToTag(CompoundTag compound) { public void writeCustomDataToTag(CompoundTag compound) {
super.writeCustomDataToTag(compound); super.writeCustomDataToTag(compound);
if (hasEffect()) { if (hasSpell()) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect())); compound.put("effect", SpellRegistry.toNBT(getSpell()));
} }
} }
@ -281,8 +276,8 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
((TossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos())); ((TossableItem)item).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
} }
if (hasEffect()) { if (hasSpell()) {
MagicEffect effect = getEffect(); Spell effect = getSpell();
if (effect instanceof Tossable) { if (effect instanceof Tossable) {
((Tossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos())); ((Tossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.entity; package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
@ -184,6 +184,6 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
} }
@Override @Override
public void setEffect(TossedMagicEffect effect) { public void setEffect(ThrowableSpell effect) {
} }
} }

View file

@ -10,10 +10,10 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ducks.PickedItemSupplier; import com.minelittlepony.unicopia.ducks.PickedItemSupplier;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Castable;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener; import com.minelittlepony.unicopia.magic.EtherialListener;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.item.CastableMagicItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
@ -96,8 +96,13 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
} }
@Override @Override
public void setEffect(@Nullable MagicEffect effect) { public EffectSync getPrimarySpellSlot() {
effectDelegate.set(effect); return effectDelegate;
}
@Override
public void setSpell(@Nullable Spell effect) {
Caster.super.setSpell(effect);
if (effect != null) { if (effect != null) {
effect.onPlaced(this); effect.onPlaced(this);
@ -109,17 +114,6 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
return race.canCast(); return race.canCast();
} }
@Nullable
@Override
public <T> T getEffect(@Nullable Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@Override
public boolean hasEffect() {
return effectDelegate.has();
}
@Override @Override
protected void initDataTracker() { protected void initDataTracker() {
super.initDataTracker(); super.initDataTracker();
@ -131,7 +125,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
@Override @Override
public ItemStack getPickedStack() { public ItemStack getPickedStack() {
return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getEffect().getName()); return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getSpell().getName());
} }
protected Item getItem() { protected Item getItem() {
@ -168,8 +162,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
} }
protected void displayTick() { protected void displayTick() {
if (hasEffect()) { if (hasSpell()) {
getEffect().render(this); getSpell().render(this);
} }
} }
@ -180,17 +174,17 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
displayTick(); displayTick();
} }
if (!hasEffect()) { if (!hasSpell()) {
remove(); remove();
} else { } else {
if (getEffect().isDead()) { if (getSpell().isDead()) {
remove(); remove();
onDeath(); onDeath();
} else { } else {
getEffect().update(this); getSpell().update(this);
} }
if (getEffect().allowAI()) { if (getSpell().allowAI()) {
super.tickMovement(); super.tickMovement();
} }
} }
@ -200,13 +194,13 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
playSpawnEffects(); playSpawnEffects();
} }
if (!world.isClient && hasEffect()) { if (!world.isClient && hasSpell()) {
float exhaustionChance = getEffect().getExhaustion(this); float exhaustionChance = getSpell().getExhaustion(this);
if (exhaustionChance == 0 || world.random.nextInt((int)(exhaustionChance / 500)) == 0) { if (exhaustionChance == 0 || world.random.nextInt((int)(exhaustionChance / 500)) == 0) {
addLevels(-1); addLevels(-1);
} else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) { } else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) {
setEffect(null); setSpell(null);
} else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) { } else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) {
world.createExplosion(this, getX(), getY(), getZ(), getCurrentLevel()/2, DestructionType.BREAK); world.createExplosion(this, getX(), getY(), getZ(), getCurrentLevel()/2, DestructionType.BREAK);
remove(); remove();
@ -223,7 +217,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
public EntityDimensions getDimensions(EntityPose pose) { public EntityDimensions getDimensions(EntityPose pose) {
EntityDimensions dims = super.getDimensions(pose); EntityDimensions dims = super.getDimensions(pose);
if (hasEffect() && getEffect().allowAI()) { if (hasSpell() && getSpell().allowAI()) {
return EntityDimensions.changing(dims.width, 1.5F); return EntityDimensions.changing(dims.width, 1.5F);
} }
@ -257,8 +251,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
int level = getCurrentLevel(); int level = getCurrentLevel();
ItemStack stack = new ItemStack(getItem(), level + 1); ItemStack stack = new ItemStack(getItem(), level + 1);
if (hasEffect()) { if (hasSpell()) {
SpellRegistry.instance().enchantStack(stack, getEffect().getName()); SpellRegistry.instance().enchantStack(stack, getSpell().getName());
} }
dropStack(stack, 0); dropStack(stack, 0);
@ -267,8 +261,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
@Override @Override
public void remove() { public void remove() {
if (hasEffect()) { if (hasSpell()) {
getEffect().onDestroyed(this); getSpell().onDestroyed(this);
} }
super.remove(); super.remove();
} }
@ -279,8 +273,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND); ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND);
if (currentItem != null if (currentItem != null
&& currentItem.getItem() instanceof Castable && currentItem.getItem() instanceof CastableMagicItem
&& ((Castable)currentItem.getItem()).canFeed(this, currentItem) && ((CastableMagicItem)currentItem.getItem()).canFeed(this, currentItem)
&& tryLevelUp(currentItem)) { && tryLevelUp(currentItem)) {
if (!player.abilities.creativeMode) { if (!player.abilities.creativeMode) {
@ -299,8 +293,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
} }
public boolean tryLevelUp(ItemStack stack) { public boolean tryLevelUp(ItemStack stack) {
if (hasEffect() && SpellRegistry.stackHasEnchantment(stack)) { if (hasSpell() && SpellRegistry.stackHasEnchantment(stack)) {
if (!getEffect().getName().contentEquals(SpellRegistry.getKeyFromStack(stack))) { if (!getSpell().getName().contentEquals(SpellRegistry.getKeyFromStack(stack))) {
return false; return false;
} }
@ -316,7 +310,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
@Override @Override
public int getMaxLevel() { public int getMaxLevel() {
return hasEffect() ? getEffect().getMaxLevelCutOff(this) : 0; return hasSpell() ? getSpell().getMaxLevelCutOff(this) : 0;
} }
@Override @Override
@ -347,7 +341,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
setCurrentLevel(compound.getInt("level")); setCurrentLevel(compound.getInt("level"));
if (compound.contains("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setSpell(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
} }
@ -359,15 +353,15 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
compound.putInt("level", getCurrentLevel()); compound.putInt("level", getCurrentLevel());
getOwnerId().ifPresent(id -> compound.putUuid("owner", id)); getOwnerId().ifPresent(id -> compound.putUuid("owner", id));
if (hasEffect()) { if (hasSpell()) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect())); compound.put("effect", SpellRegistry.toNBT(getSpell()));
} }
} }
@Override @Override
public void onNearbySpellChange(Caster<?> source, MagicEffect effect, int newState) { public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
if (hasEffect()) { if (hasSpell()) {
EtherialListener listener = getEffect(EtherialListener.class, true); EtherialListener listener = getSpell(EtherialListener.class, true);
if (listener != null) { if (listener != null) {
listener.onNearbySpellChange(source, effect, newState); listener.onNearbySpellChange(source, effect, newState);
} }

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.entity.player; package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.unicopia.ability.HeightPredicate; import com.minelittlepony.unicopia.ability.HeightPredicate;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityPose;
@ -61,8 +61,8 @@ public final class PlayerDimensions {
} }
private float calculateTargetEyeHeight() { private float calculateTargetEyeHeight() {
if (pony.hasEffect()) { if (pony.hasSpell()) {
MagicEffect effect = pony.getEffect(); Spell effect = pony.getSpell();
if (!effect.isDead() && effect instanceof HeightPredicate) { if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetEyeHeight(pony); float val = ((HeightPredicate)effect).getTargetEyeHeight(pony);
if (val > 0) { if (val > 0) {
@ -79,8 +79,8 @@ public final class PlayerDimensions {
} }
private float calculateTargetBodyHeight() { private float calculateTargetBodyHeight() {
if (pony.hasEffect()) { if (pony.hasSpell()) {
MagicEffect effect = pony.getEffect(); Spell effect = pony.getSpell();
if (!effect.isDead() && effect instanceof HeightPredicate) { if (!effect.isDead() && effect instanceof HeightPredicate) {
float val = ((HeightPredicate)effect).getTargetBodyHeight(pony); float val = ((HeightPredicate)effect).getTargetBodyHeight(pony);
if (val > 0) { if (val > 0) {

View file

@ -6,8 +6,8 @@ import java.util.Map;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.minelittlepony.unicopia.container.HeavyInventory; import com.minelittlepony.unicopia.container.HeavyInventory;
import com.minelittlepony.unicopia.item.MagicGemItem; import com.minelittlepony.unicopia.item.MagicGemItem;
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem; import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem;
import com.minelittlepony.unicopia.magic.MagicalItem; import com.minelittlepony.unicopia.magic.item.MagicItem;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -20,7 +20,7 @@ import net.minecraft.util.Tickable;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public class PlayerInventory implements Tickable, NbtSerialisable { public class PlayerInventory implements Tickable, NbtSerialisable {
private final Map<AddictiveMagicalItem, Entry> dependencies = Maps.newHashMap(); private final Map<AddictiveMagicitem, Entry> dependencies = Maps.newHashMap();
private final Pony player; private final Pony player;
@ -36,7 +36,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
* *
* Bad things might happen when it's removed. * Bad things might happen when it's removed.
*/ */
public synchronized void enforceDependency(AddictiveMagicalItem item) { public synchronized void enforceDependency(AddictiveMagicitem item) {
if (dependencies.containsKey(item)) { if (dependencies.containsKey(item)) {
dependencies.get(item).reinforce(); dependencies.get(item).reinforce();
} else { } else {
@ -47,7 +47,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
/** /**
* Returns how long the player has been wearing the given item. * Returns how long the player has been wearing the given item.
*/ */
public synchronized int getTicksAttached(AddictiveMagicalItem item) { public synchronized int getTicksAttached(AddictiveMagicitem item) {
if (dependencies.containsKey(item)) { if (dependencies.containsKey(item)) {
return dependencies.get(item).ticksAttached; return dependencies.get(item).ticksAttached;
} }
@ -60,7 +60,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
* *
* Zero means not dependent at all / not wearing. * Zero means not dependent at all / not wearing.
*/ */
public synchronized float getNeedfulness(AddictiveMagicalItem item) { public synchronized float getNeedfulness(AddictiveMagicitem item) {
if (dependencies.containsKey(item)) { if (dependencies.containsKey(item)) {
return dependencies.get(item).needfulness; return dependencies.get(item).needfulness;
} }
@ -72,10 +72,10 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
public synchronized void tick() { public synchronized void tick() {
carryingWeight = HeavyInventory.getContentsTotalWorth(player.getOwner().inventory, false); carryingWeight = HeavyInventory.getContentsTotalWorth(player.getOwner().inventory, false);
Iterator<Map.Entry<AddictiveMagicalItem, Entry>> iterator = dependencies.entrySet().iterator(); Iterator<Map.Entry<AddictiveMagicitem, Entry>> iterator = dependencies.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<AddictiveMagicalItem, Entry> entry = iterator.next(); Map.Entry<AddictiveMagicitem, Entry> entry = iterator.next();
Entry item = entry.getValue(); Entry item = entry.getValue();
@ -90,7 +90,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
/** /**
* Checks if the player is wearing the specified magical artifact. * Checks if the player is wearing the specified magical artifact.
*/ */
public boolean isWearing(MagicalItem item) { public boolean isWearing(MagicItem item) {
for (ItemStack i : player.getOwner().getArmorItems()) { for (ItemStack i : player.getOwner().getArmorItems()) {
if (!i.isEmpty() && i.getItem() == item) { if (!i.isEmpty() && i.getItem() == item) {
return true; return true;
@ -147,13 +147,13 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
float needfulness = 1; float needfulness = 1;
AddictiveMagicalItem item; AddictiveMagicitem item;
Entry() { Entry() {
} }
Entry(AddictiveMagicalItem key) { Entry(AddictiveMagicitem key) {
this.item = key; this.item = key;
} }
@ -186,7 +186,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
Item item = Registry.ITEM.get(new Identifier(compound.getString("item"))); Item item = Registry.ITEM.get(new Identifier(compound.getString("item")));
this.item = item instanceof AddictiveMagicalItem ? (AddictiveMagicalItem)item : null; this.item = item instanceof AddictiveMagicitem ? (AddictiveMagicitem)item : null;
} }
} }
} }

View file

@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.FlightPredicate; import com.minelittlepony.unicopia.ability.FlightPredicate;
import com.minelittlepony.unicopia.entity.EntityPhysics; import com.minelittlepony.unicopia.entity.EntityPhysics;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.MutableVector; import com.minelittlepony.unicopia.util.MutableVector;
@ -56,8 +56,8 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
return true; return true;
} }
if (pony.hasEffect()) { if (pony.hasSpell()) {
MagicEffect effect = pony.getEffect(); Spell effect = pony.getSpell();
if (!effect.isDead() && effect instanceof FlightPredicate) { if (!effect.isDead() && effect instanceof FlightPredicate) {
return ((FlightPredicate)effect).checkCanFly(pony); return ((FlightPredicate)effect).checkCanFly(pony);
} }

View file

@ -12,11 +12,11 @@ import com.minelittlepony.unicopia.entity.Physics;
import com.minelittlepony.unicopia.entity.Ponylike; import com.minelittlepony.unicopia.entity.Ponylike;
import com.minelittlepony.unicopia.entity.Trap; import com.minelittlepony.unicopia.entity.Trap;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldMagicEffect; import com.minelittlepony.unicopia.magic.HeldSpell;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.MagicalItem; import com.minelittlepony.unicopia.magic.item.MagicItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.EffectSync;
@ -112,7 +112,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
@Override @Override
public boolean isInvisible() { public boolean isInvisible() {
return invisible && hasEffect(); return invisible && hasSpell();
} }
@Override @Override
@ -121,14 +121,14 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
} }
@Nullable @Nullable
public HeldMagicEffect getHeldEffect(ItemStack stack) { public HeldSpell getHeldSpell(ItemStack stack) {
if (!getSpecies().canCast()) { if (!getSpecies().canCast()) {
heldEffectDelegate.set(null); heldEffectDelegate.set(null);
return null; return null;
} }
HeldMagicEffect heldEffect = heldEffectDelegate.get(HeldMagicEffect.class, true); HeldSpell heldEffect = heldEffectDelegate.get(HeldSpell.class, true);
if (heldEffect == null || !heldEffect.getName().equals(SpellRegistry.getKeyFromStack(stack))) { if (heldEffect == null || !heldEffect.getName().equals(SpellRegistry.getKeyFromStack(stack))) {
heldEffect = SpellRegistry.instance().getHeldFrom(stack); heldEffect = SpellRegistry.instance().getHeldFrom(stack);
@ -219,8 +219,8 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
public void tick() { public void tick() {
gravity.tick(); gravity.tick();
if (hasEffect()) { if (hasSpell()) {
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true); AttachableSpell effect = getSpell(AttachableSpell.class, true);
if (effect != null) { if (effect != null) {
if (entity.getEntityWorld().isClient()) { if (entity.getEntityWorld().isClient()) {
@ -228,17 +228,17 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
} }
if (!effect.updateOnPerson(this)) { if (!effect.updateOnPerson(this)) {
setEffect(null); setSpell(null);
} }
} }
} }
ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND); ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND);
HeldMagicEffect effect = getHeldEffect(stack); HeldSpell effect = getHeldSpell(stack);
if (effect != null) { if (effect != null) {
Affinity affinity = stack.getItem() instanceof MagicalItem ? ((MagicalItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL; Affinity affinity = stack.getItem() instanceof MagicItem ? ((MagicItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL;
effect.updateInHand(this, affinity); effect.updateInHand(this, affinity);
} }
@ -270,8 +270,8 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
@Override @Override
public boolean onProjectileImpact(ProjectileEntity projectile) { public boolean onProjectileImpact(ProjectileEntity projectile) {
if (hasEffect()) { if (hasSpell()) {
MagicEffect effect = getEffect(); Spell effect = getSpell();
if (!effect.isDead() && effect.handleProjectileImpact(projectile)) { if (!effect.isDead() && effect.handleProjectileImpact(projectile)) {
return true; return true;
} }
@ -340,10 +340,10 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
compound.put("powers", powers.toNBT()); compound.put("powers", powers.toNBT());
compound.put("gravity", gravity.toNBT()); compound.put("gravity", gravity.toNBT());
MagicEffect effect = getEffect(); Spell effect = getSpell();
if (effect != null) { if (effect != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect)); compound.put("effect", SpellRegistry.toNBT(effect));
} }
pageStates.toNBT(compound); pageStates.toNBT(compound);
@ -364,28 +364,22 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
} }
public void copyFrom(Pony oldPlayer) { public void copyFrom(Pony oldPlayer) {
setEffect(oldPlayer.getEffect()); setSpell(oldPlayer.getSpell());
setSpecies(oldPlayer.getSpecies()); setSpecies(oldPlayer.getSpecies());
setDirty(); setDirty();
} }
@Override @Override
public void setEffect(@Nullable MagicEffect effect) { public EffectSync getPrimarySpellSlot() {
effectDelegate.set(effect); return effectDelegate;
}
@Override
public void setSpell(@Nullable Spell effect) {
Caster.super.setSpell(effect);
setDirty(); setDirty();
} }
@Override
public boolean hasEffect() {
return effectDelegate.has();
}
@Nullable
@Override
public <T> T getEffect(@Nullable Class<T> type, boolean update) {
return effectDelegate.get(type, update);
}
@Override @Override
public void setOwner(PlayerEntity owner) { public void setOwner(PlayerEntity owner) {
} }

View file

@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.entity.player.MagicReserves; import com.minelittlepony.unicopia.entity.player.MagicReserves;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem; import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -48,7 +48,7 @@ import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType; import net.minecraft.world.explosion.Explosion.DestructionType;
public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem, ItemImpl.TickableItem { public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, ItemImpl.TickableItem {
private static final UUID[] MODIFIERS = new UUID[] { private static final UUID[] MODIFIERS = new UUID[] {
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),

View file

@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.container.BagOfHoldingInventory;
import com.minelittlepony.unicopia.container.UContainers; import com.minelittlepony.unicopia.container.UContainers;
import com.minelittlepony.unicopia.entity.IMagicals; import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.MagicalItem; import com.minelittlepony.unicopia.magic.item.MagicItem;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
@ -37,7 +37,7 @@ import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BagOfHoldingItem extends Item implements MagicalItem { public class BagOfHoldingItem extends Item implements MagicItem {
public BagOfHoldingItem(Settings settings) { public BagOfHoldingItem(Settings settings) {
super(settings); super(settings);

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect; import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -20,7 +20,7 @@ public class CursedMagicGemItem extends MagicGemItem {
} }
@Override @Override
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) { public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableSpell effect) {
BlockPos pos = source.getBlockPos(); BlockPos pos = source.getBlockPos();
World world = source.getWorld(); World world = source.getWorld();
@ -41,7 +41,7 @@ public class CursedMagicGemItem extends MagicGemItem {
} }
@Override @Override
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) { public CastResult onCastSpell(ItemUsageContext context, Spell effect) {
CastResult result = super.onCastSpell(context, effect); CastResult result = super.onCastSpell(context, effect);
if (result != CastResult.NONE) { if (result != CastResult.NONE) {

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.Affine; import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.util.projectile.TossableItem; import com.minelittlepony.unicopia.util.projectile.TossableItem;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -34,9 +34,9 @@ import net.minecraft.world.World;
public class EnchantedStaffItem extends StaffItem implements Affine, TossableItem { public class EnchantedStaffItem extends StaffItem implements Affine, TossableItem {
@Nonnull @Nonnull
private final TossedMagicEffect effect; private final ThrowableSpell effect;
public EnchantedStaffItem(Settings settings, @Nonnull TossedMagicEffect effect) { public EnchantedStaffItem(Settings settings, @Nonnull ThrowableSpell effect) {
super(settings.maxDamage(500)); super(settings.maxDamage(500));
this.effect = effect; this.effect = effect;

View file

@ -8,11 +8,11 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Castable; import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
import com.minelittlepony.unicopia.magic.Dispensable; import com.minelittlepony.unicopia.magic.Dispensable;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.magic.item.CastableMagicItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -35,7 +35,7 @@ import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MagicGemItem extends Item implements Castable { public class MagicGemItem extends Item implements CastableMagicItem {
public MagicGemItem(Settings settings) { public MagicGemItem(Settings settings) {
super(settings); super(settings);
@ -48,7 +48,7 @@ public class MagicGemItem extends Item implements Castable {
} }
@Override @Override
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) { public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableSpell effect) {
Direction facing = source.getBlockState().get(DispenserBlock.FACING); Direction facing = source.getBlockState().get(DispenserBlock.FACING);
BlockPos pos = source.getBlockPos().offset(facing); BlockPos pos = source.getBlockPos().offset(facing);
@ -56,7 +56,7 @@ public class MagicGemItem extends Item implements Castable {
} }
@Override @Override
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) { public CastResult onCastSpell(ItemUsageContext context, Spell effect) {
if (effect instanceof Useable) { if (effect instanceof Useable) {
return ((Useable)effect).onUse(context, getAffinity(context.getStack())); return ((Useable)effect).onUse(context, getAffinity(context.getStack()));
} }
@ -81,7 +81,7 @@ public class MagicGemItem extends Item implements Castable {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
MagicEffect effect = SpellRegistry.instance().getSpellFrom(stack); Spell effect = SpellRegistry.instance().getSpellFrom(stack);
if (effect == null) { if (effect == null) {
return ActionResult.FAIL; return ActionResult.FAIL;
@ -186,7 +186,7 @@ public class MagicGemItem extends Item implements Castable {
@Override @Override
public boolean canFeed(SpellcastEntity entity, ItemStack stack) { public boolean canFeed(SpellcastEntity entity, ItemStack stack) {
MagicEffect effect = entity.getEffect(); Spell effect = entity.getSpell();
return effect != null return effect != null
&& entity.getAffinity() == getAffinity() && entity.getAffinity() == getAffinity()

View file

@ -1,7 +0,0 @@
package com.minelittlepony.unicopia.magic;
import com.minelittlepony.unicopia.entity.player.Pony;
public interface AddictiveMagicalItem extends MagicalItem {
void onRemoved(Pony player, float needfulness);
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic;
/** /**
* A magic effect that does something when attached to an entity. * A magic effect that does something when attached to an entity.
*/ */
public interface AttachedMagicEffect extends MagicEffect { public interface AttachableSpell extends Spell {
/** /**
* Called every tick when attached to a player. * Called every tick when attached to a player.
* *

View file

@ -9,6 +9,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.entity.IMagicals; import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.entity.Owned; import com.minelittlepony.unicopia.entity.Owned;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.particles.ParticleSource; import com.minelittlepony.unicopia.particles.ParticleSource;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -25,14 +26,18 @@ import net.minecraft.world.World;
*/ */
public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affine, IMagicals, ParticleSource { public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affine, IMagicals, ParticleSource {
void setEffect(@Nullable MagicEffect effect); EffectSync getPrimarySpellSlot();
default void setSpell(@Nullable Spell spell) {
getPrimarySpellSlot().set(spell);
}
/** /**
* Gets the active effect for this caster. * Gets the active effect for this caster.
*/ */
@Nullable @Nullable
default MagicEffect getEffect(boolean update) { default Spell getSpell(boolean update) {
return getEffect(null, update); return getSpell(null, update);
} }
/** /**
@ -40,19 +45,21 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
* Returns null if no such effect exists for this caster. * Returns null if no such effect exists for this caster.
*/ */
@Nullable @Nullable
<T> T getEffect(@Nullable Class<T> type, boolean update); default <T> T getSpell(@Nullable Class<T> type, boolean update) {
return getPrimarySpellSlot().get(type, update);
}
/** /**
* Gets the active effect for this caster updating it if needed. * Gets the active effect for this caster updating it if needed.
*/ */
@Nullable @Nullable
default MagicEffect getEffect() { default Spell getSpell() {
return getEffect(true); return getSpell(true);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default <T extends MagicEffect> Optional<T> getEffect(Class<T> type) { default <T extends Spell> Optional<T> getSpell(Class<T> type) {
MagicEffect effect = getEffect(); Spell effect = getSpell();
if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) { if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) {
return Optional.empty(); return Optional.empty();
@ -64,7 +71,9 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
/** /**
* Returns true if this caster has an active effect attached to it. * Returns true if this caster has an active effect attached to it.
*/ */
boolean hasEffect(); default boolean hasSpell() {
return getPrimarySpellSlot().has();
}
/** /**
* Gets the entity directly responsible for casting. * Gets the entity directly responsible for casting.
@ -136,7 +145,7 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
return VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), getOrigin(), radius); return VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), getOrigin(), radius);
} }
default void notifyNearbySpells(MagicEffect sender, BlockPos origin, double radius, int newState) { default void notifyNearbySpells(Spell sender, BlockPos origin, double radius, int newState) {
AwaitTickQueue.enqueueTask(w -> { AwaitTickQueue.enqueueTask(w -> {
VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), origin, radius).filter(i -> i instanceof EtherialListener).forEach(i -> { VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), origin, radius).filter(i -> i instanceof EtherialListener).forEach(i -> {
((EtherialListener)i).onNearbySpellChange(this, sender, newState); ((EtherialListener)i).onNearbySpellChange(this, sender, newState);
@ -144,7 +153,7 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
}); });
} }
default void notifyNearbySpells(MagicEffect sender, double radius, int newState) { default void notifyNearbySpells(Spell sender, double radius, int newState) {
notifyNearbySpells(sender, getOrigin(), radius, newState); notifyNearbySpells(sender, getOrigin(), radius, newState);
} }
} }

View file

@ -50,10 +50,10 @@ public class CasterUtils {
.map(Optional::get); .map(Optional::get);
} }
static <T extends MagicEffect> Optional<T> toMagicEffect(Class<T> type, @Nullable Entity entity) { static <T extends Spell> Optional<T> toMagicEffect(Class<T> type, @Nullable Entity entity) {
return toCaster(entity) return toCaster(entity)
.filter(Caster::hasEffect) .filter(Caster::hasSpell)
.map(caster -> caster.getEffect(type, false)) .map(caster -> caster.getSpell(type, false))
.filter(e -> !e.isDead()); .filter(e -> !e.isDead());
} }

View file

@ -7,7 +7,7 @@ import net.minecraft.util.math.Direction;
/** /**
* Represents an object with an action to perform when dispensed from a dispenser. * Represents an object with an action to perform when dispensed from a dispenser.
*/ */
public interface DispenceableMagicEffect extends MagicEffect { public interface DispenceableSpell extends Spell {
/** /**
* Called when dispensed. * Called when dispensed.

View file

@ -14,5 +14,5 @@ public interface EtherialListener {
* @param effect The spell that dispatched the event * @param effect The spell that dispatched the event
* @param state The new state * @param state The new state
*/ */
void onNearbySpellChange(Caster<?> source, MagicEffect effect, int state); void onNearbySpellChange(Caster<?> source, Spell effect, int state);
} }

View file

@ -5,7 +5,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
/** /**
* Represents a passive spell that does something when held in the player's hand. * Represents a passive spell that does something when held in the player's hand.
*/ */
public interface HeldMagicEffect extends MagicEffect { public interface HeldSpell extends Spell {
/** /**
* Called every tick when held in a player's inventory. * Called every tick when held in a player's inventory.
* *

View file

@ -8,7 +8,7 @@ import net.minecraft.entity.projectile.ProjectileEntity;
/** /**
* Interface for a magic spells * Interface for a magic spells
*/ */
public interface MagicEffect extends NbtSerialisable, Affine { public interface Spell extends NbtSerialisable, Affine {
/** /**
* Gets the name used to identify this effect. * Gets the name used to identify this effect.
@ -102,7 +102,7 @@ public interface MagicEffect extends NbtSerialisable, Affine {
/** /**
* Returns a new, deep-copied instance of this spell. * Returns a new, deep-copied instance of this spell.
*/ */
default MagicEffect copy() { default Spell copy() {
return SpellRegistry.instance().copyInstance(this); return SpellRegistry.instance().copyInstance(this);
} }
} }

View file

@ -13,7 +13,7 @@ public interface Suppressable {
/** /**
* Returns true if this spell can be suppressed by the given other spell and caster. * Returns true if this spell can be suppressed by the given other spell and caster.
*/ */
boolean isVulnerable(Caster<?> otherSource, MagicEffect other); boolean isVulnerable(Caster<?> otherSource, Spell other);
/** /**
* Event triggered when this effect is suppressed. * Event triggered when this effect is suppressed.

View file

@ -20,7 +20,7 @@ import net.minecraft.world.World;
/** /**
* Magic effects that can be thrown. * Magic effects that can be thrown.
*/ */
public interface TossedMagicEffect extends MagicEffect, Tossable<Caster<?>> { public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
@Override @Override
default SoundEvent getThrowSound(Caster<?> caster) { default SoundEvent getThrowSound(Caster<?> caster) {

View file

@ -0,0 +1,10 @@
package com.minelittlepony.unicopia.magic.item;
import com.minelittlepony.unicopia.entity.player.Pony;
/**
* A magical item with addictive properties.
*/
public interface AddictiveMagicitem extends MagicItem {
void onRemoved(Pony player, float needfulness);
}

View file

@ -1,7 +1,11 @@
package com.minelittlepony.unicopia.magic; package com.minelittlepony.unicopia.magic.item;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.Dispensable;
import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -12,11 +16,11 @@ import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface Castable extends MagicalItem, Dispensable { public interface CastableMagicItem extends MagicItem, Dispensable {
@Override @Override
default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) { default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
DispenceableMagicEffect effect = SpellRegistry.instance().getDispenseActionFrom(stack); DispenceableSpell effect = SpellRegistry.instance().getDispenseActionFrom(stack);
if (effect == null) { if (effect == null) {
return new TypedActionResult<>(ActionResult.FAIL, stack); return new TypedActionResult<>(ActionResult.FAIL, stack);
@ -37,22 +41,22 @@ public interface Castable extends MagicalItem, Dispensable {
return new TypedActionResult<>(ActionResult.SUCCESS, stack); return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} }
CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect); CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableSpell effect);
CastResult onCastSpell(ItemUsageContext context, MagicEffect effect); CastResult onCastSpell(ItemUsageContext context, Spell effect);
boolean canFeed(SpellcastEntity spell, ItemStack stack); boolean canFeed(SpellcastEntity spell, ItemStack stack);
/** /**
* Called to cast a spell. The result is an entity spawned with the spell attached. * Called to cast a spell. The result is an entity spawned with the spell attached.
*/ */
default SpellcastEntity castContainedSpell(World world, BlockPos pos, ItemStack stack, MagicEffect effect) { default SpellcastEntity castContainedSpell(World world, BlockPos pos, ItemStack stack, Spell effect) {
SpellcastEntity spell = new SpellcastEntity(UEntities.MAGIC_SPELL, world); SpellcastEntity spell = new SpellcastEntity(UEntities.MAGIC_SPELL, world);
spell.setAffinity(getAffinity(stack)); spell.setAffinity(getAffinity(stack));
spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0); spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0);
world.spawnEntity(spell); world.spawnEntity(spell);
spell.setEffect(effect); spell.setSpell(effect);
return spell; return spell;
} }

View file

@ -1,8 +1,11 @@
package com.minelittlepony.unicopia.magic; package com.minelittlepony.unicopia.magic.item;
import com.minelittlepony.unicopia.magic.Affine;
import com.minelittlepony.unicopia.magic.Affinity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public interface MagicalItem extends Affine { public interface MagicItem extends Affine {
/** /**
* Gets the affinity of this magical artifact. Either good, bad, or unaligned. * Gets the affinity of this magical artifact. Either good, bad, or unaligned.
* What this returns may have effects on the behaviour of certain spells and effects. * What this returns may have effects on the behaviour of certain spells and effects.

View file

@ -1,9 +1,9 @@
package com.minelittlepony.unicopia.magic.spell; package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachedMagicEffect { public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachableSpell {
@Override @Override
public int getMaxLevelCutOff(Caster<?> source) { public int getMaxLevelCutOff(Caster<?> source) {

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.magic.spell; package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
public abstract class AbstractSpell implements MagicEffect { public abstract class AbstractSpell implements Spell {
protected boolean isDead; protected boolean isDead;
protected boolean isDirty; protected boolean isDirty;

View file

@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener; import com.minelittlepony.unicopia.magic.EtherialListener;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
@ -103,7 +103,7 @@ public class AttractiveSpell extends ShieldSpell implements EtherialListener {
} }
@Override @Override
public void onNearbySpellChange(Caster<?> source, MagicEffect effect, int newState) { public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
if (effect instanceof ChargingSpell && !isDead()) { if (effect instanceof ChargingSpell && !isDead()) {
if (newState == ADDED) { if (newState == ADDED) {
if (homingPos == null) { if (homingPos == null) {

View file

@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
import com.mojang.brigadier.StringReader; import com.mojang.brigadier.StringReader;
@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.World; import net.minecraft.world.World;
public class AwkwardSpell extends AbstractSpell implements TossedMagicEffect, Useable { public class AwkwardSpell extends AbstractSpell implements ThrowableSpell, Useable {
@Override @Override
public String getName() { public String getName() {

View file

@ -9,9 +9,9 @@ import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.util.WorldEvent; import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -32,7 +32,7 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEffect, AttachedMagicEffect { public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell, AttachableSpell {
private BlockPos previousTrappedPosition; private BlockPos previousTrappedPosition;
@ -179,10 +179,10 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff
protected void entrap(Caster<?> e) { protected void entrap(Caster<?> e) {
ChangelingTrapSpell existing = e.getEffect(ChangelingTrapSpell.class, true); ChangelingTrapSpell existing = e.getSpell(ChangelingTrapSpell.class, true);
if (existing == null) { if (existing == null) {
e.setEffect(copy()); e.setSpell(copy());
} else { } else {
existing.enforce(e); existing.enforce(e);
} }

View file

@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.EtherialListener; import com.minelittlepony.unicopia.magic.EtherialListener;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Line; import com.minelittlepony.unicopia.util.shape.Line;
@ -33,7 +33,7 @@ public class ChargingSpell extends AbstractLinkedSpell implements EtherialListen
@Override @Override
protected boolean canTargetEntity(SpellcastEntity e) { protected boolean canTargetEntity(SpellcastEntity e) {
return e.hasEffect(); return e.hasSpell();
} }
@Override @Override
@ -86,7 +86,7 @@ public class ChargingSpell extends AbstractLinkedSpell implements EtherialListen
} }
@Override @Override
public void onNearbySpellChange(Caster<?> source, MagicEffect effect, int newState) { public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
if (effect instanceof AttractiveSpell && !isDead()) { if (effect instanceof AttractiveSpell && !isDead()) {
setDead(); setDead();
setDirty(true); setDirty(true);

View file

@ -210,7 +210,7 @@ public class DarknessSpell extends AbstractLinkedSpell {
public boolean isAreaOccupied(Caster<?> source, Vec3d pos) { public boolean isAreaOccupied(Caster<?> source, Vec3d pos) {
if (source.getWorld().isAir(new BlockPos(pos).down())) { if (source.getWorld().isAir(new BlockPos(pos).down())) {
return source.findAllSpellsInRange(100).anyMatch(spell -> { return source.findAllSpellsInRange(100).anyMatch(spell -> {
ShieldSpell effect = spell.getEffect(ShieldSpell.class, false); ShieldSpell effect = spell.getSpell(ShieldSpell.class, false);
if (effect != null) { if (effect != null) {
return pos.distanceTo(spell.getOriginVector()) <= effect.getDrawDropOffRange(spell); return pos.distanceTo(spell.getOriginVector()) <= effect.getDrawDropOffRange(spell);
@ -254,6 +254,6 @@ public class DarknessSpell extends AbstractLinkedSpell {
@Override @Override
protected boolean canTargetEntity(SpellcastEntity e) { protected boolean canTargetEntity(SpellcastEntity e) {
return e.hasEffect() && "light".equals(e.getEffect().getName()); return e.hasSpell() && "light".equals(e.getSpell().getName());
} }
} }

View file

@ -13,9 +13,9 @@ import com.minelittlepony.unicopia.entity.Owned;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Suppressable; import com.minelittlepony.unicopia.magic.Suppressable;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.particles.UParticles;
@ -45,7 +45,7 @@ import net.minecraft.entity.vehicle.MinecartEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, Suppressable, FlightPredicate, HeightPredicate { public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Suppressable, FlightPredicate, HeightPredicate {
@Nonnull @Nonnull
private String entityId = ""; private String entityId = "";
@ -79,7 +79,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect,
} }
@Override @Override
public boolean isVulnerable(Caster<?> otherSource, MagicEffect other) { public boolean isVulnerable(Caster<?> otherSource, Spell other) {
return suppressionCounter <= otherSource.getCurrentLevel(); return suppressionCounter <= otherSource.getCurrentLevel();
} }
@ -189,7 +189,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect,
return; return;
} }
CasterUtils.toCaster(entity).ifPresent(c -> c.setEffect(null)); CasterUtils.toCaster(entity).ifPresent(c -> c.setSpell(null));
if (source.isClient()) { if (source.isClient()) {
source.getWorld().spawnEntity(entity); source.getWorld().spawnEntity(entity);

View file

@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.entity.FollowCasterGoal;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import net.minecraft.entity.ai.goal.SwimGoal; import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -25,7 +25,7 @@ public class FaithfulAssistantSpell extends AbstractSpell {
private static final Box EFFECT_BOUNDS = new Box(-2, -2, -2, 2, 2, 2); private static final Box EFFECT_BOUNDS = new Box(-2, -2, -2, 2, 2, 2);
@Nullable @Nullable
private MagicEffect piggyBackSpell; private Spell piggyBackSpell;
@Override @Override
public String getName() { public String getName() {
@ -87,11 +87,11 @@ public class FaithfulAssistantSpell extends AbstractSpell {
source.getWorld().getEntities(source.getEntity(), bb, e -> e instanceof SpellcastEntity).stream() source.getWorld().getEntities(source.getEntity(), bb, e -> e instanceof SpellcastEntity).stream()
.map(i -> (SpellcastEntity)i) .map(i -> (SpellcastEntity)i)
.filter(i -> i.hasEffect() && !(i.getEffect() instanceof FaithfulAssistantSpell)) .filter(i -> i.hasSpell() && !(i.getSpell() instanceof FaithfulAssistantSpell))
.findFirst().ifPresent(i -> { .findFirst().ifPresent(i -> {
piggyBackSpell = i.getEffect().copy(); piggyBackSpell = i.getSpell().copy();
piggyBackSpell.onPlaced(source); piggyBackSpell.onPlaced(source);
i.setEffect(null); i.setSpell(null);
setDirty(true); setDirty(true);
}); });
} }
@ -115,7 +115,7 @@ public class FaithfulAssistantSpell extends AbstractSpell {
super.toNBT(compound); super.toNBT(compound);
if (piggyBackSpell != null) { if (piggyBackSpell != null) {
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(piggyBackSpell)); compound.put("effect", SpellRegistry.toNBT(piggyBackSpell));
} }
} }

View file

@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect; import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
@ -41,7 +41,7 @@ import net.minecraft.world.World;
/** /**
* Simple fire spell that triggers an effect when used on a block. * Simple fire spell that triggers an effect when used on a block.
*/ */
public class FireSpell extends AbstractRangedAreaSpell implements Useable, DispenceableMagicEffect { public class FireSpell extends AbstractRangedAreaSpell implements Useable, DispenceableSpell {
private static final Shape VISUAL_EFFECT_RANGE = new Sphere(false, 0.5); private static final Shape VISUAL_EFFECT_RANGE = new Sphere(false, 0.5);
private static final Shape EFFECT_RANGE = new Sphere(false, 4); private static final Shape EFFECT_RANGE = new Sphere(false, 4);

View file

@ -3,13 +3,13 @@ package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldMagicEffect; import com.minelittlepony.unicopia.magic.HeldSpell;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
public class FlameSpell extends AbstractSpell implements HeldMagicEffect { public class FlameSpell extends AbstractSpell implements HeldSpell {
@Override @Override
public String getName() { public String getName() {

View file

@ -4,7 +4,7 @@ import java.util.function.Supplier;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
public class GenericSpell extends AbstractSpell { public class GenericSpell extends AbstractSpell {
@ -15,7 +15,7 @@ public class GenericSpell extends AbstractSpell {
private final Affinity affinity; private final Affinity affinity;
static Supplier<MagicEffect> factory(String name, int tint, Affinity affinity) { static Supplier<Spell> factory(String name, int tint, Affinity affinity) {
return () -> new GenericSpell(name, tint, affinity); return () -> new GenericSpell(name, tint, affinity);
} }

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.HeldMagicEffect; import com.minelittlepony.unicopia.magic.HeldSpell;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -12,7 +12,7 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.light.ChunkBlockLightProvider; import net.minecraft.world.chunk.light.ChunkBlockLightProvider;
import net.minecraft.world.chunk.light.ChunkLightingView; import net.minecraft.world.chunk.light.ChunkLightingView;
public class GlowingSpell extends GenericSpell implements HeldMagicEffect { public class GlowingSpell extends GenericSpell implements HeldSpell {
private BlockPos lastPos; private BlockPos lastPos;
private Caster<?> source; private Caster<?> source;

View file

@ -7,7 +7,7 @@ import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect; import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
@ -32,7 +32,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
public class IceSpell extends AbstractRangedAreaSpell implements Useable, DispenceableMagicEffect { public class IceSpell extends AbstractRangedAreaSpell implements Useable, DispenceableSpell {
private final int rad = 3; private final int rad = 3;
private final Shape effect_range = new Sphere(false, rad); private final Shape effect_range = new Sphere(false, rad);

View file

@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
@ -84,7 +84,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
destinationId = null; destinationId = null;
destinationPos = null; destinationPos = null;
getDestinationPortal().ifPresent(MagicEffect::setDead); getDestinationPortal().ifPresent(Spell::setDead);
} }
private PortalSpell bridge; private PortalSpell bridge;
@ -112,18 +112,18 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
Pony prop = Pony.of(context.getPlayer()); Pony prop = Pony.of(context.getPlayer());
PortalSpell other = prop.getEffect(PortalSpell.class, true); PortalSpell other = prop.getSpell(PortalSpell.class, true);
if (other != null) { if (other != null) {
other.getActualInstance().setDestinationPortal(this); other.getActualInstance().setDestinationPortal(this);
if (!context.getWorld().isClient) { if (!context.getWorld().isClient) {
prop.setEffect(null); prop.setSpell(null);
} }
} else { } else {
if (!context.getWorld().isClient) { if (!context.getWorld().isClient) {
bridge = (PortalSpell)copy(); bridge = (PortalSpell)copy();
prop.setEffect(bridge); prop.setSpell(bridge);
} }
} }
@ -234,7 +234,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
} }
if (i instanceof SpellcastEntity) { if (i instanceof SpellcastEntity) {
MagicEffect effect = ((SpellcastEntity) i).getEffect(); Spell effect = ((SpellcastEntity) i).getSpell();
if (effect instanceof PortalSpell) { if (effect instanceof PortalSpell) {
return (PortalSpell)effect; return (PortalSpell)effect;
@ -272,7 +272,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
} }
if (i instanceof SpellcastEntity) { if (i instanceof SpellcastEntity) {
MagicEffect effect = ((SpellcastEntity) i).getEffect(); Spell effect = ((SpellcastEntity) i).getSpell();
if (effect instanceof PortalSpell) { if (effect instanceof PortalSpell) {
sibling = (PortalSpell)effect; sibling = (PortalSpell)effect;

View file

@ -32,7 +32,7 @@ public class RevealingSpell extends AbstractSpell {
@Override @Override
public boolean update(Caster<?> source) { public boolean update(Caster<?> source) {
source.findAllSpellsInRange(15).forEach(e -> { source.findAllSpellsInRange(15).forEach(e -> {
Suppressable spell = e.getEffect(Suppressable.class, false); Suppressable spell = e.getSpell(Suppressable.class, false);
if (spell != null && spell.isVulnerable(source, this)) { if (spell != null && spell.isVulnerable(source, this)) {
spell.onSuppressed(source); spell.onSuppressed(source);

View file

@ -5,7 +5,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.blockstate.StateMaps; import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
@ -17,7 +17,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.explosion.Explosion.DestructionType; import net.minecraft.world.explosion.Explosion.DestructionType;
public class ScorchSpell extends FireSpell implements TossedMagicEffect { public class ScorchSpell extends FireSpell implements ThrowableSpell {
@Override @Override
public String getName() { public String getName() {
@ -68,7 +68,7 @@ public class ScorchSpell extends FireSpell implements TossedMagicEffect {
@Override @Override
@Nullable @Nullable
public AdvancedProjectile toss(Caster<?> caster) { public AdvancedProjectile toss(Caster<?> caster) {
AdvancedProjectile projectile = TossedMagicEffect.super.toss(caster); AdvancedProjectile projectile = ThrowableSpell.super.toss(caster);
if (projectile != null) { if (projectile != null) {
projectile.setGravity(false); projectile.setGravity(false);

View file

@ -6,7 +6,7 @@ import java.util.stream.Collectors;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.AttachableSpell;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.ParticleHandle; import com.minelittlepony.unicopia.particles.ParticleHandle;
@ -20,7 +20,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public class ShieldSpell extends AbstractRangedAreaSpell implements AttachedMagicEffect { public class ShieldSpell extends AbstractRangedAreaSpell implements AttachableSpell {
private final ParticleHandle particlEffect = new ParticleHandle(); private final ParticleHandle particlEffect = new ParticleHandle();

View file

@ -12,9 +12,9 @@ import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect; import com.minelittlepony.unicopia.magic.DispenceableSpell;
import com.minelittlepony.unicopia.magic.HeldMagicEffect; import com.minelittlepony.unicopia.magic.HeldSpell;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.magic.Useable;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -54,7 +54,7 @@ public class SpellRegistry {
} }
@Nullable @Nullable
public MagicEffect getSpellFromName(String name) { public Spell getSpellFromName(String name) {
if (entries.containsKey(name)) { if (entries.containsKey(name)) {
return entries.get(name).create(); return entries.get(name).create();
} }
@ -63,14 +63,14 @@ public class SpellRegistry {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends MagicEffect> T copyInstance(T effect) { public <T extends Spell> T copyInstance(T effect) {
return (T)createEffectFromNBT(serializeEffectToNBT(effect)); return (T)createEffectFromNBT(toNBT(effect));
} }
@Nullable @Nullable
public MagicEffect createEffectFromNBT(CompoundTag compound) { public Spell createEffectFromNBT(CompoundTag compound) {
if (compound.contains("effect_id")) { if (compound.contains("effect_id")) {
MagicEffect effect = getSpellFromName(compound.getString("effect_id")); Spell effect = getSpellFromName(compound.getString("effect_id"));
if (effect != null) { if (effect != null) {
effect.fromNBT(compound); effect.fromNBT(compound);
@ -82,7 +82,7 @@ public class SpellRegistry {
return null; return null;
} }
public CompoundTag serializeEffectToNBT(MagicEffect effect) { public static CompoundTag toNBT(Spell effect) {
CompoundTag compound = effect.toNBT(); CompoundTag compound = effect.toNBT();
compound.putString("effect_id", effect.getName()); compound.putString("effect_id", effect.getName());
@ -95,7 +95,7 @@ public class SpellRegistry {
} }
@Nullable @Nullable
public DispenceableMagicEffect getDispenseActionFrom(ItemStack stack) { public DispenceableSpell getDispenseActionFrom(ItemStack stack) {
return getEntryFromStack(stack).map(Entry::dispensable).orElse(null); return getEntryFromStack(stack).map(Entry::dispensable).orElse(null);
} }
@ -105,16 +105,16 @@ public class SpellRegistry {
} }
@Nullable @Nullable
public HeldMagicEffect getHeldFrom(ItemStack stack) { public HeldSpell getHeldFrom(ItemStack stack) {
return getEntryFromStack(stack).map(Entry::holdable).orElse(null); return getEntryFromStack(stack).map(Entry::holdable).orElse(null);
} }
@Nullable @Nullable
public MagicEffect getSpellFrom(ItemStack stack) { public Spell getSpellFrom(ItemStack stack) {
return getSpellFromName(getKeyFromStack(stack)); return getSpellFromName(getKeyFromStack(stack));
} }
public <T extends MagicEffect> void register(Supplier<T> factory) { public <T extends Spell> void register(Supplier<T> factory) {
try { try {
new Entry<>(factory); new Entry<>(factory);
} catch (Exception e) { } catch (Exception e) {
@ -174,7 +174,7 @@ public class SpellRegistry {
} }
@Immutable @Immutable
class Entry<T extends MagicEffect> { class Entry<T extends Spell> {
final Supplier<T> factory; final Supplier<T> factory;
final int color; final int color;
@ -190,9 +190,9 @@ public class SpellRegistry {
this.factory = factory; this.factory = factory;
this.color = inst.getTint(); this.color = inst.getTint();
this.canDispense = inst instanceof DispenceableMagicEffect; this.canDispense = inst instanceof DispenceableSpell;
this.canUse = inst instanceof Useable; this.canUse = inst instanceof Useable;
this.canHold = inst instanceof HeldMagicEffect; this.canHold = inst instanceof HeldSpell;
this.affinity = inst.getAffinity(); this.affinity = inst.getAffinity();
if (inst.isCraftable()) { if (inst.isCraftable()) {
@ -212,20 +212,20 @@ public class SpellRegistry {
return (Useable)create(); return (Useable)create();
} }
HeldMagicEffect holdable() { HeldSpell holdable() {
if (!canHold) { if (!canHold) {
return null; return null;
} }
return (HeldMagicEffect)create(); return (HeldSpell)create();
} }
DispenceableMagicEffect dispensable() { DispenceableSpell dispensable() {
if (!canDispense) { if (!canDispense) {
return null; return null;
} }
return (DispenceableMagicEffect)create(); return (DispenceableSpell)create();
} }
T create() { T create() {

View file

@ -34,7 +34,7 @@ abstract class MixinEntityRenderDispatcher {
WorldRenderDelegate.INSTANCE.beforeEntityRender(pony, matrices, x, y, z); WorldRenderDelegate.INSTANCE.beforeEntityRender(pony, matrices, x, y, z);
DisguiseSpell effect = pony.getEffect(DisguiseSpell.class, true); DisguiseSpell effect = pony.getSpell(DisguiseSpell.class, true);
if (effect == null || effect.isDead()) { if (effect == null || effect.isDead()) {
return; return;

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.network;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedData;
@ -19,7 +19,7 @@ import net.minecraft.nbt.CompoundTag;
public class EffectSync { public class EffectSync {
@Nullable @Nullable
private MagicEffect effect; private Spell effect;
private final Caster<?> owned; private final Caster<?> owned;
@ -93,7 +93,7 @@ public class EffectSync {
return null; return null;
} }
public void set(@Nullable MagicEffect effect) { public void set(@Nullable Spell effect) {
if (this.effect != null && this.effect != effect) { if (this.effect != null && this.effect != effect) {
this.effect.setDead(); this.effect.setDead();
} }
@ -102,7 +102,7 @@ public class EffectSync {
if (effect == null) { if (effect == null) {
owned.getEntity().getDataTracker().set(param, new CompoundTag()); owned.getEntity().getDataTracker().set(param, new CompoundTag());
} else { } else {
owned.getEntity().getDataTracker().set(param, SpellRegistry.instance().serializeEffectToNBT(effect)); owned.getEntity().getDataTracker().set(param, SpellRegistry.toNBT(effect));
} }
} }
} }

View file

@ -57,7 +57,7 @@ public class ParticleHandle {
public void attach(Caster<?> caster) { public void attach(Caster<?> caster) {
this.linked = true; this.linked = true;
this.caster = Optional.of(caster); this.caster = Optional.of(caster);
effect = caster.getEffect(false).getName(); effect = caster.getSpell(false).getName();
} }
public boolean linked() { public boolean linked() {
@ -68,7 +68,7 @@ public class ParticleHandle {
caster = caster.filter(c -> { caster = caster.filter(c -> {
Entity e = c.getEntity(); Entity e = c.getEntity();
return c.hasEffect() && c.getEffect(false).getName().equals(effect) && e != null && c.getWorld().getEntityById(e.getEntityId()) != null; return c.hasSpell() && c.getSpell(false).getName().equals(effect) && e != null && c.getWorld().getEntityById(e.getEntityId()) != null;
}); });
if (!caster.isPresent()) { if (!caster.isPresent()) {
action.run(); action.run();

View file

@ -5,7 +5,7 @@ import java.util.stream.Stream;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Spell;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.recipe.Utils; import com.minelittlepony.unicopia.recipe.Utils;
@ -17,7 +17,7 @@ import net.minecraft.util.PacketByteBuf;
* Appends that spell to the output when crafting. * Appends that spell to the output when crafting.
*/ */
class SpellPredicate implements Predicate { class SpellPredicate implements Predicate {
private final MagicEffect spell; private final Spell spell;
SpellPredicate(String spell) { SpellPredicate(String spell) {
this.spell = Utils.require(SpellRegistry.instance().getSpellFromName(spell), "Unknown spell tag '" + spell + "'"); this.spell = Utils.require(SpellRegistry.instance().getSpellFromName(spell), "Unknown spell tag '" + spell + "'");

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.util.projectile; package com.minelittlepony.unicopia.util.projectile;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.ThrowableSpell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@ -16,7 +16,7 @@ public interface AdvancedProjectile extends Projectile {
void setOwner(LivingEntity owner); void setOwner(LivingEntity owner);
void setEffect(TossedMagicEffect effect); void setEffect(ThrowableSpell effect);
void setThrowDamage(float damage); void setThrowDamage(float damage);