mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Since using magic doesn't kill the player any more, cancel spells if the player doesn't have enough mana to sustain them
This commit is contained in:
parent
bc4e6ca316
commit
a163686b3a
10 changed files with 31 additions and 12 deletions
|
@ -12,7 +12,6 @@ import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
|
|||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.FallingBlockEntity;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
|
|
|
@ -20,7 +20,9 @@ public class ChillingBreathSpell extends AbstractSpell implements HomingSpell {
|
|||
|
||||
@Override
|
||||
public boolean tick(Caster<?> source, Situation situation) {
|
||||
source.subtractEnergyCost(90);
|
||||
if (!source.subtractEnergyCost(90)) {
|
||||
setDead();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,9 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
source.asWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
|
||||
}
|
||||
|
||||
source.subtractEnergyCost(-accumulatedMass);
|
||||
if (!source.subtractEnergyCost(-accumulatedMass)) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
if (!source.isClient() && source.asWorld().random.nextInt(300) == 0) {
|
||||
ParticleUtils.spawnParticle(source.asWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
|
||||
|
@ -233,7 +235,9 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
target.discard();
|
||||
}
|
||||
|
||||
source.subtractEnergyCost(-massOfTarget * 10);
|
||||
if (!source.subtractEnergyCost(-massOfTarget * 10)) {
|
||||
setDead();
|
||||
}
|
||||
source.asWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_MOOD, SoundCategory.AMBIENT, 2, 0.02F);
|
||||
} else {
|
||||
double force = getAttractiveForce(source, target);
|
||||
|
|
|
@ -80,7 +80,9 @@ public class HydrophobicSpell extends AbstractSpell {
|
|||
}
|
||||
});
|
||||
|
||||
source.subtractEnergyCost(storedFluidPositions.isEmpty() ? 0.001F : 0.02F);
|
||||
if (!source.subtractEnergyCost(storedFluidPositions.isEmpty() ? 0.001F : 0.02F)) {
|
||||
setDead();
|
||||
}
|
||||
source.spawnParticles(new Sphere(true, getRange(source)), 10, pos -> {
|
||||
BlockPos bp = new BlockPos(pos);
|
||||
if (source.asWorld().getFluidState(bp.up()).isIn(affectedFluid)) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.Owned;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||
|
@ -66,9 +67,11 @@ public class IceSpell extends AbstractSpell {
|
|||
return false;
|
||||
}).count();
|
||||
|
||||
source.subtractEnergyCost(Math.min(10, blocksAffected));
|
||||
if (!source.subtractEnergyCost(Math.min(10, blocksAffected / 30))) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
return applyEntities(source, source.getOriginVector()) && situation == Situation.PROJECTILE;
|
||||
return applyEntities(source, source.getOriginVector()) && situation == Situation.PROJECTILE && !isDead();
|
||||
}
|
||||
|
||||
protected boolean applyEntities(Caster<?> source, Vec3d pos) {
|
||||
|
@ -79,6 +82,9 @@ public class IceSpell extends AbstractSpell {
|
|||
}
|
||||
|
||||
protected void applyEntitySingle(Caster<?> source, Entity e) {
|
||||
if (source.asEntity() == e || source.isOwnedBy(e) || (e instanceof Owned<?> sibling && source.hasCommonOwner(sibling))) {
|
||||
return;
|
||||
}
|
||||
if (e instanceof TntEntity) {
|
||||
e.remove(RemovalReason.DISCARDED);
|
||||
e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState());
|
||||
|
|
|
@ -129,7 +129,9 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
protected void spawnMonster(Caster<?> source, Vec3d pos, EntityType<? extends LivingEntity> type) {
|
||||
LivingEntity minion = type.create(source.asWorld());
|
||||
|
||||
source.subtractEnergyCost(3);
|
||||
if (!source.subtractEnergyCost(3)) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
minion.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
|
||||
minion.setVelocity(0, 0.3, 0);
|
||||
|
|
|
@ -127,7 +127,9 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
entity.world.playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1);
|
||||
setDirty();
|
||||
|
||||
source.subtractEnergyCost(Math.sqrt(entity.getPos().subtract(dest).length()));
|
||||
if (!source.subtractEnergyCost(Math.sqrt(entity.getPos().subtract(dest).length()))) {
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
ParticleUtils.spawnParticles(new MagicParticleEffect(getType().getColor()), entity, 7);
|
||||
|
|
|
@ -92,7 +92,9 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
|||
getTargets(source).forEach(e -> {
|
||||
float maxHealthGain = e.getMaxHealth() - e.getHealth();
|
||||
|
||||
source.subtractEnergyCost(0.2F);
|
||||
if (!source.subtractEnergyCost(0.2F)) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
if (ticksUpset > 0 || maxHealthGain <= 0) {
|
||||
if (source.asWorld().random.nextInt(3000) == 0) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface ManaConsumptionUtil {
|
|||
return hunger.getFoodLevel()
|
||||
+ (pony.getMagicalReserves().getMana().get() / MANA_PER_FOOD)
|
||||
+ (hunger.getSaturationLevel() / SATURATION_PER_FOOD)
|
||||
+ (pony.asEntity().getHealth() / HEARTS_PER_FOOD);
|
||||
+ ((pony.asEntity().getHealth() - 1) / HEARTS_PER_FOOD);
|
||||
}
|
||||
|
||||
static float addExhaustion(HungerManager hunger, float foodSubtract) {
|
||||
|
|
|
@ -534,7 +534,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
|
||||
directTakeEnergy(foodSubtract);
|
||||
|
||||
return entity.getHealth() > 0;
|
||||
return entity.getHealth() > 1 && mana.getMana().getPercentFill() > 0.1F;
|
||||
}
|
||||
|
||||
protected void directTakeEnergy(double foodSubtract) {
|
||||
|
|
Loading…
Reference in a new issue