<commit_before>package com.teamwizardry.refraction.common.network;

import com.teamwizardry.librarianlib.client.fx.particle.ParticleBuilder;
import com.teamwizardry.librarianlib.client.fx.particle.ParticleSpawner;
import com.teamwizardry.librarianlib.client.fx.particle.functions.InterpFadeInOut;
import com.teamwizardry.librarianlib.common.network.PacketBase;
import com.teamwizardry.librarianlib.common.util.math.interpolate.StaticInterp;
import com.teamwizardry.librarianlib.common.util.math.interpolate.position.InterpBezier3D;
import com.teamwizardry.refraction.Refraction;
import com.teamwizardry.refraction.common.block.BlockAXYZ;
import io.netty.buffer.ByteBuf;
import kotlin.Pair;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

public class PacketAXYZMarks extends PacketBase {

	public static final Map<BlockAXYZ.DimWithPos, Pair<Vec3d, Vec3d>> controlPoints = new HashMap<>();

	private BlockPos[] positions, originPositions;
	private int dimension;

	public PacketAXYZMarks() {
	}

	public PacketAXYZMarks(BlockPos[] positions, BlockPos[] origins, int dimension) {
		this.positions = positions;
		this.originPositions = origins;
		this.dimension = dimension;
	}

	@Override
	public void handle(MessageContext ctx) {
		if (ctx.side.isServer()) return;

		World world = Minecraft.getMinecraft().theWorld;
		if (world.provider.getDimension() != dimension) return;

		for (int i = 0; i < positions.length; i++) {
			BlockPos pos = positions[i], origin = originPositions[i];
			double range = 5;
			controlPoints.putIfAbsent(new BlockAXYZ.DimWithPos(world.provider.getDimension(), origin),
					new Pair<>(
							new Vec3d(ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range)),
							new Vec3d(ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range))));


			ParticleBuilder wormholeVoid = new ParticleBuilder(10);
			ParticleSpawner.spawn(wormholeVoid, world, new StaticInterp<>(new Vec3d(pos).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(10, 20), 0, (aFloat, particleBuilder) -> {
				wormholeVoid.setAlphaFunction(new InterpFadeInOut(0.2f, 0.2f));
				wormholeVoid.setRenderNormalLayer(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double radius = 0.4;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double r = radius * ThreadLocalRandom.current().nextFloat();
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				wormholeVoid.setPositionOffset(new Vec3d(x, 0, z));
				int rnd = ThreadLocalRandom.current().nextInt(0, 40);
				wormholeVoid.setColor(new Color(rnd, 0, rnd));
				wormholeVoid.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
				wormholeVoid.setMotion(Vec3d.ZERO);
			});

			ParticleBuilder wormholeHalo = new ParticleBuilder(15);
			ParticleSpawner.spawn(wormholeHalo, world, new StaticInterp<>(new Vec3d(pos).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(5, 10), 0, (aFloat, particleBuilder) -> {
				wormholeHalo.setAlphaFunction(new InterpFadeInOut(0.2f, 0.2f));
				wormholeHalo.setRender(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double r = 0.5;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				wormholeHalo.setPositionOffset(new Vec3d(x, 0, z));
				wormholeHalo.setColor(new Color(72, 119, 122));
				wormholeHalo.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
			});

			ParticleBuilder generatorHalo = new ParticleBuilder(10);
			ParticleSpawner.spawn(generatorHalo, world, new StaticInterp<>(new Vec3d(origin).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(5, 10), 0, (aFloat, particleBuilder) -> {
				generatorHalo.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
				generatorHalo.setRender(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double r = 0.5;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				generatorHalo.setPositionOffset(new Vec3d(x, 0, z));
				generatorHalo.setColor(new Color(72, 119, 122));
				generatorHalo.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
			});

			for (BlockAXYZ.DimWithPos dimWithPos : controlPoints.keySet()) {
				if (dimWithPos.blockPos.toLong() == origin.toLong()) {
					if (ThreadLocalRandom.current().nextInt(5) == 0) {

						Pair<Vec3d, Vec3d> pair = controlPoints.get(dimWithPos);
						double shift = ThreadLocalRandom.current().nextDouble(0.1, 0.5);

						double p1r1 = pair.getFirst().xCoord + ThreadLocalRandom.current().nextDouble(-shift, shift);<commit_msg>expand particle ring when circling nonair block<commit_after>package com.teamwizardry.refraction.common.network;

import com.teamwizardry.librarianlib.client.fx.particle.ParticleBuilder;
import com.teamwizardry.librarianlib.client.fx.particle.ParticleSpawner;
import com.teamwizardry.librarianlib.client.fx.particle.functions.InterpFadeInOut;
import com.teamwizardry.librarianlib.common.network.PacketBase;
import com.teamwizardry.librarianlib.common.util.math.interpolate.StaticInterp;
import com.teamwizardry.librarianlib.common.util.math.interpolate.position.InterpBezier3D;
import com.teamwizardry.refraction.Refraction;
import com.teamwizardry.refraction.common.block.BlockAXYZ;
import io.netty.buffer.ByteBuf;
import kotlin.Pair;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

public class PacketAXYZMarks extends PacketBase {

	public static final Map<BlockAXYZ.DimWithPos, Pair<Vec3d, Vec3d>> controlPoints = new HashMap<>();

	private BlockPos[] positions, originPositions;
	private int dimension;

	public PacketAXYZMarks() {
		// NO-OP
	}

	public PacketAXYZMarks(BlockPos[] positions, BlockPos[] origins, int dimension) {
		this.positions = positions;
		this.originPositions = origins;
		this.dimension = dimension;
	}

	@Override
	public void handle(MessageContext ctx) {
		if (ctx.side.isServer()) return;

		World world = Minecraft.getMinecraft().theWorld;
		if (world.provider.getDimension() != dimension) return;

		for (int i = 0; i < positions.length; i++) {
			BlockPos pos = positions[i], origin = originPositions[i];
			double range = 5;
			controlPoints.putIfAbsent(new BlockAXYZ.DimWithPos(world.provider.getDimension(), origin),
					new Pair<>(
							new Vec3d(ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range)),
							new Vec3d(ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range),
									ThreadLocalRandom.current().nextDouble(-range, range))));

			boolean isAir = world.isAirBlock(pos);

			ParticleBuilder wormholeVoid = new ParticleBuilder(10);
			ParticleSpawner.spawn(wormholeVoid, world, new StaticInterp<>(new Vec3d(pos).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(isAir ? 5 : 10, isAir ? 10 : 20), 0, (aFloat, particleBuilder) -> {
				wormholeVoid.setAlphaFunction(new InterpFadeInOut(0.2f, 0.2f));
				wormholeVoid.setRenderNormalLayer(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double radius = 0.4;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double r = radius * ThreadLocalRandom.current().nextFloat() + (isAir ? 0 : 0.5);
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				wormholeVoid.setPositionOffset(new Vec3d(x, 0, z));
				int rnd = ThreadLocalRandom.current().nextInt(0, 40);
				wormholeVoid.setColor(new Color(rnd, 0, rnd));
				wormholeVoid.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
				wormholeVoid.setMotion(Vec3d.ZERO);
			});

			ParticleBuilder wormholeHalo = new ParticleBuilder(15);
			ParticleSpawner.spawn(wormholeHalo, world, new StaticInterp<>(new Vec3d(pos).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(isAir ? 5 : 20, isAir ? 10 : 30), 0, (aFloat, particleBuilder) -> {
				wormholeHalo.setAlphaFunction(new InterpFadeInOut(0.2f, 0.2f));
				wormholeHalo.setRender(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double r = isAir ? 0.5 : 1;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				wormholeHalo.setPositionOffset(new Vec3d(x, 0, z));
				wormholeHalo.setColor(new Color(72, 119, 122));
				wormholeHalo.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
			});

			ParticleBuilder generatorHalo = new ParticleBuilder(10);
			ParticleSpawner.spawn(generatorHalo, world, new StaticInterp<>(new Vec3d(origin).addVector(0.5, 0.5, 0.5)), ThreadLocalRandom.current().nextInt(5, 10), 0, (aFloat, particleBuilder) -> {
				generatorHalo.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
				generatorHalo.setRender(new ResourceLocation(Refraction.MOD_ID, "particles/glow"));
				double r = 0.5;
				double theta = 2.0f * (float) Math.PI * ThreadLocalRandom.current().nextFloat();
				double x = r * MathHelper.cos((float) theta);
				double z = r * MathHelper.sin((float) theta);
				generatorHalo.setPositionOffset(new Vec3d(x, 0, z));
				generatorHalo.setColor(new Color(72, 119, 122));
				generatorHalo.setScale((float) ThreadLocalRandom.current().nextDouble(1, 2));
			});

			for (BlockAXYZ.DimWithPos dimWithPos : controlPoints.keySet()) {
				if (dimWithPos.blockPos.toLong() == origin.toLong()) {
					if (ThreadLocalRandom.current().nextInt(5) == 0) {

						Pair<Vec3d, Vec3d> pair = controlPoints.get(dimWithPos);
						double shift = ThreadLocalRandom.current().nextDouble(0.1, 0.5);

						double p1r1 = pair.getFirst().xCoord + ThreadLocalRandom.current().nextDouble(-shift, shift);
{'fraction_non_alphanumeric': 0.13582712910840747, 'fraction_numerical': 0.021881242055565644, 'mean_word_length': 5.029009304871374, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '2018360', 'n_tokens_mistral': 4187, 'n_tokens_neox': 3627, 'n_words': 656}