<commit_before>/***************************************************************************
 * Temporal Convergence
 * Copyright (C) 2017
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 **************************************************************************/
package daxum.temporalconvergence.tileentity;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.items.ItemStackHandler;

public class TileTimeFurnace extends TileTimeFurnaceBase {
	private BlockPos controllerPos = null;

	public void setControllerPos(BlockPos pos) {
		controllerPos = pos;
		sendBlockUpdate();
	}

	@Override
	public BlockPos getControllerPos() {
		return controllerPos;
	}

	@Override
	public ItemStackHandler getInventory() {
		TileTimeFurnaceController contr = getController();

		if (contr != null) {
			return contr.getInventory();
		}

		return null;
	}

	@Override
	public TileTimeFurnaceController getController() {
		if (controllerPos != null) {
			TileEntity contr = world.getTileEntity(controllerPos);

			if (contr instanceof TileTimeFurnaceController) {
				return (TileTimeFurnaceController) contr;
			}
		}

		return null;
	}

	private static final String CONTROLLER_TAG = "controller";

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound comp) {
		if (controllerPos != null) {
			comp.setLong(CONTROLLER_TAG, controllerPos.toLong());
		}

		return super.writeToNBT(comp);
	}

	@Override
	public void readFromNBT(NBTTagCompound comp) {
		super.readFromNBT(comp);

		if (comp.hasKey(CONTROLLER_TAG, Constants.NBT.TAG_LONG)) {
			controllerPos = BlockPos.fromLong(comp.getLong(CONTROLLER_TAG));
		}
	}
}
<commit_msg>Simplified getting controller<commit_after>/***************************************************************************
 * Temporal Convergence
 * Copyright (C) 2017
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 **************************************************************************/
package daxum.temporalconvergence.tileentity;

import daxum.temporalconvergence.util.WorldHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.items.ItemStackHandler;

public class TileTimeFurnace extends TileTimeFurnaceBase {
	private BlockPos controllerPos = null;

	public void setControllerPos(BlockPos pos) {
		controllerPos = pos;
		sendBlockUpdate();
	}

	@Override
	public BlockPos getControllerPos() {
		return controllerPos;
	}

	@Override
	public ItemStackHandler getInventory() {
		TileTimeFurnaceController contr = getController();

		if (contr != null) {
			return contr.getInventory();
		}

		return null;
	}

	@Override
	public TileTimeFurnaceController getController() {
		if (controllerPos != null) {
			return WorldHelper.getTileEntity(world, controllerPos, TileTimeFurnaceController.class);
		}

		return null;
	}

	private static final String CONTROLLER_TAG = "controller";

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound comp) {
		if (controllerPos != null) {
			comp.setLong(CONTROLLER_TAG, controllerPos.toLong());
		}

		return super.writeToNBT(comp);
	}

	@Override
	public void readFromNBT(NBTTagCompound comp) {
		super.readFromNBT(comp);

		if (comp.hasKey(CONTROLLER_TAG, Constants.NBT.TAG_LONG)) {
			controllerPos = BlockPos.fromLong(comp.getLong(CONTROLLER_TAG));
		}
	}
}

{'fraction_non_alphanumeric': 0.13645662847790507, 'fraction_numerical': 0.006955810147299509, 'mean_word_length': 4.991421568627451, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7251288', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1361, 'n_words': 432}