}
}
else if(heldItem instanceof ItemGun)
{
ItemGun gunItem = (ItemGun)heldItem;
GunType gunType = gunItem.type;
//Get the correct shoot delay
int delay = left ? shootDelayLeft : shootDelayRight;
//If we can shoot
if(delay <= 0)
{
//Go through the bullet stacks in the gun and see if any of them are not null
int bulletID = 0;
ItemStack bulletStack = null;
for(; bulletID < gunType.numAmmoItemsInGun; bulletID++)
{
ItemStack checkingStack = gunItem.getBulletItemStack(heldStack, bulletID);
if(checkingStack != null && checkingStack.getItem() != null && checkingStack.getItemDamage() < checkingStack.getMaxDamage())
{
bulletStack = checkingStack;
break;
}
}
//If no bullet stack was found, reload
if(bulletStack == null)
{
gunItem.reload(heldStack, gunType, worldObj, this, driveableData, (infiniteAmmo() ? true : creative), false);
}
//A bullet stack was found, so try shooting with it
else if(bulletStack.getItem() instanceof ItemBullet)
{
//Shoot
shoot(heldStack, gunType, bulletStack, creative, left);
//Apply animations to 3D modelled guns
//TODO : Move to client side and sync
if(worldObj.isRemote)
{
int pumpDelay = gunType.model == null ? 0 : gunType.model.pumpDelay;
int pumpTime = gunType.model == null ? 1 : gunType.model.pumpTime;
if(left)
{
leftAnimations.doShoot(pumpDelay, pumpTime);
}
else
{
rightAnimations.doShoot(pumpDelay, pumpTime);
}
}
//Damage the bullet item
bulletStack.setItemDamage(bulletStack.getItemDamage() + 1);
//Update the stack in the gun
gunItem.setBulletItemStack(heldStack, bulletStack, bulletID);
}
}
}
}
return true;