<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.nitro.entity;

import com.flowpowered.math.vector.Vector3d;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class VelocityEntitySpawner {
    public static Optional<Entity> send(EntityType type, Location<World> loc, Vector3d dir, float speed, Cause cause) {
        Vector3d actualDir = dir.normalize();
        Vector3d finalVecLoc = loc.getPosition().add(actualDir.mul(2));
        loc.setPosition(finalVecLoc);
        Optional<Entity> optEnt = loc.getExtent().createEntity(type, loc.getPosition());
        if (optEnt.isPresent()) {
            Entity entity = optEnt.get();
            entity.setVelocity(dir.mul(speed));
            return loc.getExtent().spawnEntity(entity, cause) ? Optional.of(entity) : Optional.empty();
        }
        return Optional.empty();
    }

    public static List<Entity> sendRadial(EntityType type, Location<World> loc, Cause cause) {
        final int amt = 12;
        final double tau = 2 * Math.PI;

        double arc = tau / amt;
        List<Entity> resultSet = new ArrayList<>();
        for (double a = 0; a < tau; a += arc) {
            Optional<Entity> optEnt = send(type, loc, new Vector3d(Math.cos(a), 0, Math.sin(a)), .5F, cause);
            if (optEnt.isPresent()) {
                resultSet.add(optEnt.get());
            }
        }
        return resultSet;
    }
}<commit_msg>Allowed configurability of the amount and speed of projectiles in the Velocity Entity Spawner<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.nitro.entity;

import com.flowpowered.math.vector.Vector3d;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class VelocityEntitySpawner {
    public static Optional<Entity> send(EntityType type, Location<World> loc, Vector3d dir, float speed, Cause cause) {
        Vector3d actualDir = dir.normalize();
        Vector3d finalVecLoc = loc.getPosition().add(actualDir.mul(2));
        loc.setPosition(finalVecLoc);
        Optional<Entity> optEnt = loc.getExtent().createEntity(type, loc.getPosition());
        if (optEnt.isPresent()) {
            Entity entity = optEnt.get();
            entity.setVelocity(dir.mul(speed));
            return loc.getExtent().spawnEntity(entity, cause) ? Optional.of(entity) : Optional.empty();
        }
        return Optional.empty();
    }

    public static List<Entity> sendRadial(EntityType type, Location<World> loc, Cause cause) {
        return sendRadial(type, loc, 12, .5F, cause);
    }

    public static List<Entity> sendRadial(EntityType type, Location<World> loc, int amt, float speed, Cause cause) {
        final double tau = 2 * Math.PI;

        double arc = tau / amt;
        List<Entity> resultSet = new ArrayList<>();
        for (double a = 0; a < tau; a += arc) {
            Optional<Entity> optEnt = send(type, loc, new Vector3d(Math.cos(a), 0, Math.sin(a)), speed, cause);
            if (optEnt.isPresent()) {
                resultSet.add(optEnt.get());
            }
        }
        return resultSet;
    }
}
{'fraction_non_alphanumeric': 0.12029501525940997, 'fraction_numerical': 0.008138351983723296, 'mean_word_length': 2.9928934010152286, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5044118', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1177, 'n_words': 316}