use of hellfirepvp.astralsorcery.common.util.data.Vector3 in project AstralSorcery by HellFirePvP.
the class EntityUtils method applyVortexMotion.
public static void applyVortexMotion(Supplier<Vector3> positionSupplier, Consumer<Vector3> addMotion, Vector3 to, double vortexRange, double multiplier) {
Vector3 pos = positionSupplier.get();
double diffX = (to.getX() - pos.getX()) / vortexRange;
double diffY = (to.getY() - pos.getY()) / vortexRange;
double diffZ = (to.getZ() - pos.getZ()) / vortexRange;
double dist = Math.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
if (1.0D - dist > 0.0D) {
double dstFactorSq = (1.0D - dist) * (1.0D - dist);
Vector3 toAdd = new Vector3();
toAdd.setX(diffX / dist * dstFactorSq * 0.15D * multiplier);
toAdd.setY(diffY / dist * dstFactorSq * 0.15D * multiplier);
toAdd.setZ(diffZ / dist * dstFactorSq * 0.15D * multiplier);
addMotion.accept(toAdd);
}
}
use of hellfirepvp.astralsorcery.common.util.data.Vector3 in project AstralSorcery by HellFirePvP.
the class TimeStopEffectHelper method playClientTickEffect.
@OnlyIn(Dist.CLIENT)
public void playClientTickEffect() {
World world = Minecraft.getInstance().world;
if (world == null) {
return;
}
List<LivingEntity> entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(-range, -range, -range, range, range, range).offset(position.getX(), position.getY(), position.getZ()), EntityPredicates.withinRange(position.getX(), position.getY(), position.getZ(), range));
for (LivingEntity e : entities) {
if (e != null && e.isAlive() && targetController.shouldFreezeEntity(e) && rand.nextInt(3) == 0) {
playEntityParticles(e);
}
}
int minX = MathHelper.floor((position.getX() - range) / 16.0D);
int maxX = MathHelper.floor((position.getX() + range) / 16.0D);
int minZ = MathHelper.floor((position.getZ() - range) / 16.0D);
int maxZ = MathHelper.floor((position.getZ() + range) / 16.0D);
for (int xx = minX; xx <= maxX; ++xx) {
for (int zz = minZ; zz <= maxZ; ++zz) {
Chunk ch = world.getChunk(xx, zz);
if (!ch.isEmpty()) {
Map<BlockPos, TileEntity> map = ch.getTileEntityMap();
for (Map.Entry<BlockPos, TileEntity> teEntry : map.entrySet()) {
TileEntity te = teEntry.getValue();
if (TileAccelerationBlacklistRegistry.INSTANCE.canBeInfluenced(te) && te.getPos().withinDistance(position, range)) {
double x = te.getPos().getX() + rand.nextFloat();
double y = te.getPos().getY() + rand.nextFloat();
double z = te.getPos().getZ() + rand.nextFloat();
playParticles(x, y, z);
}
}
}
}
}
Vector3 pos;
for (int i = 0; i < 10; i++) {
pos = Vector3.random().normalize().multiply(rand.nextFloat() * range).add(position);
playParticles(pos.getX(), pos.getY(), pos.getZ());
}
if (rand.nextInt(4) == 0) {
Vector3 rand1 = Vector3.random().normalize().multiply(rand.nextFloat() * range).add(position);
Vector3 rand2 = Vector3.random().normalize().multiply(rand.nextFloat() * range).add(position);
if (rand1.distance(rand2) > 10) {
Vector3 dir = rand1.vectorFromHereTo(rand2);
rand2 = rand1.clone().add(dir.normalize().multiply(10));
}
EffectHelper.of(EffectTemplatesAS.LIGHTNING).spawn(rand1).makeDefault(rand2).color(VFXColorFunction.WHITE);
}
}
use of hellfirepvp.astralsorcery.common.util.data.Vector3 in project AstralSorcery by HellFirePvP.
the class TimeStopEffectHelper method playEntityParticles.
@OnlyIn(Dist.CLIENT)
public static void playEntityParticles(PktPlayEffect ev) {
Vector3 at = ByteBufUtils.readVector(ev.getExtraData());
playParticles(at.getX(), at.getY(), at.getZ());
}
use of hellfirepvp.astralsorcery.common.util.data.Vector3 in project AstralSorcery by HellFirePvP.
the class BlockGeometry method getHollowSphere.
public static List<BlockPos> getHollowSphere(double outerRadius, double innerRadius) {
List<BlockPos> out = new ArrayList<>();
Vector3 vFrom = new Vector3(0.5, 0.5, 0.5);
double dstOuter = outerRadius * outerRadius;
double dstInner = innerRadius * innerRadius;
int toX = MathHelper.ceil(outerRadius);
int toY = MathHelper.ceil(outerRadius);
int toZ = MathHelper.ceil(outerRadius);
for (int x = MathHelper.floor(-outerRadius); x <= toX; x++) {
for (int y = MathHelper.floor(-outerRadius); y <= toY; y++) {
for (int z = MathHelper.floor(-outerRadius); z <= toZ; z++) {
Vector3 result = new Vector3(x, y, z).add(0.5, 0.5, 0.5);
double dst = result.distanceSquared(vFrom);
if (dst > dstInner && dst <= dstOuter) {
out.add(result.toBlockPos());
}
}
}
}
return out;
}
use of hellfirepvp.astralsorcery.common.util.data.Vector3 in project AstralSorcery by HellFirePvP.
the class BlockGeometry method getSphere.
public static List<BlockPos> getSphere(double radius) {
List<BlockPos> out = new ArrayList<>();
Vector3 vFrom = new Vector3(0.5, 0.5, 0.5);
double dst = radius * radius;
int toX = MathHelper.ceil(radius);
int toY = MathHelper.ceil(radius);
int toZ = MathHelper.ceil(radius);
for (int y = MathHelper.floor(-radius); y <= toY; y++) {
for (int x = MathHelper.floor(-radius); x <= toX; x++) {
for (int z = MathHelper.floor(-radius); z <= toZ; z++) {
Vector3 result = new Vector3(x, y, z).add(0.5, 0.5, 0.5);
if (result.distanceSquared(vFrom) <= dst) {
out.add(result.toBlockPos());
}
}
}
}
return out;
}
Aggregations