<commit_before>package com.elmakers.mine.bukkit.action.builtin;

import com.elmakers.mine.bukkit.action.CompoundAction;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import com.elmakers.mine.bukkit.spell.BaseSpell;
import com.elmakers.mine.bukkit.utility.RandomUtils;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.util.Vector;

import java.util.Arrays;
import java.util.Collection;

public class DiscAction extends CompoundAction
{
	public static final float DEGTORAD = 0.017453293F;
	private static final int DEFAULT_RADIUS	= 2;
	private boolean autoOrient;
	private int radius;
	private int currentRadius;
	private float centerProbability;
	private float outerProbability;
	private int dx;
	private int dz;
	private int xDirection;
	private int zDirection;
	private boolean checked;

	@Override
	public void prepare(CastContext context, ConfigurationSection parameters) {
		super.prepare(context, parameters);
		radius = parameters.getInt("radius", DEFAULT_RADIUS);
		autoOrient = parameters.getBoolean("orient", false);
		centerProbability = (float)parameters.getDouble("probability", 1);
		outerProbability = (float)parameters.getDouble("probability", 1);
		centerProbability = (float)parameters.getDouble("center_probability", centerProbability);
		outerProbability = (float)parameters.getDouble("outer_probability", outerProbability);
		radius = (int)(context.getMage().getRadiusMultiplier() * this.radius);
	}

	@Override
	public void reset(CastContext context) {
		super.reset(context);
		currentRadius = 0;
		dx = 0;
		dz = 0;
		xDirection = 1;
		zDirection = 0;
		checked = false;
	}

	public static Vector rotate(float yaw, float pitch, double x, double y, double z){
		float angle;
		angle = -yaw * DEGTORAD;
		double sinYaw = Math.sin(angle);
		double cosYaw = Math.cos(angle);
		angle = pitch * DEGTORAD;
		double sinPitch = Math.sin(angle);
		double cosPitch = Math.cos(angle);

		// X-axis rotation
		// The way the plane is built, we don't need to worry about Z-axis rotation
		double pitchedX = x;
		double pitchedY = y * cosPitch - z * sinPitch; // y cos θ - z sin θ
		double pitchedZ = y * sinPitch + z * cosPitch; // y sin θ + z cos θ

		// Z-axis rotation
		// Here for posterity. If there were any z-components to this shape
		// we might need to use this.
		// pitchedX = x * cosPitch - y * sinPitch; // x cos θ - y sin θ
		// pitchedY = x * sinPitch + y * cosPitch; // x sin θ + y cos θ

		// Rotate around Y
		double finalX = pitchedX * cosYaw + pitchedZ * sinYaw; // x cos θ + z sin θ
		double finalY = pitchedY; // y
		double finalZ = -pitchedX * sinYaw + pitchedZ * cosYaw; // -x sin θ + z cos θ

		return new Vector(finalX + 0.5, finalY + 0.5, finalZ + 0.5);
	}

	@Override
	public SpellResult perform(CastContext context) {
		Block block = context.getTargetBlock();

		if (radius < 1)
		{
			if (!checked && centerProbability < 1 && context.getRandom().nextDouble() <= centerProbability)
			{
				return SpellResult.NO_ACTION;
			}
			checked = true;
			actionContext.setTargetLocation(context.findBlockUnder(block).getLocation());
			return performActions(actionContext);
		}

		Location location = context.getLocation();
		SpellResult result = SpellResult.NO_ACTION;
		Vector offset = new Vector();<commit_msg>Fix encoding issue with file. Grrrr.<commit_after>package com.elmakers.mine.bukkit.action.builtin;

import com.elmakers.mine.bukkit.action.CompoundAction;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import com.elmakers.mine.bukkit.spell.BaseSpell;
import com.elmakers.mine.bukkit.utility.RandomUtils;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.util.Vector;

import java.util.Arrays;
import java.util.Collection;

public class DiscAction extends CompoundAction
{
	public static final float DEGTORAD = 0.017453293F;
	private static final int DEFAULT_RADIUS	= 2;
	private boolean autoOrient;
	private int radius;
	private int currentRadius;
	private float centerProbability;
	private float outerProbability;
	private int dx;
	private int dz;
	private int xDirection;
	private int zDirection;
	private boolean checked;

	@Override
	public void prepare(CastContext context, ConfigurationSection parameters) {
		super.prepare(context, parameters);
		radius = parameters.getInt("radius", DEFAULT_RADIUS);
		autoOrient = parameters.getBoolean("orient", false);
		centerProbability = (float)parameters.getDouble("probability", 1);
		outerProbability = (float)parameters.getDouble("probability", 1);
		centerProbability = (float)parameters.getDouble("center_probability", centerProbability);
		outerProbability = (float)parameters.getDouble("outer_probability", outerProbability);
		radius = (int)(context.getMage().getRadiusMultiplier() * this.radius);
	}

	@Override
	public void reset(CastContext context) {
		super.reset(context);
		currentRadius = 0;
		dx = 0;
		dz = 0;
		xDirection = 1;
		zDirection = 0;
		checked = false;
	}

	public static Vector rotate(float yaw, float pitch, double x, double y, double z){
		float angle;
		angle = -yaw * DEGTORAD;
		double sinYaw = Math.sin(angle);
		double cosYaw = Math.cos(angle);
		angle = pitch * DEGTORAD;
		double sinPitch = Math.sin(angle);
		double cosPitch = Math.cos(angle);

		// X-axis rotation
		// The way the plane is built, we don't need to worry about Z-axis rotation
		double pitchedX = x;
		double pitchedY = y * cosPitch - z * sinPitch;
		double pitchedZ = y * sinPitch + z * cosPitch;

		// Z-axis rotation
		// Here for posterity. If there were any z-components to this shape
		// we might need to use this.
		// pitchedX = x * cosPitch - y * sinPitch;
		// pitchedY = x * sinPitch + y * cosPitch;

		// Rotate around Y
		double finalX = pitchedX * cosYaw + pitchedZ * sinYaw;
		double finalY = pitchedY; // y
		double finalZ = -pitchedX * sinYaw + pitchedZ * cosYaw;

		return new Vector(finalX + 0.5, finalY + 0.5, finalZ + 0.5);
	}

	@Override
	public SpellResult perform(CastContext context) {
		Block block = context.getTargetBlock();

		if (radius < 1)
		{
			if (!checked && centerProbability < 1 && context.getRandom().nextDouble() <= centerProbability)
			{
				return SpellResult.NO_ACTION;
			}
			checked = true;
			actionContext.setTargetLocation(context.findBlockUnder(block).getLocation());
			return performActions(actionContext);
		}

		Location location = context.getLocation();
		SpellResult result = SpellResult.NO_ACTION;
		Vector offset = new Vector();
{'fraction_non_alphanumeric': 0.10760251421730022, 'fraction_numerical': 0.007782101167315175, 'mean_word_length': 4.233359436178543, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '5397019', 'n_tokens_mistral': 2334, 'n_tokens_neox': 2099, 'n_words': 586}