From 8ff6514306535157231a8bd6c89ea128392ae487 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 24 Dec 2021 18:37:23 +0200 Subject: [PATCH] Fixed black hole behaviour --- .../magic/spell/effect/CatapultSpell.java | 5 +++ .../magic/spell/effect/DarkVortexSpell.java | 45 ++++++++++++++----- .../magic/spell/effect/ShieldSpell.java | 23 +++++----- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java index 2147971b..2a4361f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java @@ -97,6 +97,11 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell { } static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer apply) { + + if (world.isAir(bpos)) { + return; + } + Vec3d pos = Vec3d.ofBottomCenter(bpos); FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos)); world.removeBlock(bpos, true); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index 67758a09..a78f8d6b 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -23,22 +23,34 @@ public class DarkVortexSpell extends AttractiveSpell { .with(Trait.DARKNESS, 100) .build(); - private int accumulatedMass = 10; + private int accumulatedMass = 0; protected DarkVortexSpell(SpellType type, SpellTraits traits) { super(type, traits); } + @Override + public boolean apply(Caster source) { + return toPlaceable().apply(source); + } + @Override public boolean tick(Caster source, Situation situation) { + + if (situation == Situation.BODY) { + return true; + } + if (accumulatedMass > 20) { - Vec3d pos = source.getOriginVector(); - source.getWorld().createExplosion( - source.getMaster(), - MagicalDamageSource.create("super_nova"), - null, - pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY - ); + if (!source.isClient()) { + Vec3d pos = source.getOriginVector(); + source.getWorld().createExplosion( + source.getMaster(), + MagicalDamageSource.create("super_nova"), + null, + pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY + ); + } return false; } return super.tick(source, situation); @@ -53,7 +65,7 @@ public class DarkVortexSpell extends AttractiveSpell { source.addParticle(new MagicParticleEffect(getType().getColor()), p, p.subtract(pos)); }); - float radius = (float)getDrawDropOffRange(source) / 2; + float radius = 1 + (float)getDrawDropOffRange(source) / 2; particlEffect.ifAbsent(getUuid(), source, spawner -> { spawner.addParticle(new SphereParticleEffect(getType().getColor(), 0.99F, radius), source.getOriginVector(), Vec3d.ZERO); @@ -69,9 +81,18 @@ public class DarkVortexSpell extends AttractiveSpell { @Override protected long applyEntities(Caster source) { - PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, ((int)getDrawDropOffRange(source) / 2F))).forEach(i -> { - CatapultSpell.createBlockEntity(source.getWorld(), i, null); - }); + if (!source.isClient()) { + PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, 1 + ((int)getDrawDropOffRange(source) / 2F))).forEach(i -> { + if (!source.getWorld().isAir(i)) { + source.getWorld().breakBlock(i, false); + if (source.getWorld().random.nextInt(accumulatedMass + 1) == 0) { + accumulatedMass++; + setDirty(); + } + + } + }); + } return super.applyEntities(source); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java index 7b5508bb..6b208fb1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java @@ -127,21 +127,24 @@ public class ShieldSpell extends AbstractSpell { return source.findAllEntitiesInRange(radius) .filter(entity -> { - return - !FriendshipBraceletItem.isComrade(source, entity) - && (entity instanceof LivingEntity - || entity instanceof TntEntity - || entity instanceof FallingBlockEntity - || entity instanceof EyeOfEnderEntity - || entity instanceof BoatEntity - || ProjectileUtil.isFlyingProjectile(entity) - || entity instanceof AbstractMinecartEntity) - && !(entity instanceof ArmorStandEntity) + return !FriendshipBraceletItem.isComrade(source, entity) + && isValidTarget(entity) && !(ownerIsValid && (Pony.equal(entity, owner) || owner.isConnectedThroughVehicle(entity))); }) .collect(Collectors.toList()); } + protected boolean isValidTarget(Entity entity) { + return (entity instanceof LivingEntity + || entity instanceof TntEntity + || entity instanceof FallingBlockEntity + || entity instanceof EyeOfEnderEntity + || entity instanceof BoatEntity + || ProjectileUtil.isFlyingProjectile(entity) + || entity instanceof AbstractMinecartEntity) + && !(entity instanceof ArmorStandEntity); + } + protected long applyEntities(Caster source) { double radius = getDrawDropOffRange(source);