}
public void swingHit() {
ChunkCoordinates coords = getTargetLoc();
ItemStack stack = getStackInSlot(0);
Item item = stack.getItem();
Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
player.setCurrentItemOrArmor(0, stack);
//EntityPlayer realPlayer=MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(Owner);
//NBTTagCompound data=realPlayer.getEntityData().getCompoundTag("PlayerPersisted");
//player.getEntityData().setCompoundTag("PlayerPersisted",data);
//NBTTagCompound cmp=player.getEntityData().getCompoundTag("PlayerPersisted");
//System.out.println(cmp.getCompoundTag("TCResearch").getTagList("TCResearchList").tagCount());
boolean done = false;
if (leftClick) {
Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
if (entity != null) {
player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers()); // Set attack strenght
player.attackTargetEntityWithCurrentItem(entity);
done = true;
} else if (!isBreaking) {
if (block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ) && block.getBlockHardness(worldObj, coords.posX, coords.posY, coords.posZ) >= 0) {
isBreaking = true;
startBreaking(block, worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ));
done = true;
}
}
} else {
int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
if (!(block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ))) {
coords.posY -= 1;
side = ForgeDirection.UP.ordinal();
block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
}
try {
ForgeEventFactory.onPlayerInteract(player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side,worldObj);
Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
done = entity != null && entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, player, (EntityLivingBase) entity) || (!(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(player)));
if (!done)
item.onItemUseFirst(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
if (!done)
done = block != null && block.onBlockActivated(worldObj, coords.posX, coords.posY, coords.posZ, player, side, 0F, 0F, 0F);
if (!done)
done = item.onItemUse(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
if (!done) {
item.onItemRightClick(stack, worldObj, player);
done = true;
}
} catch (Throwable e) {
e.printStackTrace();