<commit_before>/*
 * Copyright (C) 2014 Evil-Co <http://wwww.evil-co.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.evilco.mc.defense.common.item.generic;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import org.evilco.mc.defense.api.network.surveillance.ISurveillanceNetworkAuthority;
import org.evilco.mc.defense.common.DefenseNames;
import org.evilco.mc.defense.common.block.DefenseBlock;
import org.evilco.mc.defense.common.gui.creative.DefenseCreativeTab;
import org.evilco.mc.defense.common.tile.generic.DefenseStationTileEntity;

/**
 * @auhtor <NAME> <<EMAIL>>
 * @copyright Copyright (C) 2014 Evil-Co <http://www.evil-co.org>
 */
public class DefenseStationItem extends Item {

	/**
	 * Constructs a new DefenseStationItem.
	 */
	public DefenseStationItem () {
		super ();

		this.setUnlocalizedName (DefenseNames.ITEM_GENERIC_DEFENSE_STATION);
		this.setCreativeTab (DefenseCreativeTab.GENERIC);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean onItemUse (ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
		// skip client execution
		if (par3World.isRemote) return true;

		// check whether players may edit the block
		if (!par2EntityPlayer.canPlayerEdit (par4, par5, par6, par7, par1ItemStack)) return false;

		// check position
		if (par7 != 1) return false;

		// check for air blocks
		if (!par3World.isAirBlock (par4, (par5 + 1), par6) || !par3World.isAirBlock (par4, (par5 + 2), par6)) return false;

		// calculate rotation
		int metadata = MathHelper.floor_double (((double) (par2EntityPlayer.rotationYaw * 4.0f) / 360f + 2.5D)) & 3;

		// set block
		par3World.setBlock (par4, (par5 + 1), par6, DefenseBlock.GENERIC_DEFENSE_STATION, metadata, 2);
		if (!par2EntityPlayer.capabilities.isCreativeMode) par1ItemStack.stackSize--;

		// update tile entity
		DefenseStationTileEntity tileEntity = ((DefenseStationTileEntity) par3World.getTileEntity(par4, (par5 + 1), par6));

		// add player to whitelist
		tileEntity.addWhitelist (par2EntityPlayer);

		// set tier
		tileEntity.setTier (par1ItemStack.getItemDamage ());

		// confirm item use
		return true;
	}


}<commit_msg>Added name localization for higher station tiers.<commit_after>/*
 * Copyright (C) 2014 Evil-Co <http://wwww.evil-co.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.evilco.mc.defense.common.item.generic;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import org.evilco.mc.defense.common.DefenseNames;
import org.evilco.mc.defense.common.block.DefenseBlock;
import org.evilco.mc.defense.common.gui.creative.DefenseCreativeTab;
import org.evilco.mc.defense.common.tile.generic.DefenseStationTileEntity;

/**
 * @auhtor <NAME> <<EMAIL>>
 * @copyright Copyright (C) 2014 Evil-Co <http://www.evil-co.org>
 */
public class DefenseStationItem extends Item {

	/**
	 * Constructs a new DefenseStationItem.
	 */
	public DefenseStationItem () {
		super ();

		this.setUnlocalizedName (DefenseNames.ITEM_GENERIC_DEFENSE_STATION);
		this.setCreativeTab (DefenseCreativeTab.GENERIC);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean onItemUse (ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
		// skip client execution
		if (par3World.isRemote) return true;

		// check whether players may edit the block
		if (!par2EntityPlayer.canPlayerEdit (par4, par5, par6, par7, par1ItemStack)) return false;

		// check position
		if (par7 != 1) return false;

		// check for air blocks
		if (!par3World.isAirBlock (par4, (par5 + 1), par6) || !par3World.isAirBlock (par4, (par5 + 2), par6)) return false;

		// calculate rotation
		int metadata = MathHelper.floor_double (((double) (par2EntityPlayer.rotationYaw * 4.0f) / 360f + 2.5D)) & 3;

		// set block
		par3World.setBlock (par4, (par5 + 1), par6, DefenseBlock.GENERIC_DEFENSE_STATION, metadata, 2);
		if (!par2EntityPlayer.capabilities.isCreativeMode) par1ItemStack.stackSize--;

		// update tile entity
		DefenseStationTileEntity tileEntity = ((DefenseStationTileEntity) par3World.getTileEntity(par4, (par5 + 1), par6));

		// add player to whitelist
		tileEntity.addWhitelist (par2EntityPlayer);

		// set tier
		tileEntity.setTier (par1ItemStack.getItemDamage ());

		// confirm item use
		return true;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getUnlocalizedName (ItemStack par1ItemStack) {
		String name = super.getUnlocalizedName (par1ItemStack);

		switch (par1ItemStack.getItemDamage ()) {
			case 0: break;
			case 1: name += ".advanced"; break;
			case 2: name += ".expert"; break;
			default: name += ".unknown"; break;
		}

		return name;
	}
}
{'fraction_non_alphanumeric': 0.1142198815009875, 'fraction_numerical': 0.02271231073074391, 'mean_word_length': 4.270598438855161, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '3319362', 'n_tokens_mistral': 2073, 'n_tokens_neox': 1903, 'n_words': 540}