<commit_before>package org.squiddev.cctweaks.lua.patch;

import dan200.computercraft.core.computer.Computer;
import dan200.computercraft.core.computer.IComputerEnvironment;
import dan200.computercraft.core.lua.ILuaMachine;
import dan200.computercraft.core.terminal.Terminal;
import org.squiddev.patcher.visitors.MergeVisitor;

public class Computer_Patch extends Computer {
	@MergeVisitor.Stub
	private State m_state;

	@MergeVisitor.Stub
	private ILuaMachine m_machine;

	@MergeVisitor.Stub
	public Computer_Patch(IComputerEnvironment environment, Terminal terminal, int id) {
		super(environment, terminal, id);
	}

	public void abort(boolean hard) {
		synchronized (this) {
			if (m_state != State.Off && m_machine != null) {
				if (hard) {
					m_machine.hardAbort("Too long without yielding");
				} else {
					m_machine.softAbort("Too long without yielding");
				}
			}

		}
	}

	@MergeVisitor.Stub
	private static enum State {
		Off,
		Starting,
		Running,
		Stopping;

		private State() {
		}
	}
}
<commit_msg>Add method to determine if a computer is "mostly on"<commit_after>package org.squiddev.cctweaks.lua.patch;

import dan200.computercraft.core.computer.Computer;
import dan200.computercraft.core.computer.IComputerEnvironment;
import dan200.computercraft.core.lua.ILuaMachine;
import dan200.computercraft.core.terminal.Terminal;
import org.squiddev.patcher.visitors.MergeVisitor;

public class Computer_Patch extends Computer {
	@MergeVisitor.Stub
	private State m_state;

	@MergeVisitor.Stub
	private ILuaMachine m_machine;

	@MergeVisitor.Stub
	public Computer_Patch(IComputerEnvironment environment, Terminal terminal, int id) {
		super(environment, terminal, id);
	}

	public void abort(boolean hard) {
		synchronized (this) {
			if (m_state != State.Off && m_machine != null) {
				if (hard) {
					m_machine.hardAbort("Too long without yielding");
				} else {
					m_machine.softAbort("Too long without yielding");
				}
			}

		}
	}

	public boolean isMostlyOn() {
		synchronized (this) {
			return m_state != State.Off && m_machine != null;
		}
	}

	@MergeVisitor.Stub
	private enum State {
		Off,
		Starting,
		Running,
		Stopping,
	}
}

{'fraction_non_alphanumeric': 0.10161662817551963, 'fraction_numerical': 0.011085450346420323, 'mean_word_length': 4.388059701492537, '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': '4332952', 'n_tokens_mistral': 811, 'n_tokens_neox': 709, 'n_words': 154}