<commit_before>package erogenousbeef.bigreactors.common.tileentity;

import net.minecraft.tileentity.TileEntity;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
import erogenousbeef.bigreactors.common.multiblock.MultiblockReactor;
import erogenousbeef.core.common.CoordTriplet;

public class TileEntityReactorComputerPort extends TileEntityReactorPart implements IPeripheral {

	public enum ComputerMethod {
		getConnected,		// No arguments
		getActive,			// No arguments
		getTemperature,		// Optional Arg: fuel rod index
		getEnergyStored, 	// No arguments
		getFuelAmount,  	// Optional Arg: fuel rod index
		getWasteAmount, 	// Optional Arg: fuel rod index
		getControlRodName,		// Required Arg: fuel rod index
		getNumberOfFuelRods,// No arguments
		getControlRodLevel, // Required Arg: control rod index
		setActive,			// Required Arg: integer (active)
		setControlRodLevel,		// Required Args: fuel rod index, integer (insertion)
		setAllControlRodLevels,	// Required Arg: integer (insertion)
		doEjectWaste		// No arguments
	}
	
	public static final int numMethods = ComputerMethod.values().length; 
	
	@Override
	public String getType() {
		return "BigReactors-Reactor";
	}

	@Override
	public String[] getMethodNames() {
		ComputerMethod[] methods = ComputerMethod.values();
		String[] methodNames = new String[methods.length];
		for(ComputerMethod method : methods) {
			methodNames[method.ordinal()] = method.toString();
		}

		return methodNames;
	}

	@Override
	public Object[] callMethod(IComputerAccess computer, ILuaContext context,
			int method, Object[] arguments) throws Exception {
		if(method < 0 || method >= numMethods) {
			throw new IllegalArgumentException("Invalid method number");
		}
		
		// Special case: getConnected can always be called.
		if(method == 0) {
			return new Object[] { this.isConnected() };
		}

		if(!this.isConnected()) {
			throw new Exception("Unable to access reactor - port is not connected");
		}
		MultiblockReactor reactor = this.getReactorController();

		ComputerMethod computerMethod = ComputerMethod.values()[method];
		int index, newLevel;
		boolean newState;
		TileEntityReactorControlRod controlRod;

		switch(computerMethod) {
		case getEnergyStored:
			return new Object[] { (int)reactor.getEnergyStoredPercentage() };
		case getNumberOfFuelRods:
			return new Object[] { (int)reactor.getFuelColumnCount() };
		case getActive:
			return new Object[] { reactor.isActive() };
		case getTemperature:
			if(arguments.length <= 0) {
				return new Object[] { (int)reactor.getHeat() };
			}
			else {
				controlRod = getControlRodFromArguments(reactor, arguments, 0);
				return new Object[] { (int)controlRod.getHeat() };
			}
		case getFuelAmount:
			if(arguments.length <= 0) {<commit_msg>Making Lua method names consistent<commit_after>package erogenousbeef.bigreactors.common.tileentity;

import net.minecraft.tileentity.TileEntity;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
import erogenousbeef.bigreactors.common.multiblock.MultiblockReactor;
import erogenousbeef.core.common.CoordTriplet;

public class TileEntityReactorComputerPort extends TileEntityReactorPart implements IPeripheral {

	public enum ComputerMethod {
		getConnected,			// No arguments
		getActive,				// No arguments
		getTemperature,			// Optional Arg: fuel rod index
		getEnergyStored, 		// No arguments
		getFuelAmount,  		// Optional Arg: fuel rod index
		getWasteAmount, 		// Optional Arg: fuel rod index
		getControlRodName,		// Required Arg: fuel rod index
		getNumberOfControlRods,	// No arguments
		getControlRodLevel, 	// Required Arg: control rod index
		setActive,				// Required Arg: integer (active)
		setControlRodLevel,		// Required Args: fuel rod index, integer (insertion)
		setAllControlRodLevels,	// Required Arg: integer (insertion)
		doEjectWaste			// No arguments
	}
	
	public static final int numMethods = ComputerMethod.values().length; 
	
	@Override
	public String getType() {
		return "BigReactors-Reactor";
	}

	@Override
	public String[] getMethodNames() {
		ComputerMethod[] methods = ComputerMethod.values();
		String[] methodNames = new String[methods.length];
		for(ComputerMethod method : methods) {
			methodNames[method.ordinal()] = method.toString();
		}

		return methodNames;
	}

	@Override
	public Object[] callMethod(IComputerAccess computer, ILuaContext context,
			int method, Object[] arguments) throws Exception {
		if(method < 0 || method >= numMethods) {
			throw new IllegalArgumentException("Invalid method number");
		}
		
		// Special case: getConnected can always be called.
		if(method == 0) {
			return new Object[] { this.isConnected() };
		}

		if(!this.isConnected()) {
			throw new Exception("Unable to access reactor - port is not connected");
		}
		MultiblockReactor reactor = this.getReactorController();

		ComputerMethod computerMethod = ComputerMethod.values()[method];
		int index, newLevel;
		boolean newState;
		TileEntityReactorControlRod controlRod;

		switch(computerMethod) {
		case getEnergyStored:
			return new Object[] { (int)reactor.getEnergyStoredPercentage() };
		case getNumberOfControlRods:
			return new Object[] { (int)reactor.getFuelColumnCount() };
		case getActive:
			return new Object[] { reactor.isActive() };
		case getTemperature:
			if(arguments.length <= 0) {
				return new Object[] { (int)reactor.getHeat() };
			}
			else {
				controlRod = getControlRodFromArguments(reactor, arguments, 0);
				return new Object[] { (int)controlRod.getHeat() };
			}
		case getFuelAmount:
			if(arguments.length <= 0) {
{'fraction_non_alphanumeric': 0.10187950114175302, 'fraction_numerical': 0.004918320744774284, 'mean_word_length': 4.469740634005763, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2407717', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1683, 'n_words': 436}