<commit_before>package carpentersblocks.data;

import net.minecraftforge.common.ForgeDirection;
import carpentersblocks.tileentity.TEBase;
import carpentersblocks.util.BlockProperties;

public class Torch
{
	
	/**
	 * 16-bit data components:
	 *
	 *	[0000000000]	[0]		[00]	[000]
	 *  Unused			Ready	State	Facing
	 */

	public enum State {
		LIT,
		SMOLDERING,
		UNLIT
	}

	/**
	 * Returns facing.
	 */
	public final static ForgeDirection getFacing(TEBase TE)
	{
		int data = BlockProperties.getData(TE);
		
		return ForgeDirection.getOrientation(data & 0x7);
	}

	/**
	 * Sets facing.
	 */
	public final static void setFacing(TEBase TE, int side)
	{
		int temp = BlockProperties.getData(TE) & 0xfff8;
		temp |= side;

		BlockProperties.setData(TE, temp);
	}

	/**
	 * Returns state.
	 */
	public final static State getState(TEBase TE)
	{
		int data = BlockProperties.getData(TE);
		
		int temp = data & 0x18;
		int val = temp >> 3;
		
		return val == State.LIT.ordinal() ? State.LIT : val == State.SMOLDERING.ordinal() ? State.SMOLDERING : State.UNLIT;
	}

	/**
	 * Sets state.
	 */
	public final static void setState(TEBase TE, State state)
	{
		if (!state.equals(State.LIT)) {
			double[] headCoords = getHeadCoordinates(TE);
			TE.worldObj.playSoundEffect(headCoords[0], headCoords[1], headCoords[2], "random.fizz", 0.5F, 2.6F + (TE.worldObj.rand.nextFloat() - TE.worldObj.rand.nextFloat()) * 0.8F);
		}
		
		int temp = BlockProperties.getData(TE) & 0xffe7;
		temp |= state.ordinal() << 3;<commit_msg>Fixed torch playing hissing sound for incorrect state changes.<commit_after>package carpentersblocks.data;

import net.minecraftforge.common.ForgeDirection;
import carpentersblocks.tileentity.TEBase;
import carpentersblocks.util.BlockProperties;

public class Torch
{
	
	/**
	 * 16-bit data components:
	 *
	 *	[0000000000]	[0]		[00]	[000]
	 *  Unused			Ready	State	Facing
	 */

	public enum State {
		LIT,
		SMOLDERING,
		UNLIT
	}

	/**
	 * Returns facing.
	 */
	public final static ForgeDirection getFacing(TEBase TE)
	{
		int data = BlockProperties.getData(TE);
		
		return ForgeDirection.getOrientation(data & 0x7);
	}

	/**
	 * Sets facing.
	 */
	public final static void setFacing(TEBase TE, int side)
	{
		int temp = BlockProperties.getData(TE) & 0xfff8;
		temp |= side;

		BlockProperties.setData(TE, temp);
	}

	/**
	 * Returns state.
	 */
	public final static State getState(TEBase TE)
	{
		int data = BlockProperties.getData(TE);
		
		int temp = data & 0x18;
		int val = temp >> 3;
		
		return val == State.LIT.ordinal() ? State.LIT : val == State.SMOLDERING.ordinal() ? State.SMOLDERING : State.UNLIT;
	}

	/**
	 * Sets state.
	 */
	public final static void setState(TEBase TE, State state)
	{
		if (state.ordinal() > getState(TE).ordinal()) {
			double[] headCoords = getHeadCoordinates(TE);
			TE.worldObj.playSoundEffect(headCoords[0], headCoords[1], headCoords[2], "random.fizz", 0.5F, 2.6F + (TE.worldObj.rand.nextFloat() - TE.worldObj.rand.nextFloat()) * 0.8F);
		}
		
		int temp = BlockProperties.getData(TE) & 0xffe7;
		temp |= state.ordinal() << 3;
{'fraction_non_alphanumeric': 0.1356980149690856, 'fraction_numerical': 0.024731532704197853, 'mean_word_length': 3.5608308605341246, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6252544', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1095, 'n_words': 244}