<commit_before>package zmaster587.advancedRocketry.tile;

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

import org.apache.commons.lang3.ArrayUtils;

import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import zmaster587.advancedRocketry.tile.multiblock.TilePlaceholder;
import zmaster587.libVulpes.block.BlockMeta;

public class TileSchematic extends TilePlaceholder {

	private final int ttl = 6000;
	private int timeAlive = 0;
	List<BlockMeta> possibleBlocks;

	public TileSchematic() {
		possibleBlocks = new ArrayList<BlockMeta>();
	}
	
	@Override
	public boolean canUpdate() {
		return true;
	}

	public void setReplacedBlock(List<BlockMeta> block) {
		possibleBlocks = block;
	}
	
	@Override
	public void setReplacedBlock(Block block) {
		super.setReplacedBlock(block);
		possibleBlocks.clear();
	}
	
	@Override
	public void setReplacedBlockMeta(byte meta) {
		super.setReplacedBlockMeta(meta);
		possibleBlocks.clear();
	}

	@Override
	public Block getReplacedBlock() {
		if(possibleBlocks.isEmpty())
			return super.getReplacedBlock();
		else
			return possibleBlocks.get((timeAlive/20) % possibleBlocks.size()).getBlock();
	}
	
	@Override
	public byte getReplacedBlockMeta() {
		if(possibleBlocks.isEmpty())
			return super.getReplacedBlockMeta();
		else
			return possibleBlocks.get((timeAlive/20) % possibleBlocks.size()).getMeta();
	}

	@Override
	public void updateEntity() {
		super.updateEntity();

		if(!worldObj.isRemote) {
			if(timeAlive == ttl) {
				worldObj.setBlockToAir(xCoord, yCoord, zCoord);
			}
		}
		timeAlive++;
	}

	@Override
	public void writeToNBT(NBTTagCompound nbt) {
		super.writeToNBT(nbt);
		nbt.setInteger("timeAlive", timeAlive);
		
		List<Integer> blockIds = new ArrayList<Integer>();
		List<Integer> blockMetas = new ArrayList<Integer>();
		for(int i = 0;  i < possibleBlocks.size();i++) {
			blockIds.add(Block.getIdFromBlock(possibleBlocks.get(i).getBlock()));
			blockMetas.add((int)possibleBlocks.get(i).getMeta());
		}
		
		if(!blockIds.isEmpty()) {
			Integer[] bufferSpace1 = new Integer[blockIds.size()];
			Integer[] bufferSpace2 = new Integer[blockIds.size()];
			nbt.setIntArray("blockIds", ArrayUtils.toPrimitive(blockIds.toArray(bufferSpace1)));
			nbt.setIntArray("blockMetas", ArrayUtils.toPrimitive(blockMetas.toArray(bufferSpace2)));
		}
	}

	@Override
	public void readFromNBT(NBTTagCompound nbt) {
		super.readFromNBT(nbt);
		timeAlive = nbt.getInteger("timeAlive");
		
		if(nbt.hasKey("blockIds")) {
			int[] block = nbt.getIntArray("blockIds");
			int[] metas = nbt.getIntArray("blockMetas");
			possibleBlocks.clear();
			
			for(int i = 0; i < block.length; i++) {
				possibleBlocks.add(new BlockMeta(Block.getBlockById(block[i]), metas[i]));
			}
		}
	}
}<commit_msg>Fix NPEs with the schematics that can be caused by removal of a mod (like IC2)<commit_after>package zmaster587.advancedRocketry.tile;

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

import org.apache.commons.lang3.ArrayUtils;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import zmaster587.advancedRocketry.tile.multiblock.TilePlaceholder;
import zmaster587.libVulpes.block.BlockMeta;

public class TileSchematic extends TilePlaceholder {

	private final int ttl = 6000;
	private int timeAlive = 0;
	List<BlockMeta> possibleBlocks;

	public TileSchematic() {
		possibleBlocks = new ArrayList<BlockMeta>();
	}

	@Override
	public boolean canUpdate() {
		return true;
	}

	public void setReplacedBlock(List<BlockMeta> block) {
		possibleBlocks = block;
	}

	@Override
	public void setReplacedBlock(Block block) {
		super.setReplacedBlock(block);
		possibleBlocks.clear();
	}

	@Override
	public void setReplacedBlockMeta(byte meta) {
		super.setReplacedBlockMeta(meta);
		possibleBlocks.clear();
	}

	@Override
	public Block getReplacedBlock() {
		if(possibleBlocks.isEmpty())
			return super.getReplacedBlock();
		else {
			return possibleBlocks.get((timeAlive/20) % possibleBlocks.size()).getBlock();
		}
	}

	@Override
	public byte getReplacedBlockMeta() {
		if(possibleBlocks.isEmpty())
			return super.getReplacedBlockMeta();
		else
			return possibleBlocks.get((timeAlive/20) % possibleBlocks.size()).getMeta();
	}

	@Override
	public void updateEntity() {
		super.updateEntity();

		if(!worldObj.isRemote) {
			if(timeAlive == ttl) {
				worldObj.setBlockToAir(xCoord, yCoord, zCoord);
			}
		}
		timeAlive++;
	}

	@Override
	public void writeToNBT(NBTTagCompound nbt) {
		super.writeToNBT(nbt);
		nbt.setInteger("timeAlive", timeAlive);

		List<Integer> blockIds = new ArrayList<Integer>();
		List<Integer> blockMetas = new ArrayList<Integer>();
		for(int i = 0;  i < possibleBlocks.size();i++) {
			blockIds.add(Block.getIdFromBlock(possibleBlocks.get(i).getBlock()));
			blockMetas.add((int)possibleBlocks.get(i).getMeta());
		}

		if(!blockIds.isEmpty()) {
			Integer[] bufferSpace1 = new Integer[blockIds.size()];
			Integer[] bufferSpace2 = new Integer[blockIds.size()];
			nbt.setIntArray("blockIds", ArrayUtils.toPrimitive(blockIds.toArray(bufferSpace1)));
			nbt.setIntArray("blockMetas", ArrayUtils.toPrimitive(blockMetas.toArray(bufferSpace2)));
		}
	}

	@Override
	public void readFromNBT(NBTTagCompound nbt) {
		super.readFromNBT(nbt);
		timeAlive = nbt.getInteger("timeAlive");

		if(nbt.hasKey("blockIds")) {
			int[] block = nbt.getIntArray("blockIds");
			int[] metas = nbt.getIntArray("blockMetas");
			possibleBlocks.clear();

			for(int i = 0; i < block.length; i++) {
				if(Block.getBlockById(block[i]) != Blocks.air)
					possibleBlocks.add(new BlockMeta(Block.getBlockById(block[i]), metas[i]));
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.1347442680776014, 'fraction_numerical': 0.008994708994708995, 'mean_word_length': 5.058760683760684, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '2560998', 'n_tokens_mistral': 2133, 'n_tokens_neox': 1915, 'n_words': 335}