<commit_before>package com.creativemd.littletiles.common.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;

import com.creativemd.creativecore.common.utils.math.Rotation;
import com.creativemd.creativecore.common.utils.mc.WorldUtils;
import com.creativemd.creativecore.common.utils.type.UUIDSupplier;
import com.creativemd.littletiles.common.action.block.LittleActionPlaceStack;
import com.creativemd.littletiles.common.action.block.LittleActionPlaceStack.LittlePlaceResult;
import com.creativemd.littletiles.common.structure.LittleStructure;
import com.creativemd.littletiles.common.structure.type.door.LittleDoor;
import com.creativemd.littletiles.common.structure.type.door.LittleDoor.DoorOpeningResult;
import com.creativemd.littletiles.common.tileentity.TileEntityLittleTiles;
import com.creativemd.littletiles.common.tiles.place.PlacePreviewTile;
import com.creativemd.littletiles.common.tiles.preview.LittleAbsolutePreviewsStructure;
import com.creativemd.littletiles.common.tiles.vec.LittleTileVec;
import com.creativemd.littletiles.common.utils.animation.AnimationController;
import com.creativemd.littletiles.common.utils.animation.AnimationState;
import com.creativemd.littletiles.common.utils.animation.AnimationTimeline;
import com.creativemd.littletiles.common.utils.placing.PlacementMode;
import com.creativemd.littletiles.common.utils.vec.LittleTransformation;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class DoorController extends EntityAnimationController {
	
	protected boolean isWaitingForApprove = false;
	protected int ticksToWait = -1;
	protected static final int waitTimeApprove = 300;
	protected static final int waitTimeRender = 200;
	protected Boolean placed = null;
	
	public static final String openedState = "opened";
	public static final String closedState = "closed";
	public Boolean turnBack;
	public int duration;
	public int completeDuration;
	public EntityPlayer activator;
	public DoorOpeningResult result;
	public UUIDSupplier supplier;
	
	protected boolean modifiedTransition;
	
	@SideOnly(Side.CLIENT)
	List<TileEntityLittleTiles> waitingForRender;
	
	public DoorController() {
		
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState closed, AnimationState opened, Boolean turnBack, int duration, int completeDuration) {
		this.result = result;
		this.supplier = supplier;
		
		this.turnBack = turnBack;
		this.duration = duration;
		this.completeDuration = completeDuration;
		
		addState(openedState, opened);
		addStateAndSelect(closedState, closed);
		
		generateAllTransistions(duration);
		modifiedTransition = false;
		
		stretchTransitions();
		startTransition(openedState);
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState closed, AnimationState opened, Boolean turnBack, int duration, int completeDuration, AnimationTimeline open, AnimationTimeline close) {
		this.result = result;
		this.supplier = supplier;
		
		this.turnBack = turnBack;
		this.duration = duration;
		this.completeDuration = completeDuration;
		
		addState(openedState, opened);
		addStateAndSelect(closedState, closed);
		
		addTransition("closed", "opened", open);
		addTransition("opened", "closed", close);
		
		stretchTransitions();
		startTransition(openedState);
	}
	
	@Override
	public AnimationController addTransition(String from, String to, AnimationTimeline animation) {
		modifiedTransition = true;
		return super.addTransition(from, to, animation);
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState opened, Boolean turnBack, int duration, int completeDuration) {
		this(result, supplier, new AnimationState(), opened, turnBack, duration, completeDuration);
	}
	
	protected void stretchTransitions() {
		completeDuration = Math.max(completeDuration, duration);
		for (AnimationTimeline timeline : stateTransition.values()) {
			timeline.duration = completeDuration;
		}
	}
	
	@Override
	public EntityPlayer activator() {
		return activator;
	}
	
	public void markWaitingForApprove() {
		isWaitingForApprove = true;
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public void removeWaitingTe(TileEntityLittleTiles te) {
		synchronized (waitingForRender) {
			waitingForRender.remove(te);
		}
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public boolean isWaitingForRender() {
		return waitingForRender != null;
	}
	
	public boolean activate() {
		if (placed != null)<commit_msg>Fixed crash at the end of animations<commit_after>package com.creativemd.littletiles.common.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;

import com.creativemd.creativecore.common.utils.math.Rotation;
import com.creativemd.creativecore.common.utils.mc.WorldUtils;
import com.creativemd.creativecore.common.utils.type.UUIDSupplier;
import com.creativemd.littletiles.common.action.block.LittleActionPlaceStack;
import com.creativemd.littletiles.common.action.block.LittleActionPlaceStack.LittlePlaceResult;
import com.creativemd.littletiles.common.structure.LittleStructure;
import com.creativemd.littletiles.common.structure.type.door.LittleDoor;
import com.creativemd.littletiles.common.structure.type.door.LittleDoor.DoorOpeningResult;
import com.creativemd.littletiles.common.tileentity.TileEntityLittleTiles;
import com.creativemd.littletiles.common.tiles.place.PlacePreviewTile;
import com.creativemd.littletiles.common.tiles.preview.LittleAbsolutePreviewsStructure;
import com.creativemd.littletiles.common.tiles.vec.LittleTileVec;
import com.creativemd.littletiles.common.utils.animation.AnimationController;
import com.creativemd.littletiles.common.utils.animation.AnimationState;
import com.creativemd.littletiles.common.utils.animation.AnimationTimeline;
import com.creativemd.littletiles.common.utils.placing.PlacementMode;
import com.creativemd.littletiles.common.utils.vec.LittleTransformation;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class DoorController extends EntityAnimationController {
	
	protected boolean isWaitingForApprove = false;
	protected int ticksToWait = -1;
	protected static final int waitTimeApprove = 300;
	protected static final int waitTimeRender = 200;
	protected Boolean placed = null;
	
	public static final String openedState = "opened";
	public static final String closedState = "closed";
	public Boolean turnBack;
	public int duration;
	public int completeDuration;
	public EntityPlayer activator;
	public DoorOpeningResult result;
	public UUIDSupplier supplier;
	
	protected boolean modifiedTransition;
	
	@SideOnly(Side.CLIENT)
	List<TileEntityLittleTiles> waitingForRender;
	
	public DoorController() {
		
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState closed, AnimationState opened, Boolean turnBack, int duration, int completeDuration) {
		this.result = result;
		this.supplier = supplier;
		
		this.turnBack = turnBack;
		this.duration = duration;
		this.completeDuration = completeDuration;
		
		addState(openedState, opened);
		addStateAndSelect(closedState, closed);
		
		generateAllTransistions(duration);
		modifiedTransition = false;
		
		stretchTransitions();
		startTransition(openedState);
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState closed, AnimationState opened, Boolean turnBack, int duration, int completeDuration, AnimationTimeline open, AnimationTimeline close) {
		this.result = result;
		this.supplier = supplier;
		
		this.turnBack = turnBack;
		this.duration = duration;
		this.completeDuration = completeDuration;
		
		addState(openedState, opened);
		addStateAndSelect(closedState, closed);
		
		addTransition("closed", "opened", open);
		addTransition("opened", "closed", close);
		
		stretchTransitions();
		startTransition(openedState);
	}
	
	@Override
	public AnimationController addTransition(String from, String to, AnimationTimeline animation) {
		modifiedTransition = true;
		return super.addTransition(from, to, animation);
	}
	
	public DoorController(DoorOpeningResult result, UUIDSupplier supplier, AnimationState opened, Boolean turnBack, int duration, int completeDuration) {
		this(result, supplier, new AnimationState(), opened, turnBack, duration, completeDuration);
	}
	
	protected void stretchTransitions() {
		completeDuration = Math.max(completeDuration, duration);
		for (AnimationTimeline timeline : stateTransition.values()) {
			timeline.duration = completeDuration;
		}
	}
	
	@Override
	public EntityPlayer activator() {
		return activator;
	}
	
	public void markWaitingForApprove() {
		isWaitingForApprove = true;
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public void removeWaitingTe(TileEntityLittleTiles te) {
		if (!isWaitingForRender())
			return;
		synchronized (waitingForRender) {
			waitingForRender.remove(te);
		}
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public boolean isWaitingForRender() {
		return waitingForRender != null;
	}
	
	public boolean activate() {
		if (placed != null)
{'fraction_non_alphanumeric': 0.08834682791841755, 'fraction_numerical': 0.001434867274777083, 'mean_word_length': 6.0761421319796955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3142693', 'n_tokens_mistral': 3077, 'n_tokens_neox': 2819, 'n_words': 580}