mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-22 11:07:13 +01:00
Move the collides predicate out of the RayTraceHelper class
This commit is contained in:
parent
0532aafa83
commit
1b17ab24c9
8 changed files with 11 additions and 10 deletions
|
@ -44,7 +44,7 @@ public class BatPonyHangAbility implements Ability<Multi> {
|
|||
return new Multi(BlockPos.ZERO, 0);
|
||||
}
|
||||
|
||||
BlockPos poss = RayTraceHelper.doTrace(player.getMaster(), 3, 1, EntityPredicates.EXCEPT_SPECTATOR).getBlockPos().orElse(null);
|
||||
BlockPos poss = RayTraceHelper.doTrace(player.getMaster(), 3, 1, EntityPredicates.CAN_COLLIDE).getBlockPos().orElse(null);
|
||||
if (poss != null) {
|
||||
boolean air = player.getWorld().isAir(poss.down()) && player.getWorld().isAir(poss.down(2));
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
RayTraceHelper.Trace trace = RayTraceHelper.doTrace(player, 10, 1, EntityPredicates.EXCEPT_SPECTATOR.and(e -> !(e instanceof LightningEntity)));
|
||||
RayTraceHelper.Trace trace = RayTraceHelper.doTrace(player, 10, 1, EntityPredicates.CAN_COLLIDE.and(e -> !(e instanceof LightningEntity)));
|
||||
|
||||
Entity looked = trace.getEntity().filter(e -> !(e instanceof AbstractDecorationEntity)).map(e -> {
|
||||
return e instanceof PlayerEntity ? Pony.of((PlayerEntity)e)
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
|||
import com.minelittlepony.unicopia.util.RayTraceHelper;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
|
@ -107,7 +108,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
player.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1, 0.5F);
|
||||
} else {
|
||||
if (s instanceof HomingSpell) {
|
||||
RayTraceHelper.doTrace(player.getMaster(), 600, 1, EntityPredicates.EXCEPT_SPECTATOR).getEntity().ifPresent(((HomingSpell)s)::setTarget);
|
||||
RayTraceHelper.doTrace(player.getMaster(), 600, 1, EntityPredicates.CAN_COLLIDE).getEntity().ifPresent(((HomingSpell)s)::setTarget);
|
||||
}
|
||||
player.playSound(SoundEvents.BLOCK_BEACON_POWER_SELECT, 0.05F, 2.2F);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class UnicornProjectileAbility implements Ability<Hit> {
|
|||
|
||||
spell.toThrowable().throwProjectile(player).ifPresent(projectile -> {
|
||||
if (spell instanceof HomingSpell) {
|
||||
RayTraceHelper.doTrace(player.getMaster(), 600, 1, EntityPredicates.EXCEPT_SPECTATOR).getEntity().filter(((HomingSpell)spell)::setTarget).ifPresent(target -> {
|
||||
RayTraceHelper.doTrace(player.getMaster(), 600, 1, EntityPredicates.CAN_COLLIDE).getEntity().filter(((HomingSpell)spell)::setTarget).ifPresent(target -> {
|
||||
projectile.setHomingTarget(target);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
|||
@Override
|
||||
public Pos tryActivate(Pony player) {
|
||||
int maxDistance = player.getMaster().isCreative() ? 1000 : 100;
|
||||
HitResult ray = RayTraceHelper.doTrace(player.getMaster(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR).getResult();
|
||||
HitResult ray = RayTraceHelper.doTrace(player.getMaster(), maxDistance, 1, EntityPredicates.CAN_COLLIDE).getResult();
|
||||
|
||||
World w = player.getWorld();
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
|||
|
||||
double maxDistance = 2 + (getTraits().get(Trait.FOCUS) - 50) * 8;
|
||||
|
||||
HitResult ray = RayTraceHelper.doTrace(caster.getMaster(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR).getResult();
|
||||
HitResult ray = RayTraceHelper.doTrace(caster.getMaster(), maxDistance, 1, EntityPredicates.CAN_COLLIDE).getResult();
|
||||
|
||||
if (ray.getType() == HitResult.Type.ENTITY) {
|
||||
EntityHitResult result = (EntityHitResult)ray;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
|
|||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
Optional<Entity> entity = RayTraceHelper.doTrace(player, 5, 1, EntityPredicates.EXCEPT_SPECTATOR.and(e -> canFeedTo(stack, e))).getEntity();
|
||||
Optional<Entity> entity = RayTraceHelper.doTrace(player, 5, 1, EntityPredicates.CAN_COLLIDE.and(e -> canFeedTo(stack, e))).getEntity();
|
||||
|
||||
if (entity.isPresent()) {
|
||||
return onFedTo(stack, player, entity.get());
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
public class RayTraceHelper {
|
||||
public static <T extends Entity> Optional<T> findEntity(Entity e, double distance, float tickDelta, Predicate<Entity> predicate) {
|
||||
return doTrace(e, distance, tickDelta, EntityPredicates.EXCEPT_SPECTATOR.and(predicate)).getEntity();
|
||||
return doTrace(e, distance, tickDelta, EntityPredicates.CAN_COLLIDE.and(predicate)).getEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ public class RayTraceHelper {
|
|||
* @return A Trace describing what was found.
|
||||
*/
|
||||
public static Trace doTrace(Entity e, double distance, float tickDelta) {
|
||||
return doTrace(e, distance, tickDelta, EntityPredicates.EXCEPT_SPECTATOR);
|
||||
return doTrace(e, distance, tickDelta, EntityPredicates.CAN_COLLIDE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ public class RayTraceHelper {
|
|||
|
||||
final Box box = e.getBoundingBox().stretch(ray).expand(1);
|
||||
|
||||
EntityHitResult pointedEntity = ProjectileUtil.raycast(e, start, start.add(ray), box, predicate.and(Entity::collides), distance);
|
||||
EntityHitResult pointedEntity = ProjectileUtil.raycast(e, start, start.add(ray), box, predicate, distance);
|
||||
|
||||
if (pointedEntity != null) {
|
||||
return new Trace(pointedEntity);
|
||||
|
|
Loading…
Add table
Reference in a new issue