mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fix #290 and exclude spectators from being affected by magic
This commit is contained in:
parent
308cb721cd
commit
5348e12aca
3 changed files with 5 additions and 6 deletions
|
@ -35,11 +35,13 @@ public interface EquinePredicates {
|
|||
Predicate<Entity> IS_CASTER = e -> !e.isRemoved() && (e instanceof Caster || IS_PLAYER.test(e));
|
||||
Predicate<Entity> IS_PLACED_SPELL = e -> e instanceof Caster && !e.isRemoved();
|
||||
|
||||
Predicate<Entity> IS_MAGIC_IMMUNE = e -> (e instanceof MagicImmune || !(e instanceof LivingEntity))
|
||||
Predicate<Entity> IS_MAGIC_IMMUNE = EntityPredicates.VALID_ENTITY.negate()
|
||||
.or(EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.negate()
|
||||
.or(e -> (e instanceof MagicImmune || !(e instanceof LivingEntity))
|
||||
&& !(e instanceof ItemEntity)
|
||||
&& !(e instanceof ExperienceOrbEntity)
|
||||
&& !(e instanceof BoatEntity)
|
||||
&& !(e instanceof ProjectileEntity);
|
||||
&& !(e instanceof ProjectileEntity)));
|
||||
Predicate<Entity> EXCEPT_MAGIC_IMMUNE = IS_MAGIC_IMMUNE.negate();
|
||||
Predicate<Entity> VALID_LIVING_AND_NOT_MAGIC_IMMUNE = EntityPredicates.VALID_LIVING_ENTITY.and(EXCEPT_MAGIC_IMMUNE);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.minelittlepony.unicopia.ability.magic.Affine;
|
|||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
|
||||
public class TargetSelecter {
|
||||
private final Map<UUID, Target> targets = new TreeMap<>();
|
||||
|
@ -46,7 +45,6 @@ public class TargetSelecter {
|
|||
public Stream<Entity> getEntities(Caster<?> source, double radius) {
|
||||
targets.values().removeIf(Target::tick);
|
||||
return source.findAllEntitiesInRange(radius)
|
||||
.filter(EntityPredicates.VALID_ENTITY)
|
||||
.filter(EquinePredicates.EXCEPT_MAGIC_IMMUNE)
|
||||
.filter(entity -> entity != source.asEntity() && checkAlliegance(spell, source, entity) && filter.test(source, entity))
|
||||
.map(i -> {
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.nbt.NbtElement;
|
|||
import net.minecraft.particle.ItemStackParticleEffect;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
|
@ -208,7 +207,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
protected void onEntityHit(EntityHitResult hit) {
|
||||
Entity entity = hit.getEntity();
|
||||
|
||||
if (EquinePredicates.IS_MAGIC_IMMUNE.test(entity) || !EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.test(entity)) {
|
||||
if (EquinePredicates.IS_MAGIC_IMMUNE.test(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue