<commit_before>package com.creativemd.littletiles.common.utils.animation;

import java.util.Set;

import javax.vecmath.Vector3d;

import com.creativemd.creativecore.common.utils.math.Rotation;
import com.creativemd.creativecore.common.utils.type.Pair;
import com.creativemd.creativecore.common.utils.type.PairList;

import net.minecraft.nbt.NBTTagCompound;

public class AnimationState {
	
	private PairList<AnimationKey, Double> values = new PairList<>();
	
	public double get(AnimationKey key) {
		Double value = values.getValue(key);
		if (value == null)
			return key.getDefault();
		return value;
	}
	
	public AnimationState set(AnimationKey key, double value) {
		if (key.getDefault() == value)
			return this;
		
		Pair<AnimationKey, Double> pair = values.getPair(key);
		if (pair != null)
			pair.setValue(value);
		else
			values.add(key, value);
		return this;
	}
	
	public AnimationState(NBTTagCompound nbt) {
		for (AnimationKey key : AnimationKey.getKeys())
			if (nbt.hasKey(key.name))
				values.add(key, nbt.getDouble(key.name));
	}
	
	public AnimationState() {
		
	}
	
	public Vector3d getRotation() {
		return new Vector3d(get(AnimationKey.rotX), get(AnimationKey.rotY), get(AnimationKey.rotZ));
	}
	
	public Vector3d getOffset() {
		return new Vector3d(get(AnimationKey.offX), get(AnimationKey.offY), get(AnimationKey.offZ));
	}
	
	public void clear() {
		values.clear();
	}
	<commit_msg>Fixed stop button in structure preview<commit_after>package com.creativemd.littletiles.common.utils.animation;

import java.util.Set;

import javax.vecmath.Vector3d;

import com.creativemd.creativecore.common.utils.math.Rotation;
import com.creativemd.creativecore.common.utils.type.Pair;
import com.creativemd.creativecore.common.utils.type.PairList;

import net.minecraft.nbt.NBTTagCompound;

public class AnimationState {
	
	private PairList<AnimationKey, Double> values = new PairList<>();
	
	public double get(AnimationKey key) {
		Double value = values.getValue(key);
		if (value == null)
			return key.getDefault();
		return value;
	}
	
	public AnimationState set(AnimationKey key, double value) {
		Pair<AnimationKey, Double> pair = values.getPair(key);
		
		if (key.getDefault() == value) {
			if (pair != null)
				values.removeKey(key);
			return this;
		}
		
		if (pair != null)
			pair.setValue(value);
		else
			values.add(key, value);
		return this;
	}
	
	public AnimationState(NBTTagCompound nbt) {
		for (AnimationKey key : AnimationKey.getKeys())
			if (nbt.hasKey(key.name))
				values.add(key, nbt.getDouble(key.name));
	}
	
	public AnimationState() {
		
	}
	
	public Vector3d getRotation() {
		return new Vector3d(get(AnimationKey.rotX), get(AnimationKey.rotY), get(AnimationKey.rotZ));
	}
	
	public Vector3d getOffset() {
		return new Vector3d(get(AnimationKey.offX), get(AnimationKey.offY), get(AnimationKey.offZ));
	}
	
	public void clear() {
		values.clear();
	}
	
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.003453038674033149, 'mean_word_length': 4.486742424242424, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3876638', 'n_tokens_mistral': 1068, 'n_tokens_neox': 959, 'n_words': 197}