<commit_before>package com.arkcraft.module.item.common.items.weapons.guns;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.arkcraft.module.core.ARKCraft;
import com.arkcraft.module.item.common.entity.item.projectiles.EntityProjectile;
import com.arkcraft.module.item.common.entity.item.projectiles.ProjectileType;
import com.arkcraft.module.item.common.items.weapons.bullets.ItemProjectile;
import com.arkcraft.module.item.common.items.weapons.handlers.IItemWeapon;
import com.arkcraft.module.item.common.items.weapons.handlers.WeaponModAttributes;
import com.arkcraft.module.item.common.tile.TileInventoryAttachment;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

public abstract class ItemRangedWeapon extends ItemBow implements IItemWeapon
{
	protected static final int MAX_DELAY = 72000;

	private Set<ItemProjectile> projectiles;
	private final int maxAmmo;
	private final int ammoConsumption;
	private final String defaultAmmoType;
	private final long shotInterval;
	private long nextShotMillis = 0;

	public ItemRangedWeapon(String name, int durability, int maxAmmo, String defaultAmmoType, int ammoConsumption, double shotInterval)
	{
		super();
		this.shotInterval = (long) shotInterval * 1000;
		this.ammoConsumption = ammoConsumption;
		this.defaultAmmoType = defaultAmmoType;
		this.maxAmmo = maxAmmo;
		this.setMaxDamage(durability);
		this.setMaxStackSize(1);
		this.projectiles = new HashSet<ItemProjectile>();
		this.setUnlocalizedName(name);
	}

	@Override
	public String getUnlocalizedName()
	{
		String s = super.getUnlocalizedName();
		return s.substring(s.indexOf('.') + 1);
	}

	public int getMaxAmmo()
	{
		return this.maxAmmo;
	}

	public long getShotInterval()
	{
		return this.shotInterval;
	}

	public int getAmmoConsumption()
	{
		return this.ammoConsumption;
	}

	public boolean registerProjectile(ItemProjectile projectile)
	{
		return this.projectiles.add(projectile);
	}

	public boolean isValidProjectile(Item item)
	{
		return this.projectiles.contains(item);
	}

	@Override
	public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
	{
		String jsonPath = ARKCraft.MODID + ":" + this.getUnlocalizedName();
		if (canScope(stack))
		{
			jsonPath = jsonPath + "_scoped";
		}
		return new ModelResourceLocation(jsonPath, "inventory");
	}

	@Override
	public Random getItemRand()
	{
		return new Random();
	}

	@Override
	public int getMaxItemUseDuration(ItemStack stack)
	{
		return MAX_DELAY;
	}

	@Override
	public boolean canScope(ItemStack stack)
	{
		return new TileInventoryAttachment(stack).isScopePresent();
	}

	@Override
	public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
	{
		if (stack.stackSize <= 0 || player.isUsingItem()) { return stack; }

		if (canFire(stack, player))
		{
			if (this.nextShotMillis < System.currentTimeMillis())
			// Start aiming weapon to fire
			player.setItemInUse(stack, getMaxItemUseDuration(stack));
		}
		// Check can reload
		else if (hasAmmoInInventory(player))
		{
			// Begin reloading
			for (int x=1; x<1; x++)
			{
				soundCharge(stack, world, player);
			}
			player.setItemInUse(stack, getMaxItemUseDuration(stack));
		}
		else
		{
			// Can't reload; no ammo
			soundEmpty(stack, world, player);
		}
		return stack;
	}

	@Override
	public EnumAction getItemUseAction(ItemStack stack)
	{
		return EnumAction.NONE;
	}

	@Override
	public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
	{
		if (canReload(stack, player) && this.getMaxItemUseDuration(stack) - count >= getReloadDuration())
		{
			if (hasAmmoAndConsume(stack, player))
			{
				effectReloadDone(stack, player.worldObj, player);
				player.clearItemInUse();
			}
		}
	}
<commit_msg>A way to check if the mouse is down<commit_after>package com.arkcraft.module.item.common.items.weapons.guns;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import org.lwjgl.input.Mouse;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.arkcraft.module.core.ARKCraft;
import com.arkcraft.module.item.common.entity.item.projectiles.EntityProjectile;
import com.arkcraft.module.item.common.entity.item.projectiles.ProjectileType;
import com.arkcraft.module.item.common.items.weapons.bullets.ItemProjectile;
import com.arkcraft.module.item.common.items.weapons.handlers.IItemWeapon;
import com.arkcraft.module.item.common.items.weapons.handlers.WeaponModAttributes;
import com.arkcraft.module.item.common.tile.TileInventoryAttachment;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

public abstract class ItemRangedWeapon extends ItemBow implements IItemWeapon
{
	protected static final int MAX_DELAY = 72000;

	private Set<ItemProjectile> projectiles;
	private final int maxAmmo;
	private final int ammoConsumption;
	private final String defaultAmmoType;
	private final long shotInterval;
	private long nextShotMillis = 0;

	public ItemRangedWeapon(String name, int durability, int maxAmmo, String defaultAmmoType, int ammoConsumption, double shotInterval)
	{
		super();
		this.shotInterval = (long) shotInterval * 1000;
		this.ammoConsumption = ammoConsumption;
		this.defaultAmmoType = defaultAmmoType;
		this.maxAmmo = maxAmmo;
		this.setMaxDamage(durability);
		this.setMaxStackSize(1);
		this.projectiles = new HashSet<ItemProjectile>();
		this.setUnlocalizedName(name);
	}

	@Override
	public String getUnlocalizedName()
	{
		String s = super.getUnlocalizedName();
		return s.substring(s.indexOf('.') + 1);
	}

	public int getMaxAmmo()
	{
		return this.maxAmmo;
	}

	public long getShotInterval()
	{
		return this.shotInterval;
	}

	public int getAmmoConsumption()
	{
		return this.ammoConsumption;
	}

	public boolean registerProjectile(ItemProjectile projectile)
	{
		return this.projectiles.add(projectile);
	}

	public boolean isValidProjectile(Item item)
	{
		return this.projectiles.contains(item);
	}

	@Override
	public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
	{
		String jsonPath = ARKCraft.MODID + ":" + this.getUnlocalizedName();
		if (canScope(stack))
		{
			jsonPath = jsonPath + "_scoped";
		}
		return new ModelResourceLocation(jsonPath, "inventory");
	}

	@Override
	public Random getItemRand()
	{
		return new Random();
	}

	@Override
	public int getMaxItemUseDuration(ItemStack stack)
	{
		return MAX_DELAY;
	}

	@Override
	public boolean canScope(ItemStack stack)
	{
		return new TileInventoryAttachment(stack).isScopePresent();
	}
	
	@Override 
    public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) 
	{
	//	EntityPlayer player = Minecraft.getMinecraft().thePlayer;

		if(Mouse.isButtonDown(-1) == true)
		{
			System.out.print("Found mouse left click");
		}
	}

	
	@Override
	public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
	{
		if (stack.stackSize <= 0 || player.isUsingItem()) { return stack; }

		if (canFire(stack, player))
		{
			if (this.nextShotMillis < System.currentTimeMillis())
			// Start aiming weapon to fire
			player.setItemInUse(stack, getMaxItemUseDuration(stack));
		}
		// Check can reload
		else if (hasAmmoInInventory(player))
		{
			// Begin reloading
			for (int x=1; x<1; x++)
			{
				soundCharge(stack, world, player);
			}
			player.setItemInUse(stack, getMaxItemUseDuration(stack));
		}
		else
		{
			// Can't reload; no ammo
			soundEmpty(stack, world, player);
		}
		return stack;
	}	

	@Override
	public EnumAction getItemUseAction(ItemStack stack)
	{
		return EnumAction.NONE;
	}

	@Override
	public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
	{
		if (canReload(stack, player) && this.getMaxItemUseDuration(stack) - count >= getReloadDuration())
		{
			if (hasAmmoAndConsume(stack, player))
			{
				effectReloadDone(stack, player.worldObj, player);
				player.clearItemInUse();
			}
		}
	}

{'fraction_non_alphanumeric': 0.10355853532748839, 'fraction_numerical': 0.0031975244971634864, 'mean_word_length': 5.086629001883239, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 9, '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': '6545288', 'n_tokens_mistral': 3388, 'n_tokens_neox': 3176, 'n_words': 626}