mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-28 23:48:00 +01:00
996181c097
- Adding traits to some existing spells - Removed curses (and their respective duplicate spells) - Spells can now control how they are applied and some spells will now correctly apply as area effects
31 lines
1.1 KiB
Java
31 lines
1.1 KiB
Java
package com.minelittlepony.unicopia.util;
|
|
|
|
import java.util.List;
|
|
import java.util.function.DoubleSupplier;
|
|
import java.util.function.Predicate;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.util.math.Box;
|
|
import net.minecraft.util.math.Vec3d;
|
|
import net.minecraft.world.World;
|
|
|
|
public interface VecHelper {
|
|
|
|
static Vec3d supply(DoubleSupplier rng) {
|
|
return new Vec3d(rng.getAsDouble(), rng.getAsDouble(), rng.getAsDouble());
|
|
}
|
|
|
|
static Predicate<Entity> inRange(Vec3d center, double range) {
|
|
double rad = Math.pow(range, 2);
|
|
return e -> {
|
|
return e.squaredDistanceTo(center) <= rad
|
|
|| e.squaredDistanceTo(center.getX(), center.getY() - e.getStandingEyeHeight(), center.getZ()) <= rad;
|
|
};
|
|
}
|
|
|
|
static List<Entity> findInRange(@Nullable Entity origin, World w, Vec3d pos, double radius, @Nullable Predicate<Entity> predicate) {
|
|
double diameter = radius * 2;
|
|
return w.getOtherEntities(origin, Box.of(pos, diameter, diameter, diameter), predicate == null ? inRange(pos, radius) : inRange(pos, radius).and(predicate));
|
|
}
|
|
}
|