Search in sources :

Example 1 with Vector3

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);
    }
}
Also used : Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 2 with Vector3

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);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) LivingEntity(net.minecraft.entity.LivingEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with Vector3

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());
}
Also used : Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with Vector3

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;
}
Also used : ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 5 with Vector3

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;
}
Also used : ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Aggregations

Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)232 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)119 BlockPos (net.minecraft.util.math.BlockPos)55 PlayerEntity (net.minecraft.entity.player.PlayerEntity)31 World (net.minecraft.world.World)28 FXFacingParticle (hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle)24 Nonnull (javax.annotation.Nonnull)20 ItemStack (net.minecraft.item.ItemStack)20 VFXAlphaFunction (hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction)19 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)19 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)19 Dist (net.minecraftforge.api.distmarker.Dist)19 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)17 Nullable (javax.annotation.Nullable)17 MiscUtils (hellfirepvp.astralsorcery.common.util.MiscUtils)16 FluidStack (net.minecraftforge.fluids.FluidStack)16 LogicalSide (net.minecraftforge.fml.LogicalSide)15 PktPlayEffect (hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)14 java.awt (java.awt)13 List (java.util.List)13