mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed catapult spell and fixed spells not being applied when a projectile hits something
This commit is contained in:
parent
3c065ac097
commit
10758fc25d
2 changed files with 1 additions and 21 deletions
|
@ -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<Entity> 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<Entity> apply) {
|
||||
|
||||
if (world.isAir(bpos)) {
|
||||
|
|
|
@ -256,7 +256,6 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Ma
|
|||
@Override
|
||||
protected void onCollision(HitResult result) {
|
||||
if (!isRemoved()) {
|
||||
discard();
|
||||
super.onCollision(result);
|
||||
|
||||
if (!world.isClient()) {
|
||||
|
|
Loading…
Reference in a new issue