mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
The siphoning spell can now get angry if you misuse it
This commit is contained in:
parent
b27ff8c5f0
commit
d27de0f690
2 changed files with 26 additions and 3 deletions
|
@ -86,7 +86,6 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac
|
|||
@Override
|
||||
public void fromNBT(CompoundTag compound) {
|
||||
super.fromNBT(compound);
|
||||
System.out.println("Loaded!");
|
||||
if (compound.contains("dimension")) {
|
||||
dimension = new Identifier(compound.getString("dimension"));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -26,6 +27,8 @@ import net.minecraft.util.math.Vec3d;
|
|||
*/
|
||||
public class SiphoningSpell extends AbstractPlacedSpell {
|
||||
|
||||
private int ticksUpset;
|
||||
|
||||
protected SiphoningSpell(SpellType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
@ -34,6 +37,10 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
|||
public boolean onGroundTick(Caster<?> source) {
|
||||
super.onGroundTick(source);
|
||||
|
||||
if (ticksUpset > 0) {
|
||||
ticksUpset--;
|
||||
}
|
||||
|
||||
if (source.isClient()) {
|
||||
int radius = 4 + source.getLevel().get();
|
||||
int direction = isFriendlyTogether(source) ? 1 : -1;
|
||||
|
@ -44,7 +51,7 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
|||
double dist = pos.distanceTo(source.getOriginVector());
|
||||
Vec3d velocity = pos.subtract(source.getOriginVector()).normalize().multiply(direction * dist);
|
||||
|
||||
source.addParticle(direction == 1 ? ParticleTypes.HEART : ParticleTypes.ANGRY_VILLAGER, pos, velocity);
|
||||
source.addParticle(direction == 1 && ticksUpset == 0 ? ParticleTypes.HEART : ParticleTypes.ANGRY_VILLAGER, pos, velocity);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -77,12 +84,16 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
|||
|
||||
source.subtractEnergyCost(0.2F);
|
||||
|
||||
if (maxHealthGain <= 0) {
|
||||
if (ticksUpset > 0 || maxHealthGain <= 0) {
|
||||
if (source.getWorld().random.nextInt(3000) == 0) {
|
||||
onDestroyed(source);
|
||||
} else {
|
||||
e.damage(damage, e.getHealth() / 4);
|
||||
}
|
||||
if (maxHealthGain <= 0) {
|
||||
ticksUpset = 100;
|
||||
}
|
||||
setDirty(true);
|
||||
} else {
|
||||
e.heal((float)Math.min(0.5F * (1 + source.getLevel().get()), maxHealthGain * 0.6));
|
||||
ParticleUtils.spawnParticle(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.world, e.getPos(), Vec3d.ZERO);
|
||||
|
@ -135,4 +146,17 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
|||
|
||||
owner.heal(healthGain);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void toNBT(CompoundTag compound) {
|
||||
super.toNBT(compound);
|
||||
compound.putInt("upset", ticksUpset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromNBT(CompoundTag compound) {
|
||||
super.fromNBT(compound);
|
||||
ticksUpset = compound.getInt("upset");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue