mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Some terminology changes and cleanup
This commit is contained in:
parent
ad4a449723
commit
2f6ffe43a9
54 changed files with 286 additions and 294 deletions
|
@ -54,7 +54,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
|
|||
|
||||
if (looked instanceof PlayerEntity) {
|
||||
looked = Pony.of((PlayerEntity)looked)
|
||||
.getEffect(DisguiseSpell.class)
|
||||
.getSpell(DisguiseSpell.class)
|
||||
.map(DisguiseSpell::getDisguise)
|
||||
.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);
|
||||
|
||||
iplayer.getEffect(DisguiseSpell.class).orElseGet(() -> {
|
||||
iplayer.getSpell(DisguiseSpell.class).orElseGet(() -> {
|
||||
DisguiseSpell disc = new DisguiseSpell();
|
||||
|
||||
iplayer.setEffect(disc);
|
||||
iplayer.setSpell(disc);
|
||||
return disc;
|
||||
}).setDisguise(looked);
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
@Override
|
||||
public void apply(Pony player, Hit data) {
|
||||
|
||||
if (player.hasEffect()) {
|
||||
String current = player.getEffect().getName();
|
||||
player.setEffect(Streams.stream(player.getOwner().getItemsHand())
|
||||
if (player.hasSpell()) {
|
||||
String current = player.getSpell().getName();
|
||||
player.setSpell(Streams.stream(player.getOwner().getItemsHand())
|
||||
.map(SpellRegistry::getKeyFromStack)
|
||||
.filter(i -> i != null && !current.equals(i))
|
||||
.map(SpellRegistry.instance()::getSpellFromName)
|
||||
|
@ -52,7 +52,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
.findFirst()
|
||||
.orElse(null));
|
||||
} else {
|
||||
player.setEffect(Streams.stream(player.getOwner().getItemsHand())
|
||||
player.setSpell(Streams.stream(player.getOwner().getItemsHand())
|
||||
.map(SpellRegistry.instance()::getSpellFrom)
|
||||
.filter(i -> i != null)
|
||||
.findFirst()
|
||||
|
|
|
@ -5,7 +5,7 @@ import javax.annotation.Nullable;
|
|||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
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.util.Color;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
|
|||
private ModelPart body;
|
||||
|
||||
@Nullable
|
||||
private MagicEffect effect;
|
||||
private Spell effect;
|
||||
|
||||
public GemEntityModel() {
|
||||
textureWidth = 256;
|
||||
|
@ -37,7 +37,7 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ public class DisguiseCommand {
|
|||
throw FAILED_EXCEPTION.create();
|
||||
}
|
||||
|
||||
DisguiseSpell effect = iplayer.getEffect(DisguiseSpell.class, true);
|
||||
DisguiseSpell effect = iplayer.getSpell(DisguiseSpell.class, true);
|
||||
|
||||
if (effect == null) {
|
||||
iplayer.setEffect(new DisguiseSpell().setDisguise(entity));
|
||||
iplayer.setSpell(new DisguiseSpell().setDisguise(entity));
|
||||
} else {
|
||||
effect.setDisguise(entity);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class DisguiseCommand {
|
|||
|
||||
static int reveal(ServerCommandSource source, PlayerEntity player) {
|
||||
Pony iplayer = Pony.of(player);
|
||||
iplayer.getEffect(DisguiseSpell.class).ifPresent(disguise -> {
|
||||
iplayer.getSpell(DisguiseSpell.class).ifPresent(disguise -> {
|
||||
disguise.onDestroyed(iplayer);
|
||||
});
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.entity;
|
|||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
|
||||
|
@ -48,24 +48,14 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(MagicEffect effect) {
|
||||
effectDelegate.set(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getEffect(Class<T> type, boolean update) {
|
||||
return effectDelegate.get(type, update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect() {
|
||||
return effectDelegate.has();
|
||||
public EffectSync getPrimarySpellSlot() {
|
||||
return effectDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (hasEffect()) {
|
||||
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
|
||||
if (hasSpell()) {
|
||||
AttachableSpell effect = getSpell(AttachableSpell.class, true);
|
||||
|
||||
if (effect != null) {
|
||||
if (entity.getEntityWorld().isClient()) {
|
||||
|
@ -73,7 +63,7 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
|
|||
}
|
||||
|
||||
if (!effect.updateOnPerson(this)) {
|
||||
setEffect(null);
|
||||
setSpell(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,10 +98,10 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
|
|||
|
||||
@Override
|
||||
public void toNBT(CompoundTag compound) {
|
||||
MagicEffect effect = getEffect();
|
||||
Spell effect = getSpell();
|
||||
|
||||
if (effect != null) {
|
||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
|
||||
compound.put("effect", SpellRegistry.toNBT(effect));
|
||||
}
|
||||
physics.toNBT(compound);
|
||||
}
|
||||
|
@ -119,7 +109,7 @@ public class Creature implements Ponylike<LivingEntity>, Caster<LivingEntity> {
|
|||
@Override
|
||||
public void fromNBT(CompoundTag compound) {
|
||||
if (compound.contains("effect")) {
|
||||
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
|
||||
setSpell(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
|
||||
}
|
||||
physics.fromNBT(compound);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.UUID;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.EtherialListener;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.TossedMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.magic.ThrowableSpell;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.network.Channel;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
|
@ -114,7 +114,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
|
|||
|
||||
@Override
|
||||
public Affinity getAffinity() {
|
||||
return hasEffect() ? Affinity.NEUTRAL : getEffect().getAffinity();
|
||||
return hasSpell() ? Affinity.NEUTRAL : getSpell().getAffinity();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,29 +123,24 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(TossedMagicEffect effect) {
|
||||
setEffect((MagicEffect)effect);
|
||||
public void setEffect(ThrowableSpell effect) {
|
||||
setSpell(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(MagicEffect effect) {
|
||||
effectDelegate.set(effect);
|
||||
public EffectSync getPrimarySpellSlot() {
|
||||
return effectDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpell(Spell effect) {
|
||||
Caster.super.setSpell(effect);
|
||||
|
||||
if (effect != null) {
|
||||
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
|
||||
public void setThrowDamage(float damage) {
|
||||
getDataTracker().set(DAMAGE, Math.max(0, damage));
|
||||
|
@ -181,21 +176,21 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
|
|||
setNoGravity(false);
|
||||
}
|
||||
|
||||
if (hasEffect()) {
|
||||
if (hasSpell()) {
|
||||
if (lastBlockPos == null || !lastBlockPos.equals(getBlockPos())) {
|
||||
notifyNearbySpells(getEffect(), lastBlockPos, 6, EtherialListener.REMOVED);
|
||||
notifyNearbySpells(getSpell(), lastBlockPos, 6, EtherialListener.REMOVED);
|
||||
lastBlockPos = getBlockPos();
|
||||
notifyNearbySpells(getEffect(), 6, EtherialListener.ADDED);
|
||||
notifyNearbySpells(getSpell(), 6, EtherialListener.ADDED);
|
||||
}
|
||||
|
||||
if (getEffect().isDead()) {
|
||||
if (getSpell().isDead()) {
|
||||
remove();
|
||||
} else {
|
||||
getEffect().update(this);
|
||||
getSpell().update(this);
|
||||
}
|
||||
|
||||
if (world.isClient()) {
|
||||
getEffect().render(this);
|
||||
getSpell().render(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +243,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
|
|||
super.readCustomDataFromTag(compound);
|
||||
|
||||
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) {
|
||||
super.writeCustomDataToTag(compound);
|
||||
|
||||
if (hasEffect()) {
|
||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect()));
|
||||
if (hasSpell()) {
|
||||
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()));
|
||||
}
|
||||
|
||||
if (hasEffect()) {
|
||||
MagicEffect effect = getEffect();
|
||||
if (hasSpell()) {
|
||||
Spell effect = getSpell();
|
||||
|
||||
if (effect instanceof Tossable) {
|
||||
((Tossable<?>)effect).onImpact(this, hit.getBlockPos(), world.getBlockState(hit.getBlockPos()));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.projectile.AdvancedProjectile;
|
||||
|
||||
|
@ -184,6 +184,6 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(TossedMagicEffect effect) {
|
||||
public void setEffect(ThrowableSpell effect) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import com.minelittlepony.unicopia.Race;
|
|||
import com.minelittlepony.unicopia.ducks.PickedItemSupplier;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Castable;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
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.network.EffectSync;
|
||||
|
||||
|
@ -96,8 +96,13 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(@Nullable MagicEffect effect) {
|
||||
effectDelegate.set(effect);
|
||||
public EffectSync getPrimarySpellSlot() {
|
||||
return effectDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpell(@Nullable Spell effect) {
|
||||
Caster.super.setSpell(effect);
|
||||
|
||||
if (effect != null) {
|
||||
effect.onPlaced(this);
|
||||
|
@ -109,17 +114,6 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
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
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
|
@ -131,7 +125,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
|
||||
@Override
|
||||
public ItemStack getPickedStack() {
|
||||
return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getEffect().getName());
|
||||
return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getSpell().getName());
|
||||
}
|
||||
|
||||
protected Item getItem() {
|
||||
|
@ -168,8 +162,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
}
|
||||
|
||||
protected void displayTick() {
|
||||
if (hasEffect()) {
|
||||
getEffect().render(this);
|
||||
if (hasSpell()) {
|
||||
getSpell().render(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,17 +174,17 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
displayTick();
|
||||
}
|
||||
|
||||
if (!hasEffect()) {
|
||||
if (!hasSpell()) {
|
||||
remove();
|
||||
} else {
|
||||
if (getEffect().isDead()) {
|
||||
if (getSpell().isDead()) {
|
||||
remove();
|
||||
onDeath();
|
||||
} else {
|
||||
getEffect().update(this);
|
||||
getSpell().update(this);
|
||||
}
|
||||
|
||||
if (getEffect().allowAI()) {
|
||||
if (getSpell().allowAI()) {
|
||||
super.tickMovement();
|
||||
}
|
||||
}
|
||||
|
@ -200,13 +194,13 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
playSpawnEffects();
|
||||
}
|
||||
|
||||
if (!world.isClient && hasEffect()) {
|
||||
float exhaustionChance = getEffect().getExhaustion(this);
|
||||
if (!world.isClient && hasSpell()) {
|
||||
float exhaustionChance = getSpell().getExhaustion(this);
|
||||
|
||||
if (exhaustionChance == 0 || world.random.nextInt((int)(exhaustionChance / 500)) == 0) {
|
||||
addLevels(-1);
|
||||
} else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) {
|
||||
setEffect(null);
|
||||
setSpell(null);
|
||||
} else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) {
|
||||
world.createExplosion(this, getX(), getY(), getZ(), getCurrentLevel()/2, DestructionType.BREAK);
|
||||
remove();
|
||||
|
@ -223,7 +217,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
public EntityDimensions getDimensions(EntityPose pose) {
|
||||
EntityDimensions dims = super.getDimensions(pose);
|
||||
|
||||
if (hasEffect() && getEffect().allowAI()) {
|
||||
if (hasSpell() && getSpell().allowAI()) {
|
||||
return EntityDimensions.changing(dims.width, 1.5F);
|
||||
}
|
||||
|
||||
|
@ -257,8 +251,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
int level = getCurrentLevel();
|
||||
|
||||
ItemStack stack = new ItemStack(getItem(), level + 1);
|
||||
if (hasEffect()) {
|
||||
SpellRegistry.instance().enchantStack(stack, getEffect().getName());
|
||||
if (hasSpell()) {
|
||||
SpellRegistry.instance().enchantStack(stack, getSpell().getName());
|
||||
}
|
||||
|
||||
dropStack(stack, 0);
|
||||
|
@ -267,8 +261,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (hasEffect()) {
|
||||
getEffect().onDestroyed(this);
|
||||
if (hasSpell()) {
|
||||
getSpell().onDestroyed(this);
|
||||
}
|
||||
super.remove();
|
||||
}
|
||||
|
@ -279,8 +273,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND);
|
||||
|
||||
if (currentItem != null
|
||||
&& currentItem.getItem() instanceof Castable
|
||||
&& ((Castable)currentItem.getItem()).canFeed(this, currentItem)
|
||||
&& currentItem.getItem() instanceof CastableMagicItem
|
||||
&& ((CastableMagicItem)currentItem.getItem()).canFeed(this, currentItem)
|
||||
&& tryLevelUp(currentItem)) {
|
||||
|
||||
if (!player.abilities.creativeMode) {
|
||||
|
@ -299,8 +293,8 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
}
|
||||
|
||||
public boolean tryLevelUp(ItemStack stack) {
|
||||
if (hasEffect() && SpellRegistry.stackHasEnchantment(stack)) {
|
||||
if (!getEffect().getName().contentEquals(SpellRegistry.getKeyFromStack(stack))) {
|
||||
if (hasSpell() && SpellRegistry.stackHasEnchantment(stack)) {
|
||||
if (!getSpell().getName().contentEquals(SpellRegistry.getKeyFromStack(stack))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -316,7 +310,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return hasEffect() ? getEffect().getMaxLevelCutOff(this) : 0;
|
||||
return hasSpell() ? getSpell().getMaxLevelCutOff(this) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -347,7 +341,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
|
|||
setCurrentLevel(compound.getInt("level"));
|
||||
|
||||
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());
|
||||
getOwnerId().ifPresent(id -> compound.putUuid("owner", id));
|
||||
|
||||
if (hasEffect()) {
|
||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(getEffect()));
|
||||
if (hasSpell()) {
|
||||
compound.put("effect", SpellRegistry.toNBT(getSpell()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNearbySpellChange(Caster<?> source, MagicEffect effect, int newState) {
|
||||
if (hasEffect()) {
|
||||
EtherialListener listener = getEffect(EtherialListener.class, true);
|
||||
public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
|
||||
if (hasSpell()) {
|
||||
EtherialListener listener = getSpell(EtherialListener.class, true);
|
||||
if (listener != null) {
|
||||
listener.onNearbySpellChange(source, effect, newState);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
|
||||
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.EntityPose;
|
||||
|
@ -61,8 +61,8 @@ public final class PlayerDimensions {
|
|||
}
|
||||
|
||||
private float calculateTargetEyeHeight() {
|
||||
if (pony.hasEffect()) {
|
||||
MagicEffect effect = pony.getEffect();
|
||||
if (pony.hasSpell()) {
|
||||
Spell effect = pony.getSpell();
|
||||
if (!effect.isDead() && effect instanceof HeightPredicate) {
|
||||
float val = ((HeightPredicate)effect).getTargetEyeHeight(pony);
|
||||
if (val > 0) {
|
||||
|
@ -79,8 +79,8 @@ public final class PlayerDimensions {
|
|||
}
|
||||
|
||||
private float calculateTargetBodyHeight() {
|
||||
if (pony.hasEffect()) {
|
||||
MagicEffect effect = pony.getEffect();
|
||||
if (pony.hasSpell()) {
|
||||
Spell effect = pony.getSpell();
|
||||
if (!effect.isDead() && effect instanceof HeightPredicate) {
|
||||
float val = ((HeightPredicate)effect).getTargetBodyHeight(pony);
|
||||
if (val > 0) {
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Map;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.unicopia.container.HeavyInventory;
|
||||
import com.minelittlepony.unicopia.item.MagicGemItem;
|
||||
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
|
||||
import com.minelittlepony.unicopia.magic.MagicalItem;
|
||||
import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem;
|
||||
import com.minelittlepony.unicopia.magic.item.MagicItem;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -20,7 +20,7 @@ import net.minecraft.util.Tickable;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
*
|
||||
* Bad things might happen when it's removed.
|
||||
*/
|
||||
public synchronized void enforceDependency(AddictiveMagicalItem item) {
|
||||
public synchronized void enforceDependency(AddictiveMagicitem item) {
|
||||
if (dependencies.containsKey(item)) {
|
||||
dependencies.get(item).reinforce();
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
/**
|
||||
* 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)) {
|
||||
return dependencies.get(item).ticksAttached;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
*
|
||||
* Zero means not dependent at all / not wearing.
|
||||
*/
|
||||
public synchronized float getNeedfulness(AddictiveMagicalItem item) {
|
||||
public synchronized float getNeedfulness(AddictiveMagicitem item) {
|
||||
if (dependencies.containsKey(item)) {
|
||||
return dependencies.get(item).needfulness;
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
public synchronized void tick() {
|
||||
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()) {
|
||||
Map.Entry<AddictiveMagicalItem, Entry> entry = iterator.next();
|
||||
Map.Entry<AddictiveMagicitem, Entry> entry = iterator.next();
|
||||
|
||||
Entry item = entry.getValue();
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
/**
|
||||
* 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()) {
|
||||
if (!i.isEmpty() && i.getItem() == item) {
|
||||
return true;
|
||||
|
@ -147,13 +147,13 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
|
||||
float needfulness = 1;
|
||||
|
||||
AddictiveMagicalItem item;
|
||||
AddictiveMagicitem item;
|
||||
|
||||
Entry() {
|
||||
|
||||
}
|
||||
|
||||
Entry(AddictiveMagicalItem key) {
|
||||
Entry(AddictiveMagicitem key) {
|
||||
this.item = key;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Race;
|
|||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.ability.FlightPredicate;
|
||||
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.util.NbtSerialisable;
|
||||
import com.minelittlepony.unicopia.util.MutableVector;
|
||||
|
@ -56,8 +56,8 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
|||
return true;
|
||||
}
|
||||
|
||||
if (pony.hasEffect()) {
|
||||
MagicEffect effect = pony.getEffect();
|
||||
if (pony.hasSpell()) {
|
||||
Spell effect = pony.getSpell();
|
||||
if (!effect.isDead() && effect instanceof FlightPredicate) {
|
||||
return ((FlightPredicate)effect).checkCanFly(pony);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import com.minelittlepony.unicopia.entity.Physics;
|
|||
import com.minelittlepony.unicopia.entity.Ponylike;
|
||||
import com.minelittlepony.unicopia.entity.Trap;
|
||||
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.HeldMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.MagicalItem;
|
||||
import com.minelittlepony.unicopia.magic.HeldSpell;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.magic.item.MagicItem;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.network.Channel;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
|
@ -112,7 +112,7 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
return invisible && hasEffect();
|
||||
return invisible && hasSpell();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,14 +121,14 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public HeldMagicEffect getHeldEffect(ItemStack stack) {
|
||||
public HeldSpell getHeldSpell(ItemStack stack) {
|
||||
|
||||
if (!getSpecies().canCast()) {
|
||||
heldEffectDelegate.set(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))) {
|
||||
heldEffect = SpellRegistry.instance().getHeldFrom(stack);
|
||||
|
@ -219,8 +219,8 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
public void tick() {
|
||||
gravity.tick();
|
||||
|
||||
if (hasEffect()) {
|
||||
AttachedMagicEffect effect = getEffect(AttachedMagicEffect.class, true);
|
||||
if (hasSpell()) {
|
||||
AttachableSpell effect = getSpell(AttachableSpell.class, true);
|
||||
|
||||
if (effect != null) {
|
||||
if (entity.getEntityWorld().isClient()) {
|
||||
|
@ -228,17 +228,17 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
}
|
||||
|
||||
if (!effect.updateOnPerson(this)) {
|
||||
setEffect(null);
|
||||
setSpell(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = entity.getStackInHand(Hand.MAIN_HAND);
|
||||
|
||||
HeldMagicEffect effect = getHeldEffect(stack);
|
||||
HeldSpell effect = getHeldSpell(stack);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -270,8 +270,8 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
|
||||
@Override
|
||||
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
||||
if (hasEffect()) {
|
||||
MagicEffect effect = getEffect();
|
||||
if (hasSpell()) {
|
||||
Spell effect = getSpell();
|
||||
if (!effect.isDead() && effect.handleProjectileImpact(projectile)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -340,10 +340,10 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
compound.put("powers", powers.toNBT());
|
||||
compound.put("gravity", gravity.toNBT());
|
||||
|
||||
MagicEffect effect = getEffect();
|
||||
Spell effect = getSpell();
|
||||
|
||||
if (effect != null) {
|
||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(effect));
|
||||
compound.put("effect", SpellRegistry.toNBT(effect));
|
||||
}
|
||||
|
||||
pageStates.toNBT(compound);
|
||||
|
@ -364,28 +364,22 @@ public class Pony implements Caster<PlayerEntity>, Ponylike<PlayerEntity>, Trans
|
|||
}
|
||||
|
||||
public void copyFrom(Pony oldPlayer) {
|
||||
setEffect(oldPlayer.getEffect());
|
||||
setSpell(oldPlayer.getSpell());
|
||||
setSpecies(oldPlayer.getSpecies());
|
||||
setDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(@Nullable MagicEffect effect) {
|
||||
effectDelegate.set(effect);
|
||||
public EffectSync getPrimarySpellSlot() {
|
||||
return effectDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpell(@Nullable Spell effect) {
|
||||
Caster.super.setSpell(effect);
|
||||
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
|
||||
public void setOwner(PlayerEntity owner) {
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.entity.ItemImpl;
|
|||
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
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.VecHelper;
|
||||
|
||||
|
@ -48,7 +48,7 @@ import net.minecraft.world.LocalDifficulty;
|
|||
import net.minecraft.world.World;
|
||||
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[] {
|
||||
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.container.BagOfHoldingInventory;
|
|||
import com.minelittlepony.unicopia.container.UContainers;
|
||||
import com.minelittlepony.unicopia.entity.IMagicals;
|
||||
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 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.world.World;
|
||||
|
||||
public class BagOfHoldingItem extends Item implements MagicalItem {
|
||||
public class BagOfHoldingItem extends Item implements MagicItem {
|
||||
|
||||
public BagOfHoldingItem(Settings settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.item;
|
|||
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableSpell;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -20,7 +20,7 @@ public class CursedMagicGemItem extends MagicGemItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableMagicEffect effect) {
|
||||
public CastResult onDispenseSpell(BlockPointer source, ItemStack stack, DispenceableSpell effect) {
|
||||
|
||||
BlockPos pos = source.getBlockPos();
|
||||
World world = source.getWorld();
|
||||
|
@ -41,7 +41,7 @@ public class CursedMagicGemItem extends MagicGemItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
|
||||
public CastResult onCastSpell(ItemUsageContext context, Spell effect) {
|
||||
CastResult result = super.onCastSpell(context, effect);
|
||||
|
||||
if (result != CastResult.NONE) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.magic.Affinity;
|
|||
import com.minelittlepony.unicopia.magic.CasterUtils;
|
||||
import com.minelittlepony.unicopia.magic.Affine;
|
||||
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 net.minecraft.block.BlockState;
|
||||
|
@ -34,9 +34,9 @@ import net.minecraft.world.World;
|
|||
public class EnchantedStaffItem extends StaffItem implements Affine, TossableItem {
|
||||
|
||||
@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));
|
||||
|
||||
this.effect = effect;
|
||||
|
|
|
@ -8,11 +8,11 @@ import com.minelittlepony.unicopia.EquinePredicates;
|
|||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
import com.minelittlepony.unicopia.magic.Castable;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableSpell;
|
||||
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.item.CastableMagicItem;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import net.minecraft.util.Rarity;
|
|||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MagicGemItem extends Item implements Castable {
|
||||
public class MagicGemItem extends Item implements CastableMagicItem {
|
||||
|
||||
public MagicGemItem(Settings settings) {
|
||||
super(settings);
|
||||
|
@ -48,7 +48,7 @@ public class MagicGemItem extends Item implements Castable {
|
|||
}
|
||||
|
||||
@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);
|
||||
BlockPos pos = source.getBlockPos().offset(facing);
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class MagicGemItem extends Item implements Castable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CastResult onCastSpell(ItemUsageContext context, MagicEffect effect) {
|
||||
public CastResult onCastSpell(ItemUsageContext context, Spell effect) {
|
||||
if (effect instanceof Useable) {
|
||||
return ((Useable)effect).onUse(context, getAffinity(context.getStack()));
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class MagicGemItem extends Item implements Castable {
|
|||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
MagicEffect effect = SpellRegistry.instance().getSpellFrom(stack);
|
||||
Spell effect = SpellRegistry.instance().getSpellFrom(stack);
|
||||
|
||||
if (effect == null) {
|
||||
return ActionResult.FAIL;
|
||||
|
@ -186,7 +186,7 @@ public class MagicGemItem extends Item implements Castable {
|
|||
|
||||
@Override
|
||||
public boolean canFeed(SpellcastEntity entity, ItemStack stack) {
|
||||
MagicEffect effect = entity.getEffect();
|
||||
Spell effect = entity.getSpell();
|
||||
|
||||
return effect != null
|
||||
&& entity.getAffinity() == getAffinity()
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic;
|
|||
/**
|
||||
* 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.
|
||||
*
|
|
@ -9,6 +9,7 @@ import javax.annotation.Nullable;
|
|||
import com.minelittlepony.unicopia.AwaitTickQueue;
|
||||
import com.minelittlepony.unicopia.entity.IMagicals;
|
||||
import com.minelittlepony.unicopia.entity.Owned;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
import com.minelittlepony.unicopia.particles.ParticleSource;
|
||||
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 {
|
||||
|
||||
void setEffect(@Nullable MagicEffect effect);
|
||||
EffectSync getPrimarySpellSlot();
|
||||
|
||||
default void setSpell(@Nullable Spell spell) {
|
||||
getPrimarySpellSlot().set(spell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the active effect for this caster.
|
||||
*/
|
||||
@Nullable
|
||||
default MagicEffect getEffect(boolean update) {
|
||||
return getEffect(null, update);
|
||||
default Spell getSpell(boolean 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.
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@Nullable
|
||||
default MagicEffect getEffect() {
|
||||
return getEffect(true);
|
||||
default Spell getSpell() {
|
||||
return getSpell(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T extends MagicEffect> Optional<T> getEffect(Class<T> type) {
|
||||
MagicEffect effect = getEffect();
|
||||
default <T extends Spell> Optional<T> getSpell(Class<T> type) {
|
||||
Spell effect = getSpell();
|
||||
|
||||
if (effect == null || effect.isDead() || !type.isAssignableFrom(effect.getClass())) {
|
||||
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.
|
||||
*/
|
||||
boolean hasEffect();
|
||||
default boolean hasSpell() {
|
||||
return getPrimarySpellSlot().has();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
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 -> {
|
||||
VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), origin, radius).filter(i -> i instanceof EtherialListener).forEach(i -> {
|
||||
((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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ public class CasterUtils {
|
|||
.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)
|
||||
.filter(Caster::hasEffect)
|
||||
.map(caster -> caster.getEffect(type, false))
|
||||
.filter(Caster::hasSpell)
|
||||
.map(caster -> caster.getSpell(type, false))
|
||||
.filter(e -> !e.isDead());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.util.math.Direction;
|
|||
/**
|
||||
* 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.
|
|
@ -14,5 +14,5 @@ public interface EtherialListener {
|
|||
* @param effect The spell that dispatched the event
|
||||
* @param state The new state
|
||||
*/
|
||||
void onNearbySpellChange(Caster<?> source, MagicEffect effect, int state);
|
||||
void onNearbySpellChange(Caster<?> source, Spell effect, int state);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
public interface HeldMagicEffect extends MagicEffect {
|
||||
public interface HeldSpell extends Spell {
|
||||
/**
|
||||
* Called every tick when held in a player's inventory.
|
||||
*
|
|
@ -8,7 +8,7 @@ import net.minecraft.entity.projectile.ProjectileEntity;
|
|||
/**
|
||||
* 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.
|
||||
|
@ -102,7 +102,7 @@ public interface MagicEffect extends NbtSerialisable, Affine {
|
|||
/**
|
||||
* Returns a new, deep-copied instance of this spell.
|
||||
*/
|
||||
default MagicEffect copy() {
|
||||
default Spell copy() {
|
||||
return SpellRegistry.instance().copyInstance(this);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ public interface Suppressable {
|
|||
/**
|
||||
* 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.
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Magic effects that can be thrown.
|
||||
*/
|
||||
public interface TossedMagicEffect extends MagicEffect, Tossable<Caster<?>> {
|
||||
public interface ThrowableSpell extends Spell, Tossable<Caster<?>> {
|
||||
|
||||
@Override
|
||||
default SoundEvent getThrowSound(Caster<?> caster) {
|
|
@ -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);
|
||||
}
|
|
@ -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.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 net.minecraft.item.ItemStack;
|
||||
|
@ -12,11 +16,11 @@ import net.minecraft.util.math.BlockPointer;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface Castable extends MagicalItem, Dispensable {
|
||||
public interface CastableMagicItem extends MagicItem, Dispensable {
|
||||
|
||||
@Override
|
||||
default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
|
||||
DispenceableMagicEffect effect = SpellRegistry.instance().getDispenseActionFrom(stack);
|
||||
DispenceableSpell effect = SpellRegistry.instance().getDispenseActionFrom(stack);
|
||||
|
||||
if (effect == null) {
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
|
@ -37,22 +41,22 @@ public interface Castable extends MagicalItem, Dispensable {
|
|||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
spell.setAffinity(getAffinity(stack));
|
||||
spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0);
|
||||
world.spawnEntity(spell);
|
||||
spell.setEffect(effect);
|
||||
spell.setSpell(effect);
|
||||
|
||||
return spell;
|
||||
}
|
|
@ -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;
|
||||
|
||||
public interface MagicalItem extends Affine {
|
||||
public interface MagicItem extends Affine {
|
||||
/**
|
||||
* 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.
|
|
@ -1,9 +1,9 @@
|
|||
package com.minelittlepony.unicopia.magic.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.AttachableSpell;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
|
||||
public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachedMagicEffect {
|
||||
public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachableSpell {
|
||||
|
||||
@Override
|
||||
public int getMaxLevelCutOff(Caster<?> source) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.minelittlepony.unicopia.magic.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public abstract class AbstractSpell implements MagicEffect {
|
||||
public abstract class AbstractSpell implements Spell {
|
||||
|
||||
protected boolean isDead;
|
||||
protected boolean isDirty;
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
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.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
@ -103,7 +103,7 @@ public class AttractiveSpell extends ShieldSpell implements EtherialListener {
|
|||
}
|
||||
|
||||
@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 (newState == ADDED) {
|
||||
if (homingPos == null) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.magic.Affinity;
|
|||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
import com.minelittlepony.unicopia.magic.CasterUtils;
|
||||
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.util.shape.Sphere;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
|
@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AwkwardSpell extends AbstractSpell implements TossedMagicEffect, Useable {
|
||||
public class AwkwardSpell extends AbstractSpell implements ThrowableSpell, Useable {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -9,9 +9,9 @@ import com.minelittlepony.unicopia.entity.IMagicals;
|
|||
import com.minelittlepony.unicopia.entity.UEntities;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.TossedMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.ThrowableSpell;
|
||||
import com.minelittlepony.unicopia.util.WorldEvent;
|
||||
|
||||
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.Direction;
|
||||
|
||||
public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEffect, AttachedMagicEffect {
|
||||
public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell, AttachableSpell {
|
||||
|
||||
private BlockPos previousTrappedPosition;
|
||||
|
||||
|
@ -179,10 +179,10 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff
|
|||
|
||||
protected void entrap(Caster<?> e) {
|
||||
|
||||
ChangelingTrapSpell existing = e.getEffect(ChangelingTrapSpell.class, true);
|
||||
ChangelingTrapSpell existing = e.getSpell(ChangelingTrapSpell.class, true);
|
||||
|
||||
if (existing == null) {
|
||||
e.setEffect(copy());
|
||||
e.setSpell(copy());
|
||||
} else {
|
||||
existing.enforce(e);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
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.util.shape.Shape;
|
||||
import com.minelittlepony.unicopia.util.shape.Line;
|
||||
|
@ -33,7 +33,7 @@ public class ChargingSpell extends AbstractLinkedSpell implements EtherialListen
|
|||
|
||||
@Override
|
||||
protected boolean canTargetEntity(SpellcastEntity e) {
|
||||
return e.hasEffect();
|
||||
return e.hasSpell();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +86,7 @@ public class ChargingSpell extends AbstractLinkedSpell implements EtherialListen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNearbySpellChange(Caster<?> source, MagicEffect effect, int newState) {
|
||||
public void onNearbySpellChange(Caster<?> source, Spell effect, int newState) {
|
||||
if (effect instanceof AttractiveSpell && !isDead()) {
|
||||
setDead();
|
||||
setDirty(true);
|
||||
|
|
|
@ -210,7 +210,7 @@ public class DarknessSpell extends AbstractLinkedSpell {
|
|||
public boolean isAreaOccupied(Caster<?> source, Vec3d pos) {
|
||||
if (source.getWorld().isAir(new BlockPos(pos).down())) {
|
||||
return source.findAllSpellsInRange(100).anyMatch(spell -> {
|
||||
ShieldSpell effect = spell.getEffect(ShieldSpell.class, false);
|
||||
ShieldSpell effect = spell.getSpell(ShieldSpell.class, false);
|
||||
|
||||
if (effect != null) {
|
||||
return pos.distanceTo(spell.getOriginVector()) <= effect.getDrawDropOffRange(spell);
|
||||
|
@ -254,6 +254,6 @@ public class DarknessSpell extends AbstractLinkedSpell {
|
|||
|
||||
@Override
|
||||
protected boolean canTargetEntity(SpellcastEntity e) {
|
||||
return e.hasEffect() && "light".equals(e.getEffect().getName());
|
||||
return e.hasSpell() && "light".equals(e.getSpell().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import com.minelittlepony.unicopia.entity.Owned;
|
|||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.magic.Suppressable;
|
||||
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
|
||||
import com.minelittlepony.unicopia.particles.UParticles;
|
||||
|
@ -45,7 +45,7 @@ import net.minecraft.entity.vehicle.MinecartEntity;
|
|||
import net.minecraft.item.ItemStack;
|
||||
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
|
||||
private String entityId = "";
|
||||
|
@ -79,7 +79,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isVulnerable(Caster<?> otherSource, MagicEffect other) {
|
||||
public boolean isVulnerable(Caster<?> otherSource, Spell other) {
|
||||
return suppressionCounter <= otherSource.getCurrentLevel();
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect,
|
|||
return;
|
||||
}
|
||||
|
||||
CasterUtils.toCaster(entity).ifPresent(c -> c.setEffect(null));
|
||||
CasterUtils.toCaster(entity).ifPresent(c -> c.setSpell(null));
|
||||
|
||||
if (source.isClient()) {
|
||||
source.getWorld().spawnEntity(entity);
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.entity.FollowCasterGoal;
|
|||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.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);
|
||||
|
||||
@Nullable
|
||||
private MagicEffect piggyBackSpell;
|
||||
private Spell piggyBackSpell;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -87,11 +87,11 @@ public class FaithfulAssistantSpell extends AbstractSpell {
|
|||
|
||||
source.getWorld().getEntities(source.getEntity(), bb, e -> e instanceof SpellcastEntity).stream()
|
||||
.map(i -> (SpellcastEntity)i)
|
||||
.filter(i -> i.hasEffect() && !(i.getEffect() instanceof FaithfulAssistantSpell))
|
||||
.filter(i -> i.hasSpell() && !(i.getSpell() instanceof FaithfulAssistantSpell))
|
||||
.findFirst().ifPresent(i -> {
|
||||
piggyBackSpell = i.getEffect().copy();
|
||||
piggyBackSpell = i.getSpell().copy();
|
||||
piggyBackSpell.onPlaced(source);
|
||||
i.setEffect(null);
|
||||
i.setSpell(null);
|
||||
setDirty(true);
|
||||
});
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class FaithfulAssistantSpell extends AbstractSpell {
|
|||
super.toNBT(compound);
|
||||
|
||||
if (piggyBackSpell != null) {
|
||||
compound.put("effect", SpellRegistry.instance().serializeEffectToNBT(piggyBackSpell));
|
||||
compound.put("effect", SpellRegistry.toNBT(piggyBackSpell));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.entity.IMagicals;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
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.util.MagicalDamageSource;
|
||||
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.
|
||||
*/
|
||||
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 EFFECT_RANGE = new Sphere(false, 4);
|
||||
|
|
|
@ -3,13 +3,13 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.player.PlayerEntity;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
|
||||
public class FlameSpell extends AbstractSpell implements HeldMagicEffect {
|
||||
public class FlameSpell extends AbstractSpell implements HeldSpell {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
|
||||
|
||||
public class GenericSpell extends AbstractSpell {
|
||||
|
@ -15,7 +15,7 @@ public class GenericSpell extends AbstractSpell {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.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.ChunkLightingView;
|
||||
|
||||
public class GlowingSpell extends GenericSpell implements HeldMagicEffect {
|
||||
public class GlowingSpell extends GenericSpell implements HeldSpell {
|
||||
|
||||
private BlockPos lastPos;
|
||||
private Caster<?> source;
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.minelittlepony.unicopia.blockstate.StateMaps;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
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.util.MagicalDamageSource;
|
||||
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.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 Shape effect_range = new Sphere(false, rad);
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
|
|||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
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.particles.MagicParticleEffect;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
@ -84,7 +84,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
|
|||
destinationId = null;
|
||||
destinationPos = null;
|
||||
|
||||
getDestinationPortal().ifPresent(MagicEffect::setDead);
|
||||
getDestinationPortal().ifPresent(Spell::setDead);
|
||||
}
|
||||
|
||||
private PortalSpell bridge;
|
||||
|
@ -112,18 +112,18 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
|
|||
|
||||
Pony prop = Pony.of(context.getPlayer());
|
||||
|
||||
PortalSpell other = prop.getEffect(PortalSpell.class, true);
|
||||
PortalSpell other = prop.getSpell(PortalSpell.class, true);
|
||||
if (other != null) {
|
||||
other.getActualInstance().setDestinationPortal(this);
|
||||
|
||||
if (!context.getWorld().isClient) {
|
||||
prop.setEffect(null);
|
||||
prop.setSpell(null);
|
||||
}
|
||||
} else {
|
||||
if (!context.getWorld().isClient) {
|
||||
bridge = (PortalSpell)copy();
|
||||
|
||||
prop.setEffect(bridge);
|
||||
prop.setSpell(bridge);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
|
|||
}
|
||||
|
||||
if (i instanceof SpellcastEntity) {
|
||||
MagicEffect effect = ((SpellcastEntity) i).getEffect();
|
||||
Spell effect = ((SpellcastEntity) i).getSpell();
|
||||
|
||||
if (effect instanceof PortalSpell) {
|
||||
return (PortalSpell)effect;
|
||||
|
@ -272,7 +272,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable {
|
|||
}
|
||||
|
||||
if (i instanceof SpellcastEntity) {
|
||||
MagicEffect effect = ((SpellcastEntity) i).getEffect();
|
||||
Spell effect = ((SpellcastEntity) i).getSpell();
|
||||
|
||||
if (effect instanceof PortalSpell) {
|
||||
sibling = (PortalSpell)effect;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class RevealingSpell extends AbstractSpell {
|
|||
@Override
|
||||
public boolean update(Caster<?> source) {
|
||||
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)) {
|
||||
spell.onSuppressed(source);
|
||||
|
|
|
@ -5,7 +5,7 @@ import javax.annotation.Nullable;
|
|||
import com.minelittlepony.unicopia.blockstate.StateMaps;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
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.util.PosHelper;
|
||||
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.world.explosion.Explosion.DestructionType;
|
||||
|
||||
public class ScorchSpell extends FireSpell implements TossedMagicEffect {
|
||||
public class ScorchSpell extends FireSpell implements ThrowableSpell {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -68,7 +68,7 @@ public class ScorchSpell extends FireSpell implements TossedMagicEffect {
|
|||
@Override
|
||||
@Nullable
|
||||
public AdvancedProjectile toss(Caster<?> caster) {
|
||||
AdvancedProjectile projectile = TossedMagicEffect.super.toss(caster);
|
||||
AdvancedProjectile projectile = ThrowableSpell.super.toss(caster);
|
||||
|
||||
if (projectile != null) {
|
||||
projectile.setGravity(false);
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
|||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
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.particles.MagicParticleEffect;
|
||||
import com.minelittlepony.unicopia.particles.ParticleHandle;
|
||||
|
@ -20,7 +20,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.sound.SoundEvents;
|
||||
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();
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import javax.annotation.Nullable;
|
|||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.HeldMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.DispenceableSpell;
|
||||
import com.minelittlepony.unicopia.magic.HeldSpell;
|
||||
import com.minelittlepony.unicopia.magic.Spell;
|
||||
import com.minelittlepony.unicopia.magic.Useable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -54,7 +54,7 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public MagicEffect getSpellFromName(String name) {
|
||||
public Spell getSpellFromName(String name) {
|
||||
if (entries.containsKey(name)) {
|
||||
return entries.get(name).create();
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends MagicEffect> T copyInstance(T effect) {
|
||||
return (T)createEffectFromNBT(serializeEffectToNBT(effect));
|
||||
public <T extends Spell> T copyInstance(T effect) {
|
||||
return (T)createEffectFromNBT(toNBT(effect));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MagicEffect createEffectFromNBT(CompoundTag compound) {
|
||||
public Spell createEffectFromNBT(CompoundTag compound) {
|
||||
if (compound.contains("effect_id")) {
|
||||
MagicEffect effect = getSpellFromName(compound.getString("effect_id"));
|
||||
Spell effect = getSpellFromName(compound.getString("effect_id"));
|
||||
|
||||
if (effect != null) {
|
||||
effect.fromNBT(compound);
|
||||
|
@ -82,7 +82,7 @@ public class SpellRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
public CompoundTag serializeEffectToNBT(MagicEffect effect) {
|
||||
public static CompoundTag toNBT(Spell effect) {
|
||||
CompoundTag compound = effect.toNBT();
|
||||
|
||||
compound.putString("effect_id", effect.getName());
|
||||
|
@ -95,7 +95,7 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public DispenceableMagicEffect getDispenseActionFrom(ItemStack stack) {
|
||||
public DispenceableSpell getDispenseActionFrom(ItemStack stack) {
|
||||
return getEntryFromStack(stack).map(Entry::dispensable).orElse(null);
|
||||
}
|
||||
|
||||
|
@ -105,16 +105,16 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public HeldMagicEffect getHeldFrom(ItemStack stack) {
|
||||
public HeldSpell getHeldFrom(ItemStack stack) {
|
||||
return getEntryFromStack(stack).map(Entry::holdable).orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MagicEffect getSpellFrom(ItemStack stack) {
|
||||
public Spell getSpellFrom(ItemStack stack) {
|
||||
return getSpellFromName(getKeyFromStack(stack));
|
||||
}
|
||||
|
||||
public <T extends MagicEffect> void register(Supplier<T> factory) {
|
||||
public <T extends Spell> void register(Supplier<T> factory) {
|
||||
try {
|
||||
new Entry<>(factory);
|
||||
} catch (Exception e) {
|
||||
|
@ -174,7 +174,7 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@Immutable
|
||||
class Entry<T extends MagicEffect> {
|
||||
class Entry<T extends Spell> {
|
||||
final Supplier<T> factory;
|
||||
|
||||
final int color;
|
||||
|
@ -190,9 +190,9 @@ public class SpellRegistry {
|
|||
|
||||
this.factory = factory;
|
||||
this.color = inst.getTint();
|
||||
this.canDispense = inst instanceof DispenceableMagicEffect;
|
||||
this.canDispense = inst instanceof DispenceableSpell;
|
||||
this.canUse = inst instanceof Useable;
|
||||
this.canHold = inst instanceof HeldMagicEffect;
|
||||
this.canHold = inst instanceof HeldSpell;
|
||||
this.affinity = inst.getAffinity();
|
||||
|
||||
if (inst.isCraftable()) {
|
||||
|
@ -212,20 +212,20 @@ public class SpellRegistry {
|
|||
return (Useable)create();
|
||||
}
|
||||
|
||||
HeldMagicEffect holdable() {
|
||||
HeldSpell holdable() {
|
||||
if (!canHold) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (HeldMagicEffect)create();
|
||||
return (HeldSpell)create();
|
||||
}
|
||||
|
||||
DispenceableMagicEffect dispensable() {
|
||||
DispenceableSpell dispensable() {
|
||||
if (!canDispense) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (DispenceableMagicEffect)create();
|
||||
return (DispenceableSpell)create();
|
||||
}
|
||||
|
||||
T create() {
|
||||
|
|
|
@ -34,7 +34,7 @@ abstract class MixinEntityRenderDispatcher {
|
|||
|
||||
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()) {
|
||||
return;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.network;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
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 net.minecraft.entity.data.TrackedData;
|
||||
|
@ -19,7 +19,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
public class EffectSync {
|
||||
|
||||
@Nullable
|
||||
private MagicEffect effect;
|
||||
private Spell effect;
|
||||
|
||||
private final Caster<?> owned;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class EffectSync {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void set(@Nullable MagicEffect effect) {
|
||||
public void set(@Nullable Spell effect) {
|
||||
if (this.effect != null && this.effect != effect) {
|
||||
this.effect.setDead();
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class EffectSync {
|
|||
if (effect == null) {
|
||||
owned.getEntity().getDataTracker().set(param, new CompoundTag());
|
||||
} else {
|
||||
owned.getEntity().getDataTracker().set(param, SpellRegistry.instance().serializeEffectToNBT(effect));
|
||||
owned.getEntity().getDataTracker().set(param, SpellRegistry.toNBT(effect));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ParticleHandle {
|
|||
public void attach(Caster<?> caster) {
|
||||
this.linked = true;
|
||||
this.caster = Optional.of(caster);
|
||||
effect = caster.getEffect(false).getName();
|
||||
effect = caster.getSpell(false).getName();
|
||||
}
|
||||
|
||||
public boolean linked() {
|
||||
|
@ -68,7 +68,7 @@ public class ParticleHandle {
|
|||
caster = caster.filter(c -> {
|
||||
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()) {
|
||||
action.run();
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.stream.Stream;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
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.recipe.Utils;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import net.minecraft.util.PacketByteBuf;
|
|||
* Appends that spell to the output when crafting.
|
||||
*/
|
||||
class SpellPredicate implements Predicate {
|
||||
private final MagicEffect spell;
|
||||
private final Spell spell;
|
||||
|
||||
SpellPredicate(String spell) {
|
||||
this.spell = Utils.require(SpellRegistry.instance().getSpellFromName(spell), "Unknown spell tag '" + spell + "'");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.LivingEntity;
|
||||
|
@ -16,7 +16,7 @@ public interface AdvancedProjectile extends Projectile {
|
|||
|
||||
void setOwner(LivingEntity owner);
|
||||
|
||||
void setEffect(TossedMagicEffect effect);
|
||||
void setEffect(ThrowableSpell effect);
|
||||
|
||||
void setThrowDamage(float damage);
|
||||
|
||||
|
|
Loading…
Reference in a new issue