From 10758fc25db55c860a053311a7f88fad8cad4370 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 26 Dec 2022 23:48:01 +0100 Subject: [PATCH] Fixed catapult spell and fixed spells not being applied when a projectile hits something --- .../magic/spell/effect/CatapultSpell.java | 21 +------------------ .../projectile/MagicProjectileEntity.java | 1 - 2 files changed, 1 insertion(+), 21 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 d964cf44..f00d9020 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 @@ -11,11 +11,9 @@ import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import com.minelittlepony.unicopia.projectile.ProjectileDelegate; -import com.minelittlepony.unicopia.util.Trace; import net.minecraft.entity.Entity; import net.minecraft.entity.FallingBlockEntity; -import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.math.BlockPos; @@ -60,7 +58,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B return true; } - getTarget(caster, e -> apply(caster, e)); + getTypeAndTraits().create().toThrowable().throwProjectile(caster); return false; } @@ -77,23 +75,6 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B } } - protected void getTarget(Caster caster, Consumer apply) { - if (caster.isClient()) { - return; - } - - double maxDistance = 2 + (getTraits().get(Trait.FOCUS) - 50) * 8; - - Trace trace = Trace.create(caster.asEntity(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR); - trace.getEntity().ifPresentOrElse(apply, () -> { - trace.ifBlock(pos -> { - if (caster.canModifyAt(pos)) { - createBlockEntity(caster.asWorld(), pos, apply); - } - }); - }); - } - static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer apply) { if (world.isAir(bpos)) { diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index bf51bd3d..c7509c76 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -256,7 +256,6 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster